ddcx.~pas
来自「应对服装行业的生产成本控制系统」· ~PAS 代码 · 共 441 行
~PAS
441 行
unit ddcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, Grids, DBGrids, ExtCtrls, DBCtrls,
DB, ADODB, DBClient;
type
TFrmddcx = class(TForm)
Pz: TPanel;
help: TLabel;
GroupBox4: TGroupBox;
DBGrid2: TDBGrid;
Label7: TLabel;
DBGrid1: TDBGrid;
Pd: TPanel;
pq: TPanel;
csq: TCheckBox;
cddh: TCheckBox;
qddh: TEdit;
cjglx: TCheckBox;
csz: TCheckBox;
sz: TDateTimePicker;
qjglx: TEdit;
ckhmc: TCheckBox;
qkhmc: TEdit;
ccpmc: TCheckBox;
qcpmc: TEdit;
csl: TCheckBox;
ccpfl: TCheckBox;
qsl: TEdit;
qcpfl: TEdit;
ccpdw: TCheckBox;
cdj: TCheckBox;
qcpdw: TEdit;
qdj: TEdit;
sq: TDateTimePicker;
cwgzt: TCheckBox;
cje: TCheckBox;
qwgzt: TEdit;
qje: TEdit;
Cjq: TCheckBox;
Cjz: TCheckBox;
jz: TDateTimePicker;
jq: TDateTimePicker;
bprint: TBitBtn;
breturn: TBitBtn;
Bquery: TBitBtn;
bprintc: TBitBtn;
OpenDialog1: TOpenDialog;
procedure bprintClick(Sender: TObject);
procedure breturnClick(Sender: TObject);
procedure DBGrid1TitleClick(Column: TColumn);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure BqueryClick(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure bprintcClick(Sender: TObject);
private
{ Private declarations }
rzczy,rzsj,rzjsj,rzcsj:string;
errzt: integer;
errcode:boolean;
commandstring,commandstringq: string;
public
{ Public declarations }
end;
var
Frmddcx: TFrmddcx;
implementation
uses unit28, Unit1, Unit16, func;
{$R *.dfm}
procedure TFrmddcx.bprintClick(Sender: TObject);
begin
help.Caption:=' 暂不提供打印功能!';
end;
procedure TFrmddcx.breturnClick(Sender: TObject);
begin
try
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
DataModule1.ClientDataSet17.IndexFieldNames:='';
if DataModule1.clientdataset17.Active then DataModule1.ClientDataSet17.Active:=false;
if DataModule1.clientdataset18.Active then DataModule1.ClientDataSet18.Active:=false;
except
showmessage('数据库没有打开!');
end;
close;
end;
procedure TFrmddcx.DBGrid1TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid1.Columns.Count do
begin
//恢复所有标题字体为默认
DBGrid1.Columns[i-1].Title.Font.Color := clBlue;
DBGrid1.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet17.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet17.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmddcx.FormActivate(Sender: TObject);
begin
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='订单查询';
sq.DateTime:=date-30;
sz.DateTime:=date;
jq.DateTime:=date;
jz.DateTime:=date+30;
help.Caption:='';
help.Caption:=' 请您查询所需的数据!';
end;
procedure TFrmddcx.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
DataModule1.ClientDataSet17.IndexFieldNames:='';
if DataModule1.clientdataset17.Active then DataModule1.ClientDataSet17.Active:=false;
if DataModule1.clientdataset18.Active then DataModule1.ClientDataSet18.Active:=false;
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;
procedure TFrmddcx.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if DataModule1.ClientDataSet17.FieldByName('shbj').AsInteger=1 then
begin
dbgrid1.Canvas.Font.Color:=clred;
dbgrid1.Canvas.Brush.Color:=clyellow;
end
else
begin
dbgrid1.Canvas.Font.Color:=clblue;
dbgrid1.Canvas.Brush.Color:=clwhite;
end;
dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
if ((State = [gdSelected]) or (State = [gdSelected, gdFocused])) then
begin
DBGrid1.Canvas.Brush.Color:=clred;
DBGrid1.Canvas.Font.Color:=clWhite;
DBGrid1.DefaultDrawColumnCell(Rect, datacol,column, State);
end;
end;
procedure TFrmddcx.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ddb';
commandtring1:='select * from dbo.ddb';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qjglx.Text)<>'') and (cjglx.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end;
end
else
begin
qjglx.Text:='';
end;
if (trim(qkhmc.Text)<>'') and (ckhmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
end;
end
else
begin
qkhmc.Text:='';
end;
if (trim(qcpmc.Text)<>'') and (ccpmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
end;
end
else
begin
qcpmc.Text:='';
end;
if (trim(qcpfl.Text)<>'') and (ccpfl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
end;
end
else
begin
qcpfl.Text:='';
end;
if (trim(qcpdw.Text)<>'') and (ccpdw.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
end;
end
else
begin
qcpdw.Text:='';
end;
if csq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end;
end;
if csz.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end;
end;
if cjq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end;
end;
if cjz.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end;
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qdj.Text)<>'') and (cdj.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end;
end
else
begin
qdj.Text:='';
end;
if (trim(qje.Text)<>'') and (cje.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
commandstring:=commandstring+' order by ddh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet17.DisableControls;
DataModule1.ClientDataSet17.Close;
DataModule1.ClientDataSet17.CommandText:=commandstring;
DataModule1.ClientDataSet17.Open;
DataModule1.ClientDataSet17.EnableControls;
except
DataModule1.clientdataset17.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmddcx.DBGrid1DblClick(Sender: TObject);
var
relation:string;
begin
relation:=' = ''';
try
if DataModule1.ClientDataSet17.Active then
begin
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
commandstring:='select * from dbo.ddmxb where (dbo.ddmxb.ddh'+relation+DataModule1.ClientDataSet17.FieldByName('ddh').AsString+''' )'+' order by xh';
DataModule1.ClientDataSet18.Close;
DataModule1.ClientDataSet18.CommandText:=commandstring;
DataModule1.ClientDataSet18.Open;
end;
except
showmessage('表格中数据出现了错误!')
end;
end;
procedure TFrmddcx.bprintcClick(Sender: TObject);
var
excelname: string;
begin
if not DataModule1.ClientDataSet17.Active then exit;
if not form1.excel then
begin
showmessage('您还未获得管理员的授权!请您与管理员联系获取授权!');
exit;
end;
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet17,excelname,'订单信息报表');
exit;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?