📄 ghscx.~pas
字号:
unit ghscx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
Tfrmghscx = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
groupbox1: TGroupBox;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmghscx: Tfrmghscx;
implementation
uses data1, csda;
{$R *.dfm}
procedure Tfrmghscx.BitBtn1Click(Sender: TObject);
var sq1,strwhere,strorder:string;
flag:boolean;
i:integer;
begin
flag:=false;
sq1:='select * from csda ';
strwhere:='where';
strorder:='order by csbh';
if (edit1.text='') and (edit2.text='') and (edit3.text='') and
(edit4.text='') and (edit5.text='') and (edit6.text='' )
then
strwhere:=''
else
begin
if not flag then
begin
if edit1.Text<>'' then
begin
strwhere:=strwhere+' csbh='+QuotedStr(trim(edit1.Text));
flag:=true;
end;
end;
if edit2.Text<>'' then
begin
if not flag then
begin
strwhere:=strwhere+' csmc like '+quotedstr('%'+edit2.text+'%' );
flag:=true;
end;
strwhere:=strwhere+' and dsmc like '+quotedstr('%'+edit2.text+'%' );
end;
if edit3.Text<>'' then
begin
if not flag then
begin
strwhere:=strwhere+' lxr like '+quotedstr('%'+edit3.text+'%' );
flag:=true;
end;
strwhere:=strwhere+' and lxr like '+quotedstr('%'+edit3.text+'%' );
end;
if edit4.Text<>'' then
begin
if not flag then
begin
strwhere:=strwhere+' phone like '+quotedstr('%'+edit4.text+'%' );
flag:=true;
end;
strwhere:=strwhere+' and phone like '+quotedstr('%'+edit4.text+'%' );
end;
if edit5.Text<>'' then
begin
if not flag then
begin
strwhere:=strwhere+' dz like '+quotedstr('%'+edit5.text+'%' );
flag:=true;
end;
strwhere:=strwhere+'and dz like '+quotedstr('%'+edit5.text+'%' );
end;
end;
sq1:=sq1+strwhere+strorder;
screen.Cursor:=crHourGlass;
with database do
begin
ado1.Connection:=adoc1;
ado1.close;
ado1.SQL.Clear;
ado1.SQL.Add(sq1);
ado1.Open;
if ado1.Recordset.RecordCount=0 then
begin
frm_csda.StatusBar1.Panels[1].Text:=inttostr(ado1.Recordset.RecordCount);
screen.Cursor:=crDefault;
showmessage('没有符合条件的纪录');
exit;
end;
frm_csda.stringgrid1.RowCount:=ado1.Recordset.RecordCount+1;
frm_csda.StatusBar1.Panels[1].Text:=inttostr(ado1.Recordset.RecordCount);
while not ado1.Eof do
begin
for i:=1 to frm_csda.stringgrid1.RowCount do
begin
frm_csda.stringgrid1.Cells[1,i]:=ado1.Fields.fieldbyname('csbh').Value;
frm_csda.stringgrid1.Cells[2,i]:=ado1.Fields.fieldbyname('csmc').Value;
frm_csda.stringgrid1.Cells[3,i]:=ado1.Fields.fieldbyname('lxr').Value;
frm_csda.stringgrid1.Cells[4,i]:=ado1.Fields.fieldbyname('phone').Value;
frm_csda.stringgrid1.Cells[5,i]:=ado1.Fields.fieldbyname('dz').Value;
frm_csda.stringgrid1.Cells[6,i]:=ado1.Fields.fieldbyname('fax').Value;
frm_csda.stringgrid1.Cells[7,i]:=ado1.Fields.fieldbyname('email').Value;
frm_csda.stringgrid1.Cells[8,i]:=ado1.Fields.fieldbyname('http').Value;
frm_csda.stringgrid1.Cells[9,i]:=ado1.Fields.fieldbyname('sfz').Value;
ado1.Next;
end;
end;
screen.Cursor:=crDefault;
ado1.Close;
end;
end;
procedure Tfrmghscx.FormCreate(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
end;
procedure Tfrmghscx.BitBtn2Click(Sender: TObject);
begin
frmghscx.Close;
end;
procedure Tfrmghscx.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -