glfysh.pas

来自「应对服装行业的生产成本控制系统」· PAS 代码 · 共 685 行 · 第 1/2 页

PAS
685
字号
DataModule1.ClientDataSet26.DisableControls;
DataModule1.ClientDataSet26.Close;
DataModule1.ClientDataSet26.CommandText:=commandstring;
DataModule1.ClientDataSet26.Open;
DataModule1.ClientDataSet26.EnableControls;
bprint.Enabled:=true;
help.Caption:='   查询完毕!';
except
DataModule1.clientdataset26.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmglfysh.bprintcClick(Sender: TObject);
var
excelname: string;
begin
if not form1.excel then
begin
showmessage('您还未获得管理员的授权!请您与管理员联系获取授权!');
exit;
end;
if DataModule1.ClientDataSet26.RecordCount<=0 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then
excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet26,excelname,'费用信息报表');
exit;
end;

procedure TFrmglfysh.bquerysClick(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.scfyb.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(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.scfyb.ddh'+relation+cx+trim(qbz.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;
if  commandstring=commandtring1 then
  begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' where (dbo.scfyb.shbj'+relation+cx+'1'+cx+''')';
end
else
begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' and (dbo.scfyb.shbj'+relation+cx+'1'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,fyh ';
commandstringq:=commandstring;
DataModule1.ClientDataSet26.DisableControls;
DataModule1.ClientDataSet26.Close;
DataModule1.ClientDataSet26.CommandText:=commandstring;
DataModule1.ClientDataSet26.Open;
DataModule1.ClientDataSet26.EnableControls;
bprint.Enabled:=true;
help.Caption:='   查询完毕!';
except
DataModule1.clientdataset26.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmglfysh.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;
 help.Caption:= '数据审核成功!';
 end;
 except
 DataModule1.clientdataset26.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
end;

procedure TFrmglfysh.bfsClick(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=1 then
  begin
sqlstr:='update dbo.scfyb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'0'+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;
 help.Caption:= '数据反审核成功!';
 end;
 except
 DataModule1.clientdataset26.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
end;

procedure TFrmglfysh.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 TFrmglfysh.bprintClick(Sender: TObject);
begin
help.Caption:='  暂不提供打印功能!';
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?