diff --git a/Project1.dproj.local b/Project1.dproj.local index 2e6cb3c..3d1a545 100644 --- a/Project1.dproj.local +++ b/Project1.dproj.local @@ -2,34 +2,34 @@ 2018/08/02 11:30:33.000.203,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2018/08/02 11:33:44.000.784,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormSplash.dfm - 2018/08/02 11:33:44.000.784,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormSplash.pas - 2018/08/02 11:34:22.000.896,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj + 2018/08/02 11:33:44.000.784,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormSplash.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.dfm + 2018/08/02 11:33:44.000.784,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormSplash.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.pas + 2018/08/02 11:34:22.000.896,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Project1.dproj 2018/08/02 11:34:57.000.485,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_Cadastro_Forms\UnitLista.pas - 2018/08/02 11:35:17.000.765,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_Cadastro_Forms\UnitLista.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitLista.pas + 2018/08/02 11:35:17.000.765,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitLista.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_Cadastro_Forms\UnitLista.pas 2018/08/02 11:35:39.000.518,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/02 11:37:42.000.005,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPadrao.pas - 2018/08/02 11:37:42.000.005,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPadrao.dfm + 2018/08/02 11:37:42.000.005,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPadrao.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas + 2018/08/02 11:37:42.000.005,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPadrao.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm 2018/08/02 11:50:57.000.642,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/02 11:51:22.000.511,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormCidade.dfm - 2018/08/02 11:51:22.000.511,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormCidade.pas + 2018/08/02 11:51:22.000.511,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormCidade.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas + 2018/08/02 11:51:22.000.511,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormCidade.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm 2018/08/02 11:54:03.000.448,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/03 07:57:41.000.908,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/03 07:59:28.000.101,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormEstado.dfm - 2018/08/03 07:59:28.000.101,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormEstado.pas + 2018/08/03 07:59:28.000.101,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormEstado.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm + 2018/08/03 07:59:28.000.101,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormEstado.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas 2018/08/03 09:19:04.000.339,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/03 09:22:08.000.430,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPais.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/03 09:22:08.000.430,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPais.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm + 2018/08/03 09:22:08.000.430,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPais.pas + 2018/08/03 09:22:08.000.430,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormPais.dfm 2018/08/03 11:37:12.000.927,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/03 12:44:44.000.083,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/06 10:32:04.000.123,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/06 10:39:43.000.299,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormGrid.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/06 10:39:43.000.299,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormGrid.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm + 2018/08/06 10:39:43.000.299,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.dfm=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormGrid.dfm + 2018/08/06 10:39:43.000.299,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitFormGrid.pas 2018/08/07 12:32:02.000.009,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/08 10:01:00.000.149,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitSharedVariables.pas 2018/08/08 10:50:02.000.574,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitSharedVariables.pas= 2018/08/08 10:52:58.000.982,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas - 2018/08/08 10:53:51.000.544,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitDados.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas + 2018/08/08 10:53:51.000.544,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitDados.pas 2018/08/08 12:16:26.000.969,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/08 14:58:46.000.344,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/14 14:54:15.000.469,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj @@ -38,7 +38,7 @@ 2018/08/15 15:04:40.000.526,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/16 11:06:43.000.602,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj 2018/08/17 12:26:51.000.000,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Project1.dproj - 2018/08/21 09:38:54.903,C:\Users\programacaounico38\Documents\Projects\crud_delphi\Project1.dproj=C:\Users\programacaounico38\Documents\Projects\crud_delphi\Project1.dproj + 2018/08/21 09:38:54.000.903,C:\Users\programacaounico38\Documents\Projects\crud_delphi\Project1.dproj=C:\Users\programacaounico38\Documents\Projects\crud_delphi\Project1.dproj diff --git a/Project1.stat b/Project1.stat index 3f2e110..a8c20d2 100644 --- a/Project1.stat +++ b/Project1.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=55299 -DesignerSecs=6553 -InspectorSecs=2305 -CompileSecs=338405 -OtherSecs=1803 +EditorSecs=60702 +DesignerSecs=6684 +InspectorSecs=2336 +CompileSecs=360808 +OtherSecs=2143 StartTime=03/08/2018 07:57:26 RealKeys=0 EffectiveKeys=0 -DebugSecs=24770 +DebugSecs=27197 diff --git a/UnitFormCidade.pas b/UnitFormCidade.pas index 0f99fd5..c05cbe7 100644 --- a/UnitFormCidade.pas +++ b/UnitFormCidade.pas @@ -294,7 +294,7 @@ begin inherited; if wLista.Count > 0 then begin - FormGrid := TFormGrid.Create(nil); + FormGrid := TFormGrid.Create(FormCidade); FormGrid.geraGrid(wLista, TCidade); FormGrid.Show; end; diff --git a/UnitFormGrid.dfm b/UnitFormGrid.dfm index 9d2a734..3d55671 100644 --- a/UnitFormGrid.dfm +++ b/UnitFormGrid.dfm @@ -18,22 +18,16 @@ object FormGrid: TFormGrid OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 - object Label1: TLabel - Left = 48 - Top = 228 - Width = 46 - Height = 13 - Caption = 'Pesquisa:' - end object StringGrid1: TStringGrid - Left = 8 - Top = 35 + Left = 0 + Top = 59 Width = 265 Height = 184 ColCount = 4 + DrawingStyle = gdsClassic FixedCols = 0 FixedRows = 0 - Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSelect] + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goRowSelect] ParentShowHint = False ShowHint = True TabOrder = 0 @@ -46,7 +40,6 @@ object FormGrid: TFormGrid ButtonHeight = 21 Caption = 'ToolBar1' TabOrder = 1 - ExplicitWidth = 349 object btExcluir: TButton Left = 0 Top = 0 @@ -68,9 +61,9 @@ object FormGrid: TFormGrid end end object edPesquisa: TEdit - Left = 100 - Top = 225 - Width = 121 + Left = 64 + Top = 35 + Width = 70 Height = 21 TabOrder = 2 OnChange = edPesquisaChange diff --git a/UnitFormGrid.pas b/UnitFormGrid.pas index 8bb6bfd..b588cfc 100644 --- a/UnitFormGrid.pas +++ b/UnitFormGrid.pas @@ -14,14 +14,13 @@ type btExcluir: TButton; btEscolher: TButton; edPesquisa: TEdit; - Label1: TLabel; - procedure geraGrid(wLista: TLista; wClass: TClass); + procedure geraGrid(Lista: TLista; Classe: TClass); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure btExcluirClick(Sender: TObject); procedure btEscolherClick(Sender: TObject); procedure edPesquisaChange(Sender: TObject); procedure FormCreate(Sender: TObject); - procedure testeStringGrid(Lista: TLista; Classe: TClass); + procedure testeStringGrid(); private { Private declarations } palavra: string; @@ -39,25 +38,13 @@ implementation {$R *.dfm} uses UnitFormCidade; -procedure TFormGrid.testeStringGrid(Lista: TLista; Classe: TClass); -var - wCont: Integer; - wObj: TObject; +procedure TFormGrid.testeStringGrid(); begin - for wCont := 0 to Lista.Count-1 do - begin - wObj := Lista.getObjectByIndex(wCont); - if Classe = TCidade then - begin - with wObj as TCidade do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wCidade; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := wUF; - end; - end; - end; +//ShowMessage(FormGrid.StringGrid1.Cells[0,0]); + StringGrid1.Cells[0, 0] := 'a'; + StringGrid1.Cells[1, 0] := 'a'; + StringGrid1.Cells[2, 0] := 'a'; + StringGrid1.Cells[3, 0] := 'a'; end; procedure TFormGrid.btEscolherClick(Sender: TObject); @@ -83,7 +70,6 @@ var wObj: TObject; begin Index := StringGrid1.Row; - wObj := FClass.Create; try wObj := FLista.getObjectByIndex(Index); FLista.Excluir(Index); @@ -97,44 +83,63 @@ procedure TFormGrid.edPesquisaChange(Sender: TObject); var wCont: integer; wObj: TObject; - wCont2: integer; - wCheckString: string; wLista: TLista; - wObj2: TObject; - I: Integer; + linha: integer; begin palavra := edPesquisa.Text; - wLista := TLista.Create; - for wCont := 0 to FLista.Count-1 do - begin - wObj := FLista.getObjectByIndex(wCont); - if FClass = TCidade then - begin - with wObj as TCidade do - begin - if ContainsText(wCidade, palavra) then - begin - ShowMessage('Resultado containstext:'+booltostr(ContainsText(wCidade, palavra))); - wLista.Inserir(wObj, TCidade); - end; - end; - end; - end; - - ShowMessage('lista count:'+inttostr(wLista.Count)); - for I := 0 to wLista.Count-1 do - begin - wObj2 := wLista.getObjectByIndex(I); - with wObj2 as TCidade do - begin - ShowMessage(wCidade); - end; - end; - if wLista.Count > 0 then + if palavra <> '' then begin - FormGrid.testeStringGrid(wLista, TCidade); - end; + wLista := TLista.Create; + for wCont := 0 to FLista.Count-1 do + begin + wObj := FLista.getObjectByIndex(wCont); + if FClass = TCidade then + begin + with wObj as TCidade do + begin + if ContainsText(wCidade, palavra) then + begin + wLista.Inserir(wObj, TCidade); + end; + end; + end; + end; + if wLista.Count > 0 then + begin + for linha:= 1 to StringGrid1.RowCount -1 do + begin + StringGrid1.Rows[linha].Clear; //Cells[coluna,linha]:=''; + end; + StringGrid1.RowCount := wLista.Count; + for wCont := 0 to wLista.Count-1 do + begin + wObj := wLista.getObjectByIndex(wCont); + with wObj as TCidade do + begin + StringGrid1.Cells[0, wCont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wCidade; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := wUF; + end; + end; + end; + end + else + begin + StringGrid1.RowCount := Flista.Count; + for wCont := 0 to FLista.Count-1 do + begin + wObj := FLista.getObjectByIndex(wCont); + with wObj as TCidade do + begin + StringGrid1.Cells[0, wCont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wCidade; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := wUF; + end; + end; + end; end; procedure TFormGrid.FormClose(Sender: TObject; var Action: TCloseAction); @@ -147,29 +152,26 @@ begin checkList := true; end; -procedure TFormGrid.geraGrid(wLista: TLista; wClass: TClass); +procedure TFormGrid.geraGrid(Lista: TLista; Classe: TClass); var wCont: integer; wObj: TObject; begin if checkList = true then begin - FLista := wLista; - FClass := wClass; + FLista := Lista; + FClass := Classe; checkList := false; end; - wObj := wClass.Create; - ShowMessage('wLista count:'+inttostr(wLista.Count)); - //StringGrid1.RowCount := wLista.Count; - for wCont := 0 to wLista.Count-1 do + ShowMessage('wLista count:'+inttostr(Lista.Count)); + StringGrid1.RowCount := Lista.Count; + for wCont := 0 to Lista.Count-1 do begin - wObj := wLista.getObjectByIndex(wCont); + wObj := Lista.getObjectByIndex(wCont); // fazer uma condição para cada tipo de Classe existente if wObj.ClassType = TCidade then with wObj as TCidade do begin - ShowMessage('cod:'+inttostr(wCod)); - ShowMessage('testestring:'+wCidade); StringGrid1.Cells[0, wCont] := inttostr(wCod); StringGrid1.Cells[1, wCont] := wCidade; StringGrid1.Cells[2, wCont] := wPais; diff --git a/Win32/Debug/Project1.exe b/Win32/Debug/Project1.exe index 0804ee4..f4ffd49 100644 Binary files a/Win32/Debug/Project1.exe and b/Win32/Debug/Project1.exe differ diff --git a/Win32/Debug/UnitFormCidade.dcu b/Win32/Debug/UnitFormCidade.dcu index 303d174..4017d66 100644 Binary files a/Win32/Debug/UnitFormCidade.dcu and b/Win32/Debug/UnitFormCidade.dcu differ diff --git a/Win32/Debug/UnitFormEstado.dcu b/Win32/Debug/UnitFormEstado.dcu index baba8bb..aa91c39 100644 Binary files a/Win32/Debug/UnitFormEstado.dcu and b/Win32/Debug/UnitFormEstado.dcu differ diff --git a/Win32/Debug/UnitFormGrid.dcu b/Win32/Debug/UnitFormGrid.dcu index adfde00..7cdb295 100644 Binary files a/Win32/Debug/UnitFormGrid.dcu and b/Win32/Debug/UnitFormGrid.dcu differ diff --git a/Win32/Debug/UnitFormPais.dcu b/Win32/Debug/UnitFormPais.dcu index 1c1d046..4d2ebd1 100644 Binary files a/Win32/Debug/UnitFormPais.dcu and b/Win32/Debug/UnitFormPais.dcu differ