lldwh.pas
来自「应对服装行业的生产成本控制系统」· PAS 代码 · 共 1,180 行 · 第 1/3 页
PAS
1,180 行
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;
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:=' 查询完毕,要修改生产领料记录请用鼠标双击该领料记录所在的行!';
pz.Enabled:=true;
dbgrid5.Enabled:=true;
except
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmlldwh.BdeleteClick(Sender: TObject);
var
relation,cx,dx,datestr:string;
begin
relation:='=''';
cx:='';
dx:='''';
if not DataModule1.ClientDataSet20.Active then exit;
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
datestr:=frmxtfz.checkfzrq(formatdatetime('yyyy-mm-dd',rq.date));
if datestr<>'' then
begin
help.Caption:=' 封账日期为'+datestr+',您不能删除封账日期前的数据';
exit;
end;
if not check then exit;
if DataModule1.ClientDataSet20.FieldByName('shbj').AsInteger=1 then
begin
help.Caption:=' 记录已经审核,您无权修改!' ;
exit;
end;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
if (MessageDlg('您确认要删除该条记录吗?',mtConfirmation,[mbYes, mbCancel], 0) = mrYes) then
begin
try
DataModule1.ClientDataSet20.DisableConstraints;
commandstring:='delete from dbo.llb';
commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+DataModule1.ClientDataSet20.fieldbyname('lldh').AsString+cx+''')';
DataModule1.ClientDataSet20.CommandText:=commandstring;
DataModule1.ClientDataSet20.Execute;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstringq;
DataModule1.ClientDataSet20.Open;
DataModule1.ClientDataSet20.EnableControls;
dbgrid5.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmlldwh.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;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid5.Enabled:=true;
help.Caption:= '数据审核成功!';
end;
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset20.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmlldwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet20.Active then exit;
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
if DataModule1.ClientDataSet20.FieldByName('shbj').AsInteger=1 then
begin
help.Caption:=' 记录已经审核,您无权修改!';
brework.Enabled:=false;
exit;
end;
help.Caption:='';
brework.Enabled:=false;
bsave.Enabled:=true;
bcancel.Enabled:=true;
bdelete.Enabled:=false;
bsh.Enabled:=false;
bprint.Enabled:=false;
pz.Enabled:=true;
rq.SetFocus;
help.Caption:=' 请您输入数据!';
end;
procedure TFrmlldwh.tllrChange(Sender: TObject);
var
relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ygb';
if trim(tllr.Text)<>'' then
begin
commandstring:=commandstring+' where (xm'+relation+cx+trim(tllr.Text)+cx+''')'+' order by xm';;
DataModule1.ClientDataSet3.Close;
DataModule1.ClientDataSet3.CommandText:=commandstring;
DataModule1.ClientDataSet3.Open;
end;
if trim(tllr.Text)='' then
begin
help.Caption:=' 请您输入或选择一位员工!';
exit;
end;
end;
procedure TFrmlldwh.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 TFrmlldwh.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 TFrmlldwh.DBGrid5DblClick(Sender: TObject);
begin
if DataModule1.ClientDataSet20.Active then
begin
if DataModule1.ClientDataSet20.RecordCount<1 then exit;
tlldh.Text:=DataModule1.clientdataset20.FieldByName('lldh').AsString;
rq.DateTime:=DataModule1.clientdataset20.FieldByName('rq').AsDateTime;
tddh.Text:=DataModule1.clientdataset20.FieldByName('ddh').AsString;
tclmc.Text:=DataModule1.clientdataset20.FieldByName('clmc').AsString;
tclfl.Text:=DataModule1.clientdataset20.FieldByName('clfl').AsString;
tcldw.Text:=DataModule1.clientdataset20.FieldByName('dw').AsString;
tggxh.Text:=DataModule1.clientdataset20.FieldByName('ggxh').AsString;
tys.Text:=DataModule1.clientdataset20.FieldByName('ys').AsString;
tsl.Text:=DataModule1.clientdataset20.FieldByName('sl').AsString;
tdj.Text:=DataModule1.clientdataset20.FieldByName('dj').AsString;
tje.Text:=DataModule1.clientdataset20.FieldByName('je').AsString;
tbz.Text:=DataModule1.clientdataset20.FieldByName('bz').AsString;
tfb.Text:=DataModule1.clientdataset20.FieldByName('fb').AsString;
tfz.Text:=DataModule1.clientdataset20.FieldByName('fz').AsString;
tllr.Text:=DataModule1.clientdataset20.FieldByName('llr').AsString;
tflr.Text:=DataModule1.clientdataset20.FieldByName('flr').AsString;
tzgr.Text:=DataModule1.clientdataset20.FieldByName('zgr').AsString;
brework.Enabled:=true;
brework.SetFocus;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=true;
end;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
dbgrid5.Enabled:=false;
end;
procedure TFrmlldwh.SpeedButton2Click(Sender: TObject);
begin
form1.clmc:=trim(tclmc.Text);
frmclml.showmodal;
tclmc.Text:=form1.clmc;
form1.clmc:='';
end;
procedure TFrmlldwh.tfbKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tfz.SetFocus;
end;
procedure TFrmlldwh.tfzKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tllr.SetFocus;
end;
procedure TFrmlldwh.tllrKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tflr.SetFocus;
end;
procedure TFrmlldwh.tflrKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tzgr.SetFocus;
end;
procedure TFrmlldwh.tzgrKeyPress(Sender: TObject; var Key: Char);
begin
if not bsave.Enabled then exit;
if key=#13 then bsave.SetFocus;
end;
procedure TFrmlldwh.tysKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tsl.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?