ddwh.pas
来自「应对服装行业的生产成本控制系统」· PAS 代码 · 共 1,268 行 · 第 1/3 页
PAS
1,268 行
cx:='%';
commandstring:='select * from dbo.ddb';
commandtring1:='select * from dbo.ddb';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qjglx.Text)<>'') and (cjglx.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end;
end
else
begin
qjglx.Text:='';
end;
if (trim(qkhmc.Text)<>'') and (ckhmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
end;
end
else
begin
qkhmc.Text:='';
end;
if (trim(qcpmc.Text)<>'') and (ccpmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
end;
end
else
begin
qcpmc.Text:='';
end;
if (trim(qcpfl.Text)<>'') and (ccpfl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
end;
end
else
begin
qcpfl.Text:='';
end;
if (trim(qcpdw.Text)<>'') and (ccpdw.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
end;
end
else
begin
qcpdw.Text:='';
end;
if csq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end;
end;
if csz.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end;
end;
if cjq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end;
end;
if cjz.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end;
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.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.ddb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.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.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
commandstring:=commandstring+' order by ddh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet17.DisableControls;
DataModule1.ClientDataSet17.Close;
DataModule1.ClientDataSet17.CommandText:=commandstring;
DataModule1.ClientDataSet17.Open;
DataModule1.ClientDataSet17.EnableControls;
help.Caption:=' 查询完毕,要更改记录请用鼠标双击该记录所在的行!';
pz.Enabled:=true;
dbgrid1.Enabled:=true;
except
DataModule1.clientdataset17.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmddwh.DBGrid1DblClick(Sender: TObject);
VAR
relation:string;
begin
relation:=' = ''';
try
if DataModule1.ClientDataSet17.Active then
begin
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
tddh.Text:=DataModule1.clientdataset17.FieldByName('ddh').AsString;
jglx.KeyValue:=DataModule1.clientdataset17.FieldByName('jglx').AsString;
tkhmc.Text:=DataModule1.clientdataset17.FieldByName('khmc').AsString;
tcpmc.Text:=DataModule1.clientdataset17.FieldByName('cpmc').AsString;
tcpfl.Text:=DataModule1.clientdataset17.FieldByName('cpfl').AsString;
tcpdw.Text:=DataModule1.clientdataset17.FieldByName('cpdw').AsString;
jdrq.Date:=DataModule1.ClientDataSet17.FieldByName('jdrq').AsDateTime;
jhrq.Date:=DataModule1.ClientDataSet17.FieldByName('jhrq').AsDateTime;
tsl.Text:=DataModule1.clientdataset17.FieldByName('sl').AsString;
tdj.Text:=DataModule1.clientdataset17.FieldByName('dj').AsString;
tje.Text:=DataModule1.clientdataset17.FieldByName('je').AsString;
tbz.Text:=DataModule1.clientdataset17.FieldByName('bz').AsString;
commandstring:='select * from dbo.ddmxb where (dbo.ddmxb.ddh'+relation+DataModule1.ClientDataSet17.FieldByName('ddh').AsString+''' )'+' order by xh';
ClientDataSet1.Close;
ClientDataSet1.CommandText:=commandstring;
ClientDataSet1.Open;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
brework.Enabled:=true;
brework.SetFocus;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=true;
dbgrid1.Enabled:=false;
end;
except
dbgrid1.Enabled:=true;
showmessage('表格中数据出现了错误!')
end;
end;
procedure TFrmddwh.BdeleteClick(Sender: TObject);
var
datestr,relation,cx,dx:string;
begin
relation:='=''';
cx:='';
dx:='''';
datestr:=frmxtfz.checkfzrq(formatdatetime('yyyy-mm-dd',jdrq.date));
if datestr<>'' then
begin
help.Caption:=' 封账日期为'+datestr+'您不能修改封账日期前的数据';
exit;
end;
if not DataModule1.ClientDataSet17.Active then exit;
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet17.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.ClientDataSet17.DisableConstraints;
commandstring:='delete from dbo.ddb';
commandstring:=commandstring+' where (dbo.ddb.ddh'+relation+cx+tddh.Text+cx+''')';
DataModule1.ClientDataSet17.CommandText:=commandstring;
DataModule1.ClientDataSet17.Execute;
DataModule1.ClientDataSet17.Close;
DataModule1.ClientDataSet17.CommandText:=commandstringq;
DataModule1.ClientDataSet17.Open;
DataModule1.ClientDataSet17.EnableControls;
commandstring:='delete from dbo.ddmxb';
commandstring:=commandstring+' where (dbo.ddmxb.ddh'+relation+cx+tddh.text+cx+''')';
clientdataset1.DisableControls;
clientdataset1.CommandText:=commandstring;
clientdataset1.Execute;
commandstring:='select * from dbo.ddmxb';
commandstring:=commandstring+' where (dbo.ddmxb.ddhh'+relation+cx+tddh.Text+cx+''')';
clientdataset1.Close;
clientdataset1.CommandText:=commandstring;
clientdataset1.Open;
clientdataset1.EnableControls;
dbgrid1.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid1.Enabled:=true;
clientdataset1.EnableControls;
DataModule1.clientdataset17.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmddwh.bshClick(Sender: TObject);
var
ddh,relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet17.Active then exit;
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
ddh:=DataModule1.ClientDataSet17.FieldByName('ddh').AsString;
DataModule1.ClientDataSet17.Edit;
if DataModule1.ClientDataSet17.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.ddb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (ddh' +relation+cx+ddh+cx+''')';
DataModule1.ClientDataSet17.CommandText:=sqlstr;
DataModule1.ClientDataSet17.Execute;
DataModule1.ClientDataSet17.ApplyUpdates(-1);
DataModule1.ClientDataSet17.DisableControls;
DataModule1.ClientDataSet17.Close;
DataModule1.ClientDataSet17.CommandText:=commandstringq;
DataModule1.ClientDataSet17.Open;
DataModule1.ClientDataSet17.EnableControls;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid1.Enabled:=true;
help.Caption:= '数据审核成功!';
end;
except
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid1.Enabled:=true;
DataModule1.clientdataset17.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmddwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet17.Active then exit;
if DataModule1.ClientDataSet17.RecordCount<1 then exit;
if DataModule1.ClientDataSet17.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;
jglx.SetFocus;
help.Caption:=' 请您输入数据!';
end;
procedure TFrmddwh.SpeedButton2Click(Sender: TObject);
begin
if trim(tkhmc.Text)<>'' then
begin
form1.kh:='';
frmwjgdw.showmodal;
tkhmc.Text:=form1.kh;
form1.kh:='';
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?