glfywh.~pas
来自「应对服装行业的生产成本控制系统」· ~PAS 代码 · 共 839 行 · 第 1/2 页
~PAS
839 行
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;
procedure TFrmglfywh.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.scfyb';
commandtring1:='select * from dbo.scfyb';
try
if (trim(qbxr.Text)<>'') and (cbxr.Checked) then
begin
if commandstring=commandtring1 then
BEGIN
commandstring:=commandstring+' where (dbo.scfyb.bxr'+relation+cx+trim(qbxr.Text)+cx+''')'
END
else
BEGIN
commandstring:=commandstring+' and (dbo.glfyb.bxr'+relation+cx+trim(qbxr.Text)+cx+''')'
end;
end
else
begin
qbxr.Text:='';
end;
if cqrq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.scfyb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qrq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.scfyb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qrq.Date)+cx+''')';
end;
end;
if czrq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' <''';
cx:='';
commandstring:=commandstring+' where (dbo.scfyb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zrq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.scfyb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zrq.Date+1)+cx+''')';
end;
end;
if (trim(qfb.Text)<>'') and (cfb.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.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.scfyb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end;
end
else
begin
qfz.Text:='';
end;
if (trim(qzy.Text)<>'') and (czy.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.zy'+relation+cx+trim(qzy.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.zy'+relation+cx+trim(qzy.Text)+cx+''')';
end;
end
else
begin
qzy.Text:='';
end;
if (trim(qfylb.Text)<>'') and (cfylb.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.fylb'+relation+cx+trim(qfylb.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.fylb'+relation+cx+trim(qfylb.Text)+cx+''')';
end;
end
else
begin
qfylb.Text:='';
end;
if (trim(qje.Text)<>'') and (cje.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
begin
relation:=' like ''';
cx:='';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if (trim(qczy.Text)<>'') and (cczy.Checked) then
begin
relation:=' like ''';
cx:='';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.scfyb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end;
end
else
begin
qczy.Text:='';
end;
commandstring:=commandstring+' order by shbj,fyh ';
commandstringq:=commandstring;
DataModule1.ClientDataSet26.DisableControls;
DataModule1.ClientDataSet26.Close;
DataModule1.ClientDataSet26.CommandText:=commandstring;
DataModule1.ClientDataSet26.Open;
DataModule1.ClientDataSet26.EnableControls;
help.Caption:=' 查询完毕,要更改记录请用鼠标双击该记录所在的行!';
pz.Enabled:=true;
dbgrid1.Enabled:=true;
except
DataModule1.clientdataset26.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmglfywh.breworkClick(Sender: TObject);
begin
if DataModule1.ClientDataSet26.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;
tbh.Enabled:=false;
help.Caption:=' 请您修改记录数据!';
end;
procedure TFrmglfywh.BdeleteClick(Sender: TObject);
var
datestr,relation,cx,dx: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.ClientDataSet26.Active then exit;
if DataModule1.ClientDataSet26.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet26.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.ClientDataSet26.DisableConstraints;
commandstring:='delete from dbo.scfyb';
commandstring:=commandstring+' where (dbo.scfyb.fyh'+relation+cx+tbh.Text+cx+''')';
DataModule1.ClientDataSet26.CommandText:=commandstring;
DataModule1.ClientDataSet26.Execute;
DataModule1.ClientDataSet26.Close;
DataModule1.ClientDataSet26.CommandText:=commandstringq;
DataModule1.ClientDataSet26.Open;
DataModule1.ClientDataSet26.EnableControls;
dbgrid1.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid1.Enabled:=true;
DataModule1.clientdataset26.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmglfywh.bshClick(Sender: TObject);
var
kcid,relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet26.Active then exit;
if DataModule1.ClientDataSet26.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
kcid:=DataModule1.ClientDataSet26.FieldByName('fyh').AsString;
DataModule1.ClientDataSet26.Edit;
if DataModule1.ClientDataSet26.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.scfyb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (fyh' +relation+cx+kcid+cx+''')';
DataModule1.ClientDataSet26.CommandText:=sqlstr;
DataModule1.ClientDataSet26.Execute;
DataModule1.ClientDataSet26.ApplyUpdates(-1);
DataModule1.ClientDataSet26.DisableControls;
DataModule1.ClientDataSet26.Close;
DataModule1.ClientDataSet26.CommandText:=commandstringq;
DataModule1.ClientDataSet26.Open;
DataModule1.ClientDataSet26.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
dbgrid1.Enabled:=true;
DataModule1.clientdataset26.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmglfywh.DBGrid1DblClick(Sender: TObject);
begin
try
if DataModule1.ClientDataSet26.Active then
begin
if DataModule1.clientDataSet26.RecordCount<1 then exit;
tbh.Text:=DataModule1.clientdataset26.FieldByName('fyh').AsString;
rq.Date:=DataModule1.ClientDataSet26.FieldByName('rq').AsDateTime;
fb.KeyValue:=DataModule1.clientdataset26.FieldByName('fb').AsString;
fz.KeyValue:=DataModule1.clientdataset26.FieldByName('fz').AsString;
tbxr.Text:=DataModule1.clientdataset26.FieldByName('bxr').AsString;
tzy.Text:=DataModule1.clientDataSet26.FieldByName('zy').AsString;
fylb.Text:=DataModule1.clientDataSet26.FieldByName('fylb').AsString;
tje.Text:=DataModule1.clientDataSet26.FieldByName('je').AsString;
tddh.Text:=DataModule1.clientDataSet26.FieldByName('ddh').AsString;
tbz.Text:=DataModule1.clientDataSet26.FieldByName('bz').AsString;
brework.Enabled:=true;
brework.SetFocus;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=true;
end;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
dbgrid1.Enabled:=false;
except
dbgrid1.Enabled:=true;
showmessage('表格中数据出现了错误!')
end;
end;
procedure TFrmglfywh.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.ClientDataSet26.FieldByName('shbj').AsInteger=1 then
begin
dbgrid1.Canvas.Font.Color:=clred;
dbgrid1.Canvas.Brush.Color:=clyellow;
end
else
begin
dbgrid1.Canvas.Font.Color:=clblue;
dbgrid1.Canvas.Brush.Color:=clwhite;
end;
dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
if ((State = [gdSelected]) or (State = [gdSelected, gdFocused])) then
begin
DBGrid1.Canvas.Brush.Color:=clred;
DBGrid1.Canvas.Font.Color:=clWhite;
DBGrid1.DefaultDrawColumnCell(Rect, datacol,column, State);
end;
end;
procedure TFrmglfywh.fbKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then fz.SetFocus;
end;
procedure TFrmglfywh.tddhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tbz.SetFocus;
end;
procedure TFrmglfywh.SpeedButton1Click(Sender: TObject);
begin
form1.fylb:=trim(fylb.Text);
frmfylb.showmodal;
fylb.Text:=form1.fylb;
form1.fylb:='';
end;
procedure TFrmglfywh.fylbChange(Sender: TObject);
var
relation,cx,sqlstr:string;
begin
relation:=' like ''';
cx:='%';
sqlstr:='select * from fylbb';
if trim(fylb.Text)<>'' then
begin
sqlstr:=sqlstr+' where (fylb'+relation+cx+trim(fylb.Text)+cx+''')';
sqlstr:=sqlstr+' and (lb'+relation+cx+'fy'+cx+''')'+' order by xh';
DataModule1.ClientDataSet16.Close;
DataModule1.ClientDataSet16.CommandText:=sqlstr;
DataModule1.ClientDataSet16.Open;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?