-
Notifications
You must be signed in to change notification settings - Fork 1
/
Unit1.pas
107 lines (97 loc) · 3.18 KB
/
Unit1.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
102
103
104
105
106
107
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, ADODB, ExtCtrls, Grids, DBGrids, ComCtrls,
Buttons;
type
TForm_Search = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
ADOTable1ID: TIntegerField;
ADOTable1Organ: TWideMemoField;
ADOTable1Phone: TWideStringField;
ADOTable1Fax: TWideStringField;
ADOTable1Name: TWideStringField;
ADOTable1Doljnost: TWideStringField;
ADOTable1Email: TWideStringField;
ADOTable1Site: TWideStringField;
DBMemo1: TDBMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
StatusBar1: TStatusBar;
Timer1: TTimer;
BitBtn1: TBitBtn;
Label5: TLabel;
Label6: TLabel;
procedure Edit1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_Search: TForm_Search;
implementation
{$R *.dfm}
procedure TForm_Search.Edit1Change(Sender: TObject);
{ Ïîèñê äàííûõ }
var s: string; k1,k2: integer;
begin
try // âêëþ÷åíèå çàùèòû îò ñáîåâ
k1:=0; adotable1.Filtered:=false; // Âûêëþ÷åíèå ôèëüòðàöèè
s:=''; k1:=adotable1.RecordCount; // Óçíàåì êîëè÷åñòâî çàïèñåé
{ ÑÎÇÄÀÅÌ ÔÈËÜÒÐ ÑËÎÆÍÎÃÎ ÏÎÈÑÊÀ }
if trim(edit1.Text)<>'' then s:=s+' and (organ like '''+trim(edit1.Text)+'%'')';
if trim(edit2.Text)<>'' then s:=s+' and (name like '''+trim(edit2.Text)+'%'')';
if trim(edit3.Text)<>'' then s:=s+' and (phone like '''+trim(edit3.Text)+'%'')';
if trim(edit4.Text)<>'' then s:=s+' and (fax like '''+trim(edit4.Text)+'%'')';
delete(s,1,5); adotable1.Filter:=s;
{ ------------------------------ }
adotable1.Filtered:=true; // Àêòèâèçèðóåì ôèëüòð
k2:=adotable1.RecordCount; // Óçíàåì êîëè÷åñòâî çàïèñåé â ôèëüòðå
except // Àêòèâèçàöèÿ çàùèòû è îòêàòà ïîèñêà
adotable1.Filtered:=false; beep; k2:=k1; // Îòêàò ôèëüòðà, èçäàåì çâóê
// Âûäàåì ïîëüçîâàòåëþ ñîîáùåíèå îá îøèáêå
messagedlg('Îøèáêà ïîèñêà äàííûõ! Ôèëüòð íå âêëþ÷åí.',mtError, [mbOK],0);
end;
{ Ñòàòóñíàÿ ñòðîêà, ïàíåëè 0 è 1 }
StatusBar1.Panels[0].Text:='Âñåãî çàïèñåé: '+inttostr(k1);
StatusBar1.Panels[1].Text:='Îòîáðàíî çàïèñåé: '+inttostr(k2);
end;
procedure TForm_Search.Timer1Timer(Sender: TObject);
{ Ñòàòóñíàÿ ñòðîêà, ïàíåëè 2 è 3 }
var s: string; i: integer;
begin
try
i:=ADOTable1.recno; // Ñ÷èòûâàåì íîìåð òåêóùåé çàïèñè
if i>0 then s:='Òåêóùàÿ çàïèñü: '+inttostr(i) else abort;
StatusBar1.Panels[2].Text:=s;
except
StatusBar1.Panels[2].Text:='Äàííûå íå îòîáðàæàþòñÿ';
end;
try
// Âûäàåì â ñòàòóñíóþ ñòðîêó äàòó è âðåìÿ
StatusBar1.Panels[3].Text:=datetimetostr(now);
except
StatusBar1.Panels[3].Text:='';
end;
end;
procedure TForm_Search.BitBtn1Click(Sender: TObject);
{ Çàêðûòèå îêíà }
begin
close;
end;
end.