📄 unit_dgcx.pas
字号:
unit Unit_dgcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, ComCtrls;
type
Tdgcx = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Label4: TLabel;
GroupBox2: TGroupBox;
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
LabeledEdit3: TLabeledEdit;
LabeledEdit4: TLabeledEdit;
LabeledEdit5: TLabeledEdit;
LabeledEdit6: TLabeledEdit;
LabeledEdit7: TLabeledEdit;
LabeledEdit8: TLabeledEdit;
LabeledEdit9: TLabeledEdit;
LabeledEdit10: TLabeledEdit;
LabeledEdit11: TLabeledEdit;
LabeledEdit12: TLabeledEdit;
LabeledEdit13: TLabeledEdit;
LabeledEdit14: TLabeledEdit;
LabeledEdit15: TLabeledEdit;
LabeledEdit16: TLabeledEdit;
LabeledEdit17: TLabeledEdit;
Button2: TButton;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure ComboBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
dgcx: Tdgcx;
implementation
{$R *.dfm}
procedure Tdgcx.Button2Click(Sender: TObject);
begin
if messagedlg('你确定要关闭窗口吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
close
else
exit;
end;
procedure Tdgcx.Button1Click(Sender: TObject);
var sql:string;
com:string;
time1,time2:string ;
begin
time1:=datetostr(datetimepicker1.date);
time2:=datetostr(datetimepicker2.date);
com:='select * from dinggou where (data>='''+trim(time1)+''')and(data<='''+trim(time2)+''')';
if trim(combobox1.text)<>'' then
com:=com+'and(statue='''+trim(edit1.text)+''')';
if trim(combobox2.text)<>'' then
com:=com+'and(cname like ''%'+trim(combobox2.Text)+'%'')';
sql:=com;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end;
{
begin
if trim(combobox1.text)='' then
begin
if trim(combobox2.text)='' then
begin
time1:=datetostr(datetimepicker1.date);
time2:=datetostr(datetimepicker2.date);
com:='select * from dinggou where (data>='''+trim(time1)+''')and(data<='''+trim(time2)+''')';
end
else
begin
com:='select * from dinggou where (data>='''+trim(time1)+''')and(data<='''+trim(time2)+''')';
com:=com+'and(cname like ''%'+trim(combobox2.Text)+'%'')';
end;
sql:=com;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin /////
time1:=datetostr(datetimepicker1.date);
time2:=datetostr(datetimepicker2.date);
com:='select * from dinggou,zhuangtai where (dinggou.statue=zhuangtai.statue)and(yiyi='''+trim(combobox1.Text)+''')';
if trim(combobox2.text)<>'' then ///==xiao cha xun
begin
com:=com+'and(cname like ''%'+trim(combobox2.Text)+'%'')';
com:=com+'and(data>='''+trim(time1)+''')and(data<='''+trim(time2)+''')';
end
else
begin
com:=com+'and(data>='''+trim(time1)+''')and(data<='''+trim(time2)+''')';
end;
sql:=com;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
if adoquery1.RecordCount=0 then
showmessage('暂无你查找的记录,请重新输入!!!')
else
exit;
end;
end;
}
{
///客户姓名查询
begin
if trim(combobox3.Text)='' then
begin
sql:='select * from dinggou';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin
sql:='select * from dinggou where (cname like ''%'+trim(combobox3.Text)+'%'')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end;
end;
///客户姓名查询
}
{
///客户状态查询
begin
if trim(combobox4.Text)='' then
begin
sql:='select * from dinggou';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin
sql:='select * from dinggou,zhuangtai where(dinggou.statue=zhuangtai.statue)and(yiyi='''+trim(combobox4.Text)+''')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
if adoquery1.RecordCount=0 then
showmessage('暂无你查找的记录,请重新输入!!!');
end;
end;
///房屋状态查询
}
{///房屋编号查询
begin
if trim(combobox1.Text)='' then
begin
sql:='select * from dinggou';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin
sql:='select * from dinggou where (hno='''+trim(combobox1.Text)+''')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end;
end;
} ///房屋编号查询
{
///客户编号查询
begin
if trim(combobox2.Text)='' then
begin
sql:='select * from dinggou';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin
sql:='select * from dinggou where (cno='''+trim(combobox2.Text)+''')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end;
end;
} ///客户号查
{
///客户姓名查询
begin
if trim(combobox3.Text)='' then
begin
sql:='select * from dinggou';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end
else
begin
sql:='select * from dinggou where (cname like ''%'+trim(combobox3.Text)+'%'')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add(sql);
adoquery1.Open;
end;
end;
///客户姓名查询
}
procedure Tdgcx.DBGrid1CellClick(Column: TColumn);
begin
labelededit1.text:=adoquery1.Fields[0].AsString;
labelededit2.text:=adoquery1.Fields[1].AsString;
labelededit3.text:=adoquery1.Fields[2].AsString;
labelededit4.text:=adoquery1.Fields[3].AsString;
labelededit5.text:=adoquery1.Fields[4].AsString;
labelededit6.text:=adoquery1.Fields[5].AsString;
labelededit7.text:=adoquery1.Fields[6].AsString;
labelededit8.text:=adoquery1.Fields[7].AsString;
labelededit9.text:=adoquery1.Fields[8].AsString;
labelededit10.text:=adoquery1.Fields[9].AsString;
labelededit11.text:=adoquery1.Fields[10].AsString;
labelededit12.text:=adoquery1.Fields[11].AsString;
labelededit13.text:=adoquery1.Fields[12].AsString;
labelededit14.text:=adoquery1.Fields[13].AsString;
labelededit15.text:=adoquery1.Fields[14].AsString;
labelededit16.text:=adoquery1.Fields[15].AsString;
labelededit17.text:=adoquery1.Fields[16].AsString;
end;
procedure Tdgcx.ComboBox1Click(Sender: TObject);
begin
if trim(combobox1.text)='已订购' then
edit1.text:='1'
else if trim(combobox1.text)='已销售' then
edit1.text:='2';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -