finalized 'search by name' function

This commit is contained in:
rickarof 2018-08-21 14:51:10 -03:00
parent 79d111221f
commit e4aa38a98b
10 changed files with 97 additions and 102 deletions

View File

@ -2,34 +2,34 @@
<BorlandProject>
<Transactions>
<Transaction>2018/08/02 11:30:33.000.203,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/02 11:34:57.000.485,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_Cadastro_Forms\UnitLista.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/02 11:35:39.000.518,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/02 11:50:57.000.642,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/03 07:57:41.000.908,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/03 09:19:04.000.339,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/06 10:32:04.000.123,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>2018/08/08 10:01:00.000.149,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitSharedVariables.pas</Transaction>
<Transaction>2018/08/08 10:50:02.000.574,C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\UnitSharedVariables.pas=</Transaction>
<Transaction>2018/08/08 10:52:58.000.982,=C:\Users\programacaounico38\Documents\Embarcadero\Studio\Projects\Ex_CRUD\Unit1.pas</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
@ -38,7 +38,7 @@
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
<Transaction>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</Transaction>
</Transactions>
<ProjectSortOrder AutoSort="0" SortType="0">
<File Path="UnitFormSplash.pas"/>

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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,13 +83,12 @@ 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;
if palavra <> '' then
begin
wLista := TLista.Create;
for wCont := 0 to FLista.Count-1 do
begin
@ -114,27 +99,47 @@ begin
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
begin
FormGrid.testeStringGrid(wLista, TCidade);
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;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.