lldwh.pas

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

PAS
1,180
字号
if DataModule1.ClientDataSet15.RecordCount>0 then
begin
tclmc.Text:=DataModule1.ClientDataSet15.FieldByName('clmc').AsString;
tclfl.Text:=DataModule1.ClientDataSet15.FieldByName('clfl').AsString;
tcldw.text:=DataModule1.ClientDataSet15.FieldByName('cldw').AsString;
tggxh.SetFocus;
end;
end;

procedure TFrmlldwh.tslChange(Sender: TObject);
var
zhrmb:string;
begin
if trim(tje.Text)='' then tje.Text:='0';
if trim(tdj.Text)='' then tdj.Text:='0';
if (trim(tsl.Text)<>'') and (trim(tdj.Text)<>'') then
begin
tje.Text:=formatfloat('0.00',strtofloat(tsl.Text)*strtofloat(tdj.Text));
end;
end;

procedure TFrmlldwh.bsaveClick(Sender: TObject);
var
datestr:string;
begin
if not bsave.Enabled then exit;
bsave.Enabled:=false;
bcancel.Enabled:=false;
errcode:=true;
errzt:=1;
if not check then
begin
bsave.Enabled:=true;
bcancel.Enabled:=true;
 exit;
 end;
datestr:=frmxtfz.checkfzrq(formatdatetime('yyyy-mm-dd',rq.date));
if datestr<>'' then
begin
help.Caption:='  封账日期为'+datestr+',您不能修改封账日期前的数据';
exit;
end;
form1.clmc:=trim(tclmc.Text);
form1.clfl:=trim(tclfl.Text);
form1.cldw:=trim(tcldw.Text);
frmclml.checkcl(form1.clmc,form1.clfl,form1.cldw);
if form1.clmc='' then
begin
bsave.Enabled:=true;
bcancel.Enabled:=true;
tclmc.SetFocus;
help.Caption:='  该材料不存在,请您输入正确的材料名称!';
 exit;
 end;
form1.clmc:='';
form1.clfl:='';
form1.cldw:='';
form1.yg:=trim(tllr.Text);
form1.fb:=trim(tfb.Text);
form1.fz:=trim(tfz.Text);
frmcpml.checkcp(form1.yg,form1.fb,form1.fz);
if form1.yg='' then
begin
bsave.Enabled:=true;
bcancel.Enabled:=true;
tllr.SetFocus;
help.Caption:='  该员工不存在,请您输入正确的员工!';
 exit;
 end;
form1.yg:='';
form1.fb:='';
form1.fz:='';
try
save;
if errcode or (errzt<>0) then save;
if errcode or (errzt<>0) then save;
if errcode or (errzt<>0) then save;
if errcode or (errzt<>0) then
begin
showmessage('   数据库在保存主记录时失败,请您稍后重新保存!');
bsave.Enabled:=true;
bcancel.Enabled:=true;
exit;
end;
help.Caption:='   修改领料操作成功!' ;
 tlldh.Text:='';
 tddh.Text:='';
 tclmc.Text:='';
 tclfl.Text:='';
 tcldw.Text:='';
 tggxh.Text:='';
 tys.Text:='';
 tsl.Text:='';
 tdj.Text:='';
 tje.Text:='';
 tbz.Text:='';
 tfb.Text:='';
 tfz.Text:='';
 tllr.Text:='';
 tflr.Text:='';
 tzgr.Text:='';
bsh.Enabled:=true;
bprint.Enabled:=true;
dbgrid5.Enabled:=true;
except
bsave.Enabled:=true;
bcancel.Enabled:=true;
showmessage('     记录领料单时出现了系统无法识别的错误,请您主动辨别该错误!');
end;
end;

function tFrmlldwh.errdelete:boolean;
var
relation,cx:string;
begin
 relation:=' = ''';
 cx:='';
    try
  commandstring:='delete from dbo.llb';
  commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+tlldh.Text+cx+''')';
  DataModule1.ClientDataSet20.CommandText:=commandstring;
  DataModule1.ClientDataSet20.Execute;
  except
  showmessage('数据库没有打开')
  end;
  end;

procedure TFrmlldwh.FormActivate(Sender: TObject);
begin
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='领料维护';
qq.DateTime:=date-31;
zq.DateTime:=date;
rq.DateTime:=date;
help.Caption:='';
brework.Enabled:=false;
bdelete.Enabled:=false;
bsh.Enabled:=false;
bsave.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
dbgrid5.Enabled:=true;
pz.Enabled:=true;
 tlldh.Text:='';
 tddh.Text:='';
 tclmc.Text:='';
 tclfl.Text:='';
 tcldw.Text:='';
 tggxh.Text:='';
 tys.Text:='';
 tsl.Text:='';
 tdj.Text:='';
 tje.Text:='';
 tbz.Text:='';
 tfb.Text:='';
 tfz.Text:='';
 tllr.Text:='';
 tflr.Text:='';
 tzgr.Text:='';
pz.Enabled:=false;
help.Caption:='  请您点击<查询>按钮开始查询数据!';
end;

procedure TFrmlldwh.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
DataModule1.ClientDataSet20.IndexFieldNames:='';
if DataModule1.clientdataset20.Active then  DataModule1.ClientDataSet20.Active:=false;
if DataModule1.clientdataset13.Active then  DataModule1.ClientDataSet13.Active:=false;
if DataModule1.clientdataset15.Active then  DataModule1.ClientDataSet15.Active:=false;
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;

procedure TFrmlldwh.tclflKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tcldw.SetFocus;
end;

procedure TFrmlldwh.DBGrid3DblClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet3.Active then exit;
if DataModule1.ClientDataSet3.RecordCount>0 then
begin
tfb.Text:=DataModule1.ClientDataSet3.FieldByName('fb').AsString;
tfz.Text:=DataModule1.ClientDataSet3.FieldByName('fz').AsString;
tllr.text:=DataModule1.ClientDataSet3.FieldByName('xm').AsString;
tflr.SetFocus;
end;
end;

procedure TFrmlldwh.rqKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tclmc.SetFocus;
end;

procedure TFrmlldwh.tjeKeyPress(Sender: TObject; var Key: Char);
begin
if not (key in['0'..'9',#8,#13,'.','-']) then
begin
key:=#0;
help.caption:='   请输入数字!';
end;
if key=#13 then tbz.SetFocus;
end;

procedure TFrmlldwh.BqueryClick(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+''')';

⌨️ 快捷键说明

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