cccx.~pas
来自「应对服装行业的生产成本控制系统」· ~PAS 代码 · 共 604 行
~PAS
604 行
unit cccx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, Grids, DBGrids, ExtCtrls, DBCtrls,
DB, ADODB, DBClient;
type
TFrmcccx = class(TForm)
Pz: TPanel;
help: TLabel;
Label7: TLabel;
Pd: TPanel;
pq: TPanel;
cddh: TCheckBox;
qddh: TEdit;
cxh: TCheckBox;
qxh: TEdit;
cys: TCheckBox;
qys: TEdit;
csl: TCheckBox;
qsl: TEdit;
cms: TCheckBox;
qms: TEdit;
Cqq: TCheckBox;
Czq: TCheckBox;
zq: TDateTimePicker;
qq: TDateTimePicker;
GroupBox1: TGroupBox;
DBGrid5: TDBGrid;
OpenDialog1: TOpenDialog;
bprint: TBitBtn;
breturn: TBitBtn;
Bquery: TBitBtn;
bprintc: TBitBtn;
Bcchz: TBitBtn;
Bddhz: TBitBtn;
procedure bprintClick(Sender: TObject);
procedure breturnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BqueryClick(Sender: TObject);
procedure DBGrid5TitleClick(Column: TColumn);
procedure bprintcClick(Sender: TObject);
procedure BcchzClick(Sender: TObject);
procedure BddhzClick(Sender: TObject);
procedure DBGrid5KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
rzczy,rzsj,rzjsj,rzcsj:string;
errzt: integer;
errcode:boolean;
commandstring,commandstringq: string;
function hz():boolean;
public
{ Public declarations }
end;
var
Frmcccx: TFrmcccx;
implementation
uses unit28, Unit1, Unit16, func;
{$R *.dfm}
procedure TFrmcccx.bprintClick(Sender: TObject);
begin
help.Caption:=' 暂不提供打印功能!';
end;
procedure TFrmcccx.breturnClick(Sender: TObject);
begin
try
if DataModule1.clientdataset22.Active then DataModule1.ClientDataSet22.Active:=false;
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;
procedure TFrmcccx.FormActivate(Sender: TObject);
begin
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='裁床信息审核';
qq.DateTime:=date-30;
zq.DateTime:=date;
help.Caption:='';
help.Caption:=' 请您点击< 查询>按钮开始查询裁床信息记录!';
end;
procedure TFrmcccx.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
if DataModule1.clientdataset22.Active then DataModule1.ClientDataSet22.Active:=false;
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;
procedure TFrmcccx.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ccb';
commandtring1:='select * from dbo.ccb';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qxh.Text)<>'') and (cxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end;
end
else
begin
qxh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end;
end;
if czq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end;
end
else
begin
qys.Text:='';
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qms.Text)<>'') and (cms.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end;
end
else
begin
qms.Text:='';
end;
commandstring:=commandstring+' order by ddh,xh';
commandstringq:=commandstring;
DataModule1.ClientDataSet22.DisableControls;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstring;
DataModule1.ClientDataSet22.Open;
hz;
DataModule1.ClientDataSet22.EnableControls;
help.Caption:=' 查询完毕!';
except
DataModule1.clientdataset22.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmcccx.DBGrid5TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid5.Columns.Count do
begin
//恢复所有标题字体为默认
DBGrid5.Columns[i-1].Title.Font.Color := clBlue;
DBGrid5.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet22.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet22.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmcccx.bprintcClick(Sender: TObject);
var
excelname: string;
begin
if not DataModule1.ClientDataSet22.Active then exit;
if not form1.excel then
begin
showmessage('您还未获得管理员的授权!请您与管理员联系获取授权!');
exit;
end;
if DataModule1.ClientDataSet22.RecordCount<1 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet22,excelname,'裁床信息报表');
exit;
end;
procedure TFrmcccx.BcchzClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select cc,ddh,ys,sum(sl) as sl,ms from dbo.ccb';
commandtring1:=commandstring;
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qxh.Text)<>'') and (cxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end;
end
else
begin
qxh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end;
end;
if czq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end;
end
else
begin
qys.Text:='';
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qms.Text)<>'') and (cms.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end;
end
else
begin
qms.Text:='';
end;
commandstring:=commandstring+' group by cc,ddh,ys,ms';
commandstring:=commandstring+' order by cc,ddh,ys,ms';
commandstringq:=commandstring;
DataModule1.ClientDataSet22.DisableControls;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstring;
DataModule1.ClientDataSet22.Open;
hz;
DataModule1.ClientDataSet22.EnableControls;
help.Caption:=' 裁床汇总完毕!';
except
DataModule1.clientdataset22.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmcccx.BddhzClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select ddh,ys,sum(sl) as sl,ms from dbo.ccb';
commandtring1:=commandstring;
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qxh.Text)<>'') and (cxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end;
end
else
begin
qxh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end;
end;
if czq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end;
end
else
begin
qys.Text:='';
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qms.Text)<>'') and (cms.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end;
end
else
begin
qms.Text:='';
end;
commandstring:=commandstring+' group by ddh,ys,ms';
commandstring:=commandstring+' order by ddh,ys,ms';
commandstringq:=commandstring;
DataModule1.ClientDataSet22.DisableControls;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstring;
DataModule1.ClientDataSet22.Open;
hz;
DataModule1.ClientDataSet22.EnableControls;
help.Caption:=' 订单汇总完毕!';
except
DataModule1.clientdataset22.EnableControls;
showmessage('数据库没有打开!');
end;
end;
function TFrmcccx.hz:boolean;
var
sl: String;
i: integer;
begin
sl:='0';
if not DataModule1.ClientDataSet22.RecordCount>0 then exit;
DataModule1.ClientDataSet22.First;
for i := 1 to DataModule1.ClientDataSet22.RecordCount do
begin
if DataModule1.ClientDataSet22.FieldByName('sl').AsString<>'' then sl:= formatfloat('0',strtofloat(sl)+DataModule1.ClientDataSet22.FieldByName('sl').AsFloat);
DataModule1.ClientDataSet22.Next;
end;
DataModule1.ClientDataSet22.First;
help.Caption:=' 合计数量为'+sl;
end;
procedure TFrmcccx.DBGrid5KeyPress(Sender: TObject; var Key: Char);
var
sl: String;
i: integer;
begin
sl:='0';
if key=#13 then
begin
for i := 0 to (DBGrid5.SelectedRows.Count - 1) do
begin
DBGrid5.DataSource.DataSet.GotoBookmark(pointer(DBGrid5.SelectedRows.Items[i]));
if DBGrid5.DataSource.DataSet.FieldByName('sl').AsString<>'' then sl:= formatfloat('0',strtofloat(sl)+DBGrid5.DataSource.DataSet.FieldByName('sl').AsFloat);
end;
help.Caption:=' 合计数量为'+sl;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?