-
Notifications
You must be signed in to change notification settings - Fork 0
/
ULVendedor.pas
101 lines (86 loc) · 2.29 KB
/
ULVendedor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit ULVendedor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ULGenerico, FMTBcd, DB, SqlExpr, Provider, DBClient, StdCtrls, Grids,
DBGrids, Buttons, PngBitBtn, ExtCtrls;
type
TfrmLVendedor = class(TfrmLGenerico)
cdsTabCOD_VEND: TIntegerField;
cdsTabDAT_CAD: TDateField;
cdsTabNOME: TStringField;
cdsTabAPELIDO: TStringField;
cdsTabCPF_CNPJ: TStringField;
cdsTabRG_IE: TStringField;
cdsTabENDERECO: TStringField;
cdsTabBAIRRO: TStringField;
cdsTabCIDADE: TStringField;
cdsTabUF: TStringField;
cdsTabCEP: TStringField;
cdsTabTELEFONE: TStringField;
txtLocalizar: TEdit;
Label1: TLabel;
txtCampo: TComboBox;
Label2: TLabel;
procedure MontaSQL;
procedure AbreVendedor;
procedure btConsultarClick(Sender: TObject);
procedure grdDadosDblClick(Sender: TObject);
procedure btEditarClick(Sender: TObject);
procedure grdDadosKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmLVendedor: TfrmLVendedor;
implementation
uses UFuncoes, UVendedor;
{$R *.dfm}
{ TfrmLGenerico1 }
procedure TfrmLVendedor.AbreVendedor;
begin
application.CreateForm(TfrmVendedor, frmVendedor);
frmVendedor.AbreTabela('COD_VEND', cdsTabCOD_VEND.AsInteger);
frmVendedor.ShowModal;
cdsTab.Refresh;
end;
procedure TfrmLVendedor.btConsultarClick(Sender: TObject);
begin
MontaSQL;
inherited;
end;
procedure TfrmLVendedor.btEditarClick(Sender: TObject);
begin
inherited;
AbreVendedor;
end;
procedure TfrmLVendedor.grdDadosDblClick(Sender: TObject);
begin
inherited;
btEditarClick(sender);
end;
procedure TfrmLVendedor.grdDadosKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if key = 13 then
btEditarClick(sender);
end;
procedure TfrmLVendedor.MontaSQL;
begin
sql := 'SELECT * FROM VENDEDOR';
if not Vazio(txtLocalizar.Text) then begin
case txtCampo.ItemIndex of
0: sql := sql + ' WHERE COD_VEND = '+QuotedStr(txtLocalizar.Text);
1: sql := sql + ' WHERE NOME LIKE '+QuotedStr('%'+txtLocalizar.Text+'%');
end;
end;
case txtCampo.ItemIndex of
0: sql := sql + ' ORDER BY COD_VEND';
1: sql := sql + ' ORDER BY NOME';
end;
end;
end.