ccwh.~pas
来自「应对服装行业的生产成本控制系统」· ~PAS 代码 · 共 689 行 · 第 1/2 页
~PAS
689 行
begin
if key=#13 then tys.SetFocus;
end;
procedure TFrmccwh.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ccb';
commandtring1:='select * from dbo.ccb';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.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.ccb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.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.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.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.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ccb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.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.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qms.Text)<>'') and (cms.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ccb.ms'+relation+cx+trim(qms.Text)+cx+''')';
end;
end
else
begin
qms.Text:='';
end;
commandstring:=commandstring+' order by ddh,xh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet22.DisableControls;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstring;
DataModule1.ClientDataSet22.Open;
DataModule1.ClientDataSet22.EnableControls;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid5.Enabled:=true;
help.Caption:=' 查询完毕,要修改裁床信息记录请用鼠标双击该订单出货记录所在的行!';
pz.Enabled:=true;
except
DataModule1.clientdataset22.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmccwh.DBGrid5DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if DataModule1.ClientDataSet22.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 TFrmccwh.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.ClientDataSet22.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet22.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmccwh.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.ClientDataSet22.Active then exit;
if DataModule1.ClientDataSet22.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet22.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.ccb';
commandstring:=commandstring+' where (dbo.ccb.ddh'+relation+cx+DataModule1.ClientDataSet22.fieldbyname('ddh').asstring+cx+''')';
commandstring:=commandstring+' and (dbo.ccb.xh'+relation+cx+DataModule1.ClientDataSet22.fieldbyname('xh').asstring+cx+''')';
DataModule1.ClientDataSet22.CommandText:=commandstring;
DataModule1.ClientDataSet22.Execute;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstringq;
DataModule1.ClientDataSet22.Open;
DataModule1.ClientDataSet22.EnableControls;
dbgrid5.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset22.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmccwh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet22.Active then exit;
if DataModule1.ClientDataSet22.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet22.Edit;
if DataModule1.ClientDataSet22.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.ccb 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.ClientDataSet22.FieldByName('ddh').AsString+cx+''')';
sqlstr:=sqlstr+' and (xh' +relation+cx+DataModule1.ClientDataSet22.FieldByName('xh').AsString+cx+''')';
DataModule1.ClientDataSet22.CommandText:=sqlstr;
DataModule1.ClientDataSet22.Execute;
DataModule1.ClientDataSet22.ApplyUpdates(-1);
DataModule1.ClientDataSet22.DisableControls;
DataModule1.ClientDataSet22.Close;
DataModule1.ClientDataSet22.CommandText:=commandstringq;
DataModule1.ClientDataSet22.Open;
DataModule1.ClientDataSet22.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.clientdataset22.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmccwh.DBGrid5DblClick(Sender: TObject);
var
relation:string;
begin
relation:=' = ''';
if DataModule1.ClientDataSet22.Active then
begin
if DataModule1.ClientDataSet22.RecordCount<1 then exit;
tcc.Text:=DataModule1.clientdataset22.FieldByName('cc').AsString;
txh.Text:=DataModule1.clientdataset22.FieldByName('xh').AsString;
rq.DateTime:=DataModule1.clientdataset22.FieldByName('rq').AsDateTime;
tys.Text:=DataModule1.clientdataset22.FieldByName('ys').AsString;
tsl.Text:=DataModule1.clientdataset22.FieldByName('sl').AsString;
tms.Text:=DataModule1.clientdataset22.FieldByName('ms').AsString;
tbz.Text:=DataModule1.clientdataset22.FieldByName('bz').AsString;
commandstring:='select * from dbo.ddmxb where (dbo.ddmxb.ddh'+relation+DataModule1.ClientDataSet22.FieldByName('ddh').AsString+''' )'+' order by xh';
DataModule1.ClientDataSet18.Close;
DataModule1.ClientDataSet18.CommandText:=commandstring;
DataModule1.ClientDataSet18.Open;
brework.Enabled:=true;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=true;
bprint.Enabled:=false;
bsh.Enabled:=true;
brework.SetFocus;
end;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
dbgrid5.Enabled:=false;
end;
procedure TFrmccwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet22.Active then exit;
if DataModule1.ClientDataSet22.RecordCount<1 then exit;
if DataModule1.ClientDataSet22.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;
tcc.SetFocus;
help.Caption:=' 请您输入数据!';
end;
procedure TFrmccwh.txhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then rq.SetFocus;
end;
procedure TFrmccwh.tbzKeyPress(Sender: TObject; var Key: Char);
begin
if not bsave.Enabled then exit;
if key=#13 then bsave.setfocus;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?