ddchwh.pas
来自「应对服装行业的生产成本控制系统」· PAS 代码 · 共 712 行 · 第 1/2 页
PAS
712 行
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qxh.Text)<>'') and (cxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddchb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end;
end
else
begin
qxh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qcl.Text)<>'') and (ccl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end;
end
else
begin
qcl.Text:='';
end;
if (trim(qcz.Text)<>'') and (ccz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end;
end
else
begin
qcz.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
commandstring:=commandstring+' order by ddh,xh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstring;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
help.Caption:=' 查询完毕,要修改订单出货记录请用鼠标双击该订单出货记录所在的行!';
pz.Enabled:=true;
dbgrid5.Enabled:=true;
except
DataModule1.clientdataset19.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmddchwh.DBGrid5DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.ClientDataSet19.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 TFrmddchwh.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.ClientDataSet19.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet19.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmddchwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
if DataModule1.ClientDataSet19.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;
rq.SetFocus;
help.Caption:=' 请您输入数据!';
end;
procedure TFrmddchwh.BdeleteClick(Sender: TObject);
var
relation,cx,dx,datestr:string;
begin
relation:=' = ''';
cx:='';
dx:='''';
datestr:=frmxtfz.checkfzrq(formatdatetime('yyyy-mm-dd',rq.date));
if datestr<>'' then
begin
help.Caption:=' 封账日期为'+datestr+',您不能删除封账日期前的数据';
exit;
end;
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet19.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
commandstring:='delete from dbo.ddchb';
commandstring:=commandstring+' where (dbo.ddchb.ddh'+relation+cx+DataModule1.ClientDataSet19.fieldbyname('ddh').asstring+cx+''')';
commandstring:=commandstring+' and (dbo.ddchb.xh'+relation+cx+DataModule1.ClientDataSet19.fieldbyname('xh').asstring+cx+''')';
DataModule1.ClientDataSet19.CommandText:=commandstring;
DataModule1.ClientDataSet19.Execute;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstringq;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
dbgrid5.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset19.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmddchwh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet19.Edit;
if DataModule1.ClientDataSet19.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.ddchb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (ddh' +relation+cx+DataModule1.ClientDataSet19.FieldByName('ddh').AsString+cx+''')';
sqlstr:=sqlstr+' and (xh' +relation+cx+DataModule1.ClientDataSet19.FieldByName('xh').AsString+cx+''')';
DataModule1.ClientDataSet19.CommandText:=sqlstr;
DataModule1.ClientDataSet19.Execute;
DataModule1.ClientDataSet19.ApplyUpdates(-1);
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstringq;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.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.clientdataset19.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmddchwh.tbzKeyPress(Sender: TObject; var Key: Char);
begin
if not bsave.Enabled then exit;
if key=#13 then bsave.Enabled:=true;
end;
procedure TFrmddchwh.DBGrid5DblClick(Sender: TObject);
begin
if DataModule1.ClientDataSet19.Active then
begin
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
txh.Text:=DataModule1.clientdataset19.FieldByName('xh').AsString;
rq.DateTime:=DataModule1.clientdataset19.FieldByName('rq').AsDateTime;
tsl.Text:=DataModule1.clientdataset19.FieldByName('sl').AsString;
tczl.Text:=DataModule1.clientdataset19.FieldByName('czl').AsString;
twcl.Text:=DataModule1.clientdataset19.FieldByName('wcl').AsString;
tbz.Text:=DataModule1.clientdataset19.FieldByName('bz').AsString;
brework.Enabled:=true;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=true;
bprint.Enabled:=false;
bsh.Enabled:=true;
brework.SetFocus;
ysl:=DataModule1.clientdataset19.FieldByName('sl').AsString;
yczl:=DataModule1.clientdataset19.FieldByName('czl').AsString;
ywcl:=DataModule1.clientdataset19.FieldByName('wcl').AsString;
end;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
dbgrid5.Enabled:=false;
end;
procedure TFrmddchwh.txhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then rq.SetFocus;
end;
procedure TFrmddchwh.tczlKeyPress(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 twcl.SetFocus;
end;
procedure TFrmddchwh.twclKeyPress(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;
function tfrmddchwh.checkcs():boolean;
var
i,i1:integer;
czl,wcl:string;
begin
czl:='0';
wcl:='0';
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
i1:=DataModule1.ClientDataSet19.RecordCount;
czl:=floattostr(strtofloat(yczl)+strtofloat(tsl.Text)-strtofloat(ysl));
wcl:=floattostr(strtofloat(ywcl)-strtofloat(tsl.Text)+strtofloat(ysl));
tczl.Text:=czl;
twcl.Text:=wcl;
end;
procedure TFrmddchwh.tslChange(Sender: TObject);
begin
if trim(tsl.Text)='' then tsl.Text:='0';
checkcs;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?