📄 unit3.pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB;
type
TForm3 = class(TForm)
GroupBox1: TGroupBox;
ComboBox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
ComboBox2: TComboBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit1: TEdit;
ComboBox3: TComboBox;
Edit2: TEdit;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
ComboBox6: TComboBox;
Edit3: TEdit;
GroupBox2: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
DBGrid1: TDBGrid;
Button4: TButton;
q: TADOQuery;
s1: TDataSource;
t2: TADOTable;
t1: TADOTable;
ADOConnection1: TADOConnection;
s2: TDataSource;
procedure Button3Click(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button3Click(Sender: TObject);
begin
form3.Close;
end;
procedure TForm3.ComboBox1Select(Sender: TObject);
var
c:string;
begin
t2.Locate('name',trim(combobox1.Text),[]);
c:=t2.fieldvalues['code'];
q.Close;
q.SQL.Clear;
q.SQL.Add('select distinct name from xyzy where len(code)>4 and left(code,4)like '''+c+''' order by name');
q.Open;
combobox2.Items.Clear;
with q do
begin
repeat
combobox2.Items.Add(FieldValues['name']);
next;
until eof;
end;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
q.Close;
q.SQL.Clear;
q.SQL.Add('select distinct name from xyzy where len(code)=4 order by name');
q.Open;
combobox1.Items.Clear;
with q do
begin
repeat
combobox1.Items.Add(FieldValues['name']);
next;
until eof;
end;
end;
procedure TForm3.Button4Click(Sender: TObject);
var
sqlstr:string;
begin
sqlstr:='select * from jbxx where (1=1)';
if combobox1.Text <>'' then
sqlstr:=sqlstr+'and (xymc='''+combobox1.text+''')' ;
if combobox2.Text <>'' then
sqlstr:=sqlstr+'and (zymc='''+combobox2.text+''')' ;
if edit1.Text <>'' then
sqlstr:=sqlstr+'and (xm='''+edit1.text+''')';
if edit3.text<>'' then
sqlstr:=sqlstr+'and (xh='''+edit3.text+''')';
if combobox3.Text<>'' then
sqlstr:=sqlstr+'and (xb='''+combobox3.text+''')' ;
// if combobox2.Text <>'' then
// sqlstr:=sqlstr+'and (党团员='''+combobox2.text+''')' ;
if edit2.text<>'' then
sqlstr:=sqlstr+'and (csrq='''+edit2.text+''')';
if combobox4.Text <>'' then
sqlstr:=sqlstr+'and (sznj='''+combobox4.text+''')' ;
if combobox5.Text <>'' then
sqlstr:=sqlstr+'and (zzmm='''+combobox5.text+''')' ;
if combobox6.Text <>'' then
sqlstr:=sqlstr+'and (mz='''+combobox6.text+''')' ;
q.Close ;
q.SQL.Clear ;
q.SQL.Add(sqlstr);
q.Open ;
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
combobox1.Text:='';
combobox2.Text:='';
combobox3.Text:='';
combobox4.Text:='';
combobox5.Text:='';
combobox6.Text:='';
q.Active:=false;
q.Active:=true;
// statusbar1.Panels[0].Text:='总共找到 '+inttostr(dm.ADOQuery1.RecordCount)+' 条记录';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -