📄 lldcx.~pas
字号:
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.ClientDataSet20.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet20.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmlldcx.bprintcClick(Sender: TObject);
var
excelname: string;
begin
if not DataModule1.ClientDataSet20.Active then exit;
if not form1.excel then
begin
showmessage('您还未获得管理员的授权!请您与管理员联系获取授权!');
exit;
end;
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet20,excelname,'生产领料信息报表');
exit;
end;
procedure TFrmlldcx.BddhzClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select ddh,clmc,clfl,dw,ggxh,ys,sum(sl) as sl,dj,sum(je) as je from dbo.llb';
commandtring1:=commandstring;
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qlldh.Text)<>'') and (clldh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end;
end
else
begin
qlldh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.llb.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.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qclfl.Text)<>'') and (cclfl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end;
end
else
begin
qclfl.Text:='';
end;
if (trim(qclmc.Text)<>'') and (cclmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end;
end
else
begin
qclmc.Text:='';
end;
if (trim(qcldw.Text)<>'') and (ccldw.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';
end;
end
else
begin
qcldw.Text:='';
end;
if (trim(qggxh.Text)<>'') and (cggxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.ggxh'+relation+cx+trim(qggxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ggxh'+relation+cx+trim(qggxh.Text)+cx+''')';
end;
end
else
begin
qggxh.Text:='';
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.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.llb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.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.llb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.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.llb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
if (trim(qfb.Text)<>'') and (cfb.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end;
end
else
begin
qfb.Text:='';
end;
if (trim(qfz.Text)<>'') and (cfz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end;
end
else
begin
qfz.Text:='';
end;
if (trim(qllr.Text)<>'') and (cllr.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end;
end
else
begin
qllr.Text:='';
end;
if (trim(qflr.Text)<>'') and (cflr.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end;
end
else
begin
qflr.Text:='';
end;
if (trim(qzgr.Text)<>'') and (czgr.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.zgr'+relation+cx+trim(qzgr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.zgr'+relation+cx+trim(qzgr.Text)+cx+''')';
end;
end
else
begin
qzgr.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if commandstring=commandtring1 then
begin
relation:=' = ''';
cx:='';
commandstring:=commandstring+' where (dbo.llb.shbj'+relation+cx+'0'+cx+''')';
end
else
begin
relation:=' = ''';
cx:='';
commandstring:=commandstring+' and (dbo.llb.shbj'+relation+cx+'0'+cx+''')';
end;
commandstring:=commandstring+' group by ddh,clmc,clfl,dw,ggxh,ys,dj ';
commandstring:=commandstring+' order by ddh,clfl,clmc,ys,ggxh ';
commandstringq:=commandstring;
DataModule1.ClientDataSet20.DisableControls;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstring;
DataModule1.ClientDataSet20.Open;
hz;
DataModule1.ClientDataSet20.EnableControls;
help.Caption:=' 查询完毕!';
pz.Enabled:=true;
except
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmlldcx.BfbhzClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select fb,clmc,clfl,dw,ggxh,ys,sum(sl) as sl,dj,sum(je) as je from dbo.llb';
commandtring1:=commandstring;
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qlldh.Text)<>'') and (clldh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end;
end
else
begin
qlldh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.llb.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.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qclfl.Text)<>'') and (cclfl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end;
end
else
begin
qclfl.Text:='';
end;
if (trim(qclmc.Text)<>'') and (cclmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end;
end
else
begin
qclmc.Text:='';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -