lldsh.pas

来自「应对服装行业的生产成本控制系统」· PAS 代码 · 共 934 行 · 第 1/2 页

PAS
934
字号
pz.Enabled:=true;
except
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmlldsh.bshClick(Sender: TObject);
var
lldh,relation,cx,dx,sqlstr:string;
  begin
if not DataModule1.ClientDataSet20.Active then exit;
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
 relation:=' = ''';
 cx:='';
 dx:= ' ''';
try
lldh:=DataModule1.ClientDataSet20.FieldByName('lldh').AsString;
DataModule1.ClientDataSet20.Edit;
if DataModule1.ClientDataSet20.FieldByName('shbj').AsInteger=0 then
  begin
sqlstr:='update dbo.llb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (lldh' +relation+cx+lldh+cx+''')';
DataModule1.ClientDataSet20.CommandText:=sqlstr;
DataModule1.ClientDataSet20.Execute;
DataModule1.ClientDataSet20.ApplyUpdates(-1);
DataModule1.ClientDataSet20.DisableControls;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstringq;
DataModule1.ClientDataSet20.Open;
DataModule1.ClientDataSet20.EnableControls;
 help.Caption:= '数据审核成功!';
 end;
 except
 DataModule1.clientdataset20.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
end;

procedure TFrmlldsh.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.ClientDataSet20.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet20.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;

procedure TFrmlldsh.DBGrid5DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
 if DataModule1.ClientDataSet20.FieldByName('shbj').AsInteger=1 then
begin
dbgrid5.Canvas.Font.Color:=clred;
dbgrid5.Canvas.Brush.Color:=clyellow;
end
else
begin
dbgrid5.Canvas.Font.Color:=clblue;
dbgrid5.Canvas.Brush.Color:=clwhite;
end;
dbgrid5.DefaultDrawColumnCell(rect,datacol,column,state);
if   ((State = [gdSelected])   or   (State   =   [gdSelected,   gdFocused]))   then
   begin
DBGrid5.Canvas.Brush.Color:=clred;
DBGrid5.Canvas.Font.Color:=clWhite;
DBGrid5.DefaultDrawColumnCell(Rect,   datacol,column,   State);
end;
end;

procedure TFrmlldsh.bquerysClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
 relation:=' like ''';
    cx:='%';
commandstring:='select * from dbo.llb';
commandtring1:='select * from dbo.llb';
  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+'1'+cx+''')';
end
else
begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' and (dbo.llb.shbj'+relation+cx+'1'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,lldh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet20.DisableControls;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstring;
DataModule1.ClientDataSet20.Open;
DataModule1.ClientDataSet20.EnableControls;
help.Caption:='   查询完毕!';
except
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmlldsh.bfsClick(Sender: TObject);
var
lldh,relation,cx,dx,sqlstr:string;
  begin
if not DataModule1.ClientDataSet20.Active then exit;
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
 relation:=' = ''';
 cx:='';
 dx:= ' ''';
try
lldh:=DataModule1.ClientDataSet20.FieldByName('lldh').AsString;
DataModule1.ClientDataSet20.Edit;
if DataModule1.ClientDataSet20.FieldByName('shbj').AsInteger=1 then
  begin
sqlstr:='update dbo.llb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'0'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (lldh' +relation+cx+lldh+cx+''')';
DataModule1.ClientDataSet20.CommandText:=sqlstr;
DataModule1.ClientDataSet20.Execute;
DataModule1.ClientDataSet20.ApplyUpdates(-1);
DataModule1.ClientDataSet20.DisableControls;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstringq;
DataModule1.ClientDataSet20.Open;
DataModule1.ClientDataSet20.EnableControls;
 help.Caption:= '数据审核成功!';
 end;
 except
 DataModule1.clientdataset20.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
 end;

procedure TFrmlldsh.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;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?