lldcx.pas

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

PAS
1,845
字号
unit lldcx;

interface

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

type
  TFrmlldcx = class(TForm)
    Pz: TPanel;
    help: TLabel;
    Label7: TLabel;
    Pd: TPanel;
    pq: TPanel;
    cqq: TCheckBox;
    cddh: TCheckBox;
    qddh: TEdit;
    clldh: TCheckBox;
    czq: TCheckBox;
    zq: TDateTimePicker;
    qlldh: TEdit;
    cclfl: TCheckBox;
    qclfl: TEdit;
    cclmc: TCheckBox;
    qclmc: TEdit;
    cje: TCheckBox;
    ccldw: TCheckBox;
    qje: TEdit;
    qcldw: TEdit;
    cggxh: TCheckBox;
    cfb: TCheckBox;
    qggxh: TEdit;
    qfb: TEdit;
    qq: TDateTimePicker;
    cys: TCheckBox;
    cfz: TCheckBox;
    qys: TEdit;
    qfz: TEdit;
    GroupBox1: TGroupBox;
    DBGrid5: TDBGrid;
    Cflr: TCheckBox;
    qflr: TEdit;
    Czgr: TCheckBox;
    qzgr: TEdit;
    Cbz: TCheckBox;
    qbz: TEdit;
    Csl: TCheckBox;
    qsl: TEdit;
    qdj: TEdit;
    Cdj: TCheckBox;
    Cllr: TCheckBox;
    qllr: TEdit;
    bprint: TBitBtn;
    breturn: TBitBtn;
    Bquery: TBitBtn;
    bprintc: TBitBtn;
    Bddhz: TBitBtn;
    Bfbhz: TBitBtn;
    Bfzhz: TBitBtn;
    Bllrhz: TBitBtn;
    OpenDialog1: TOpenDialog;
    procedure bprintClick(Sender: TObject);
    procedure breturnClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BqueryClick(Sender: TObject);
    procedure DBGrid5TitleClick(Column: TColumn);
    procedure bprintcClick(Sender: TObject);
    procedure BddhzClick(Sender: TObject);
    procedure BfbhzClick(Sender: TObject);
    procedure BfzhzClick(Sender: TObject);
    procedure BllrhzClick(Sender: TObject);
    procedure DBGrid5KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
      rzczy,rzsj,rzjsj,rzcsj:string;
      errzt: integer;
      errcode:boolean;
  commandstring,commandstringq: string;
  function hz():boolean;
  public
    { Public declarations }
  end;

var
  Frmlldcx: TFrmlldcx;

implementation

uses unit28, Unit1, Unit16, func;

{$R *.dfm}

procedure TFrmlldcx.bprintClick(Sender: TObject);
begin
help.Caption:='   暂不提供打印功能!';
end;

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

procedure TFrmlldcx.FormActivate(Sender: TObject);
begin
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='领料审核';
qq.DateTime:=date-31;
zq.DateTime:=date;
help.Caption:='';
help.Caption:='  请您点击<查询>按钮开始查询数据!';
end;

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

procedure TFrmlldcx.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
 relation:=' like ''';
    cx:='%';
commandstring:='select * from dbo.llb';
commandtring1:='select * from dbo.llb';
  try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qlldh.Text)<>'') and (clldh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end;
end
else
begin
qlldh.Text:='';
end;
if cqq.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' where (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.llb.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.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qclfl.Text)<>'') and (cclfl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end;
end
else
begin
qclfl.Text:='';
end;
if (trim(qclmc.Text)<>'') and (cclmc.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end;
end
else
begin
qclmc.Text:='';
end;
if (trim(qcldw.Text)<>'') and (ccldw.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';
end;
end
else
begin
qcldw.Text:='';
end;
if (trim(qggxh.Text)<>'') and (cggxh.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.ggxh'+relation+cx+trim(qggxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ggxh'+relation+cx+trim(qggxh.Text)+cx+''')';
end;
end
else
begin
qggxh.Text:='';
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.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.llb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qdj.Text)<>'') and (cdj.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end;
end
else
begin
qdj.Text:='';
end;
if (trim(qje.Text)<>'') and (cje.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
if (trim(qfb.Text)<>'') and (cfb.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.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.llb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end;
end
else
begin
qfz.Text:='';
end;
if (trim(qllr.Text)<>'') and (cllr.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end;
end
else
begin
qllr.Text:='';
end;
if (trim(qflr.Text)<>'') and (cflr.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end;
end
else
begin
qflr.Text:='';
end;
if (trim(qzgr.Text)<>'') and (czgr.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.zgr'+relation+cx+trim(qzgr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.zgr'+relation+cx+trim(qzgr.Text)+cx+''')';
end;
end
else
begin
qzgr.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
commandstring:=commandstring+' order by ddh,lldh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet20.DisableControls;
DataModule1.ClientDataSet20.Close;
DataModule1.ClientDataSet20.CommandText:=commandstring;
DataModule1.ClientDataSet20.Open;
hz;
DataModule1.ClientDataSet20.EnableControls;
except
DataModule1.clientdataset20.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmlldcx.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.ClientDataSet20.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet20.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;

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

procedure TFrmlldcx.BddhzClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
 relation:=' like ''';
    cx:='%';
commandstring:='select ddh,clmc,clfl,dw,ggxh,ys,sum(sl) as sl,dj,sum(je) as je from dbo.llb';
commandtring1:=commandstring;
  try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qlldh.Text)<>'') and (clldh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.lldh'+relation+cx+trim(qlldh.Text)+cx+''')';
end;
end
else
begin
qlldh.Text:='';
end;
if cqq.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' where (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.llb.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.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.llb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qclfl.Text)<>'') and (cclfl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clfl'+relation+cx+trim(qclfl.Text)+cx+''')';
end;
end
else
begin
qclfl.Text:='';
end;
if (trim(qclmc.Text)<>'') and (cclmc.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.clmc'+relation+cx+trim(qclmc.Text)+cx+''')';
end;
end
else
begin
qclmc.Text:='';
end;
if (trim(qcldw.Text)<>'') and (ccldw.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.llb.dw'+relation+cx+trim(qcldw.Text)+cx+''')';

⌨️ 快捷键说明

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