⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddchsh.~pas

📁 应对服装行业的生产成本控制系统
💻 ~PAS
字号:
unit ddchsh;

interface

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

type
  TFrmddchsh = class(TForm)
    Pz: TPanel;
    help: TLabel;
    Label7: TLabel;
    Pd: TPanel;
    pq: TPanel;
    cddh: TCheckBox;
    qddh: TEdit;
    cxh: TCheckBox;
    qxh: TEdit;
    ccl: TCheckBox;
    qcl: TEdit;
    ccz: TCheckBox;
    qcz: TEdit;
    cbz: TCheckBox;
    qbz: TEdit;
    Cqq: TCheckBox;
    Czq: TCheckBox;
    zq: TDateTimePicker;
    qq: TDateTimePicker;
    GroupBox1: TGroupBox;
    DBGrid5: TDBGrid;
    bprint: TBitBtn;
    breturn: TBitBtn;
    Bquery: TBitBtn;
    bprintc: TBitBtn;
    bsh: TBitBtn;
    bfs: TBitBtn;
    bquerys: 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 DBGrid5DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure DBGrid5TitleClick(Column: TColumn);
    procedure bshClick(Sender: TObject);
    procedure bquerysClick(Sender: TObject);
    procedure bfsClick(Sender: TObject);
    procedure bprintcClick(Sender: TObject);
  private
    { Private declarations }
      rzczy,rzsj,rzjsj,rzcsj:string;
      errzt: integer;
      errcode:boolean;
  commandstring,commandstringq: string;
  public
    { Public declarations }
      returncs:integer;
  end;

var
  Frmddchsh: TFrmddchsh;

implementation

uses unit28, Unit1, Unit16, func;

{$R *.dfm}

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

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

procedure TFrmddchsh.FormActivate(Sender: TObject);
var
commandstring,relation,cx,str:string;
begin
rzjsj:=datetimetostr(now);
rzczy:=form1.StatusBar1.Panels[4].Text;
rzsj:='订单出货审核';
qq.DateTime:=date-30;
zq.DateTime:=date;
help.Caption:='';
help.Caption:='  请您点击<查询>按钮开始查询订单出货记录!';
end;

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

procedure TFrmddchsh.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
 relation:=' like ''';
    cx:='%';
commandstring:='select * from dbo.ddchb';
commandtring1:='select * from dbo.ddchb';
  try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;

if (trim(qcl.Text)<>'') and (ccl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end;
end
else
begin
qcl.Text:='';
end;
if (trim(qcz.Text)<>'') and (ccz.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end;
end
else
begin
qcz.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if  commandstring=commandtring1 then
  begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddchb.shbj'+relation+cx+'0'+cx+''')';
end
else
begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.shbj'+relation+cx+'0'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,xh';
commandstringq:=commandstring;
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstring;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
help.Caption:='   查询完毕,要修改订单出货记录请用鼠标双击该订单出货记录所在的行!';
pz.Enabled:=true;
except
DataModule1.clientdataset19.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmddchsh.DBGrid5DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
 if DataModule1.ClientDataSet19.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 TFrmddchsh.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.ClientDataSet19.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet19.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;

procedure TFrmddchsh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
  begin
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
 relation:=' = ''';
 cx:='';
 dx:= ' ''';
try
DataModule1.ClientDataSet19.Edit;
if DataModule1.ClientDataSet19.FieldByName('shbj').AsInteger=0 then
  begin
sqlstr:='update dbo.ddchb 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.ClientDataSet19.FieldByName('ddh').AsString+cx+''')';
sqlstr:=sqlstr+' and (xh' +relation+cx+DataModule1.ClientDataSet19.FieldByName('xh').AsString+cx+''')';
DataModule1.ClientDataSet19.CommandText:=sqlstr;
DataModule1.ClientDataSet19.Execute;
DataModule1.ClientDataSet19.ApplyUpdates(-1);
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstringq;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
 help.Caption:= '数据审核成功!';
 end;
 except
 DataModule1.clientdataset19.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
end;

procedure TFrmddchsh.bquerysClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
 relation:=' like ''';
    cx:='%';
commandstring:='select * from dbo.ddchb';
commandtring1:='select * from dbo.ddchb';
  try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.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.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;

if (trim(qcl.Text)<>'') and (ccl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.sl'+relation+cx+trim(qcl.Text)+cx+''')';
end;
end
else
begin
qcl.Text:='';
end;
if (trim(qcz.Text)<>'') and (ccz.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.czl'+relation+cx+trim(qcz.Text)+cx+''')';
end;
end
else
begin
qcz.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddchb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if  commandstring=commandtring1 then
  begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddchb.shbj'+relation+cx+'1'+cx+''')';
end
else
begin
    relation:=' = ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddchb.shbj'+relation+cx+'1'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,xh';
commandstringq:=commandstring;
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstring;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
help.Caption:='   查询完毕,要修改订单出货记录请用鼠标双击该订单出货记录所在的行!';
except
DataModule1.clientdataset19.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmddchsh.bfsClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
  begin
if not DataModule1.ClientDataSet19.Active then exit;
if DataModule1.ClientDataSet19.RecordCount<1 then exit;
 relation:=' = ''';
 cx:='';
 dx:= ' ''';
try
DataModule1.ClientDataSet19.Edit;
if DataModule1.ClientDataSet19.FieldByName('shbj').AsInteger=1 then
  begin
sqlstr:='update dbo.ddchb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'0'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (ddh' +relation+cx+DataModule1.ClientDataSet19.FieldByName('ddh').AsString+cx+''')';
sqlstr:=sqlstr+' and (xh' +relation+cx+DataModule1.ClientDataSet19.FieldByName('xh').AsString+cx+''')';
DataModule1.ClientDataSet19.CommandText:=sqlstr;
DataModule1.ClientDataSet19.Execute;
DataModule1.ClientDataSet19.ApplyUpdates(-1);
DataModule1.ClientDataSet19.DisableControls;
DataModule1.ClientDataSet19.Close;
DataModule1.ClientDataSet19.CommandText:=commandstringq;
DataModule1.ClientDataSet19.Open;
DataModule1.ClientDataSet19.EnableControls;
 help.Caption:= '数据审核成功!';
 end;
 except
 DataModule1.clientdataset19.EnableControls;
 help.Caption:= '数据审核失败!';
 end;
end;

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

end.

⌨️ 快捷键说明

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