glfysh.~pas

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

~PAS
686
字号
unit glfysh;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, Grids, DBGrids, ExtCtrls, DBCtrls,
  DB, ADODB, DBClient;

type
  TFrmglfysh = class(TForm)
    Pz: TPanel;
    help: TLabel;
    Pd: TPanel;
    bprint: TBitBtn;
    breturn: TBitBtn;
    Bquery: TBitBtn;
    bprintc: TBitBtn;
    OpenDialog1: TOpenDialog;
    bsh: TBitBtn;
    bfs: TBitBtn;
    bquerys: TBitBtn;
    GroupBox4: TGroupBox;
    pq: TPanel;
    cqrq: TCheckBox;
    cje: TCheckBox;
    czrq: TCheckBox;
    zrq: TDateTimePicker;
    qje: TEdit;
    cbxr: TCheckBox;
    qbxr: TEdit;
    cfz: TCheckBox;
    qfz: TEdit;
    czy: TCheckBox;
    qzy: TEdit;
    cfylb: TCheckBox;
    cbz: TCheckBox;
    qfylb: TEdit;
    qbz: TEdit;
    qrq: TDateTimePicker;
    Cczy: TCheckBox;
    qczy: TEdit;
    cfb: TCheckBox;
    qfb: TEdit;
    cddh: TCheckBox;
    qddh: TEdit;
    DBGrid1: TDBGrid;
    procedure breturnClick(Sender: TObject);
    procedure DBGrid1TitleClick(Column: TColumn);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BqueryClick(Sender: TObject);
    procedure bprintcClick(Sender: TObject);
    procedure bquerysClick(Sender: TObject);
    procedure bshClick(Sender: TObject);
    procedure bfsClick(Sender: TObject);
    procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure bprintClick(Sender: TObject);
  private
    { Private declarations }
      rzczy,rzsj,rzjsj,rzcsj:string;
  commandstring,commandstringq: string;
  public
    { Public declarations }
  end;

var
  Frmglfysh: TFrmglfysh;

implementation

uses unit28, Unit1, Unit16,func;

{$R *.dfm}

procedure TFrmglfysh.breturnClick(Sender: TObject);
begin
try
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
DataModule1.ClientDataSet26.IndexFieldNames:='';
if DataModule1.clientdataset26.Active then  DataModule1.ClientDataSet26.Active:=false;
except
showmessage('数据库没有打开!');
end;
close;
end;

procedure TFrmglfysh.DBGrid1TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid1.Columns.Count do
begin
//恢复所有标题字体为默认
DBGrid1.Columns[i-1].Title.Font.Color := clBlue;
DBGrid1.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet26.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet26.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;


procedure TFrmglfysh.FormActivate(Sender: TObject);
begin
try
qrq.Date:=date;
zrq.Date:=date;
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='费用审核操作';
rzcsj:='';
bprint.Enabled:=false;
dbgrid1.Enabled:=true;
help.Caption:='';
help.Caption:='  请您查询您需要审核的数据!';
except
showmessage('数据库没有打开!')
end;
end;

procedure TFrmglfysh.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
DataModule1.ClientDataSet26.IndexFieldNames:='';
if DataModule1.clientdataset26.Active then  DataModule1.ClientDataSet26.Active:=false;
if rzcsj<>'' then exit;
rzcsj:=datetimetostr(now);
form16.WriteTorz(rzczy,rzsj,rzjsj,rzcsj);
except
showmessage('数据库没有打开!');
end;
close;
end;

procedure TFrmglfysh.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.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+'0'+cx+''')';
end
else
begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' and (dbo.scfyb.shbj'+relation+cx+'0'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,fyh ';

⌨️ 快捷键说明

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