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

📄 u_form_datacheck_2.pas

📁 这是一个啤酒行业的软件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit U_Form_DataCheck_2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, EasyGrid, StdCtrls,uAdoSet,uCheckValidate,uString, ButtonExCtl,
  ExtCtrls, Buttons;

type
  TForm_DataCheck_2 = class(TForm)
    GroupBox1: TGroupBox;
    Grid1: TEasyGrid;
    BtnFind: TButtonExCtl;
    panel1: TBitBtn;
    ButtonExCtl1: TButtonExCtl;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure BtnFindClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ButtonExCtl1Click(Sender: TObject);
  private
    { Private declarations }
    _AdoNewProduce:TuAdoSet;
    _Check:TCheckValidate;
    _str:TuString;
  public
    { Public declarations }
  end;

var
  Form_DataCheck_2: TForm_DataCheck_2;
  _boxNumSum:double;
  _bottleNumSum:double;
  _emptyBoxNumSum:double;
implementation

uses U_Form_DataCheck,uGlobal;

{$R *.dfm}

procedure TForm_DataCheck_2.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
    param:TStringList;
    strsql:string;

    _boxSum:string;
    _emptyBoxSum:string;
    _bottleSum:string;

    _Col5,_Col9:string;
begin
     param:=TStringList.create; 
     if Application.MessageBox('确定是否退出...','信息提示',MB_yesNo+MB_IconWarning)=id_yes then
     begin
        _boxSum:=trim(grid1.cells[25,grid1.rowcount-1].foretext);
        _EmptyboxSum:=trim(grid1.cells[26,grid1.rowcount-1].foretext);
        _bottleSum:=trim(grid1.cells[27,grid1.rowcount-1].foretext);

        _Col5:=trim(grid1.cells[5,grid1.rowcount-1].foretext);
        _Col9:=trim(grid1.cells[11,grid1.rowcount-1].foretext);

        if (_boxSum<>'0')  or (_bottleSum<>'0')  or (_emptyboxSum<>'0') or (grid1.RowCount<7)then
        begin
           if (_Col5='0') or (_Col9='0')  then
           begin
               {/*
                   将退出后,信息存盘到newproduce-->sale_handRealStore_flag
               */}
               param.Clear;
               param.Add('CHK_handData');
               param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
               param.Add(_whichStore);
               param.Add(trim(_boxSum));
               param.Add(trim(_bottleSum));
               param.Add('1');
               strsql:='insert into sale_handRealStore_Flag(CHK_Type,CHK_CheckDate,';
               strsql:=strsql+'CHK_whichStore,CHK_data1,CHK_data2,CHK_successFlag) Values(';
               strsql:=strsql+':s1,:s2,:s3,:s4,:s5,:s6)';
               _AdoNewproduce.actionRecord(strsql,param);

              //showmessage('对不起,数据核对工作没进行或核对错误,请核对正确后再退出');
              EnableWindow(Form_DataCheck.Handle,true);
              CanClose:=true;
           end
           else
           begin
              {/*
                   将退出后,信息存盘到newproduce-->sale_handRealStore_flag
               */}
               param.Clear;
               param.Add('CHK_handData');
               param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
               param.Add(_whichStore);
               param.Add(trim(_boxSum));
               param.Add(trim(_bottleSum));
               param.Add('1');
               strsql:='insert into sale_handRealStore_Flag(CHK_Type,CHK_CheckDate,';
               strsql:=strsql+'CHK_whichStore,CHK_data1,CHK_data2,CHK_successFlag) Values(';
               strsql:=strsql+':s1,:s2,:s3,:s4,:s5,:s6)';
               _AdoNewproduce.actionRecord(strsql,param);

              EnableWindow(Form_DataCheck.Handle,true);
              CanClose:=true;
           end;
        end
        else
        begin
           {/*
               将退出后,信息存盘到newproduce-->sale_handRealStore_flag
           */}
           param.Clear;
           param.Add('CHK_handData');
           param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
           param.Add(_whichStore);
           param.Add(trim(_boxSum));
           param.Add(trim(_bottleSum));
           param.Add('1');
           strsql:='insert into sale_handRealStore_Flag(CHK_Type,CHK_CheckDate,';
           strsql:=strsql+'CHK_whichStore,CHK_data1,CHK_data2,CHK_successFlag) Values(';
           strsql:=strsql+':s1,:s2,:s3,:s4,:s5,:s6)';
           _AdoNewproduce.actionRecord(strsql,param);

           EnableWindow(Form_DataCheck.Handle,true);
           CanClose:=true;
        end;
     end
     else
     begin
        CanClose:=false;
     end;
end;

procedure TForm_DataCheck_2.FormCreate(Sender: TObject);
var
    param:TStringList;
    strsql:string;
    i:integer;
begin
    _AdoNewProduce:=TuAdoSet.Create('newProduce',1);
    _Check:=TCheckValidate.create;
    _str:=TuString.Create;

    param:=TStringList.Create;
    param.Clear;
    grid1.RowHeights[1]:=22;
    grid1.RowHeights[2]:=22;
    grid1.RowHeights[3]:=22;
    grid1.SetMerges(rect(1,1,1,3));
    grid1.Cells[1,1].ForeText:='序号';
    grid1.ColWidths[1]:=50;

    grid1.SetMerges(rect(2,1,2,3));
    grid1.Cells[2,1].ForeText:='产品名称';
    grid1.ColWidths[2]:=120;

    grid1.SetMerges(rect(3,1,3,3));
    grid1.Cells[3,1].ForeText:='规格';
    grid1.ColWidths[3]:=60;

    grid1.SetMerges(rect(4,1,4,3));
    grid1.Cells[4,1].ForeText:='单位';
    grid1.ColWidths[4]:=60;
    {/*
       接班库存=入库
    */}
    grid1.SetMerges(rect(5,1,7,2));
    grid1.Cells[5,1].ForeText:='接班库存';
    grid1.ColWidths[5]:=70;
    grid1.cells[5,3].ForeText:='成套数';
    grid1.ColWidths[6]:=60;
    grid1.cells[6,3].ForeText:='空箱数';
    grid1.ColWidths[7]:=60;
    grid1.cells[7,3].ForeText:='瓶数';
    {/*
       当天入库数据
    */}
    grid1.SetMerges(rect(8,1,10,2));
    grid1.Cells[8,1].ForeText:='本班入库';
    grid1.ColWidths[8]:=60;
    grid1.cells[8,3].ForeText:='成套数';
    grid1.ColWidths[9]:=60;
    grid1.cells[9,3].ForeText:='空箱数';
    grid1.ColWidths[10]:=60;
    grid1.cells[10,3].ForeText:='瓶数';

    grid1.SetMerges(rect(11,1,13,2));
    grid1.Cells[11,1].ForeText:='倒箱入库';
    grid1.ColWidths[11]:=60;
    grid1.cells[11,3].ForeText:='成套数';
    grid1.ColWidths[12]:=60;
    grid1.cells[12,3].ForeText:='空箱数';
    grid1.ColWidths[13]:=60;
    grid1.cells[13,3].ForeText:='瓶数';
    {/*
       本班付出=销售开票+样品票+事故单
    */}
    grid1.SetMerges(rect(14,1,15,1));
    grid1.Cells[14,1].ForeText:='本班付出';
    grid1.SetMerges(rect(14,2,14,3));
    grid1.Cells[14,2].ForeText:='销售量';

    grid1.SetMerges(rect(15,2,16,2));
    grid1.Cells[15,2].ForeText:='样品票';
    grid1.Cells[15,3].ForeText:='成套数';
    grid1.cells[16,3].ForeText:='瓶数';

    grid1.SetMerges(rect(17,2,18,2));
    grid1.Cells[17,2].ForeText:='事故单';
    grid1.Cells[17,3].ForeText:='成套数';
    grid1.cells[18,3].ForeText:='瓶数';

    grid1.SetMerges(rect(19,2,19,3));
    grid1.Cells[19,2].ForeText:='倒箱付出';

    grid1.SetMerges(rect(20,2,22,2));
    grid1.Cells[20,2].ForeText:='退库付出';
    grid1.Cells[20,3].ForeText:='成套数';
    grid1.Cells[21,3].ForeText:='空箱数';
    grid1.cells[22,3].ForeText:='瓶数';

    {/*
       损耗数据
    */}
    grid1.SetMerges(rect(23,1,24,2));
    grid1.Cells[23,1].ForeText:='本班损耗';
    grid1.ColWidths[23]:=60;
    grid1.cells[23,3].ForeText:='空箱';
    grid1.ColWidths[24]:=80;
    grid1.cells[24,3].ForeText:='瓶损';

    {/*
       计算库存=接班库存+本班入库+倒箱入库-销售-样品票-事故单-倒箱付出-退库付出-空箱损耗-瓶损耗
    */}
    grid1.SetMerges(rect(25,1,27,2));
    grid1.Cells[25,1].ForeText:='计算库存';
    grid1.ColWidths[25]:=70;
    grid1.cells[25,3].ForeText:='成套数';
    grid1.ColWidths[26]:=60;
    grid1.cells[26,3].ForeText:='空箱数';
    grid1.ColWidths[27]:=60;
    grid1.cells[27,3].ForeText:='瓶数';

    grid1.SetMerges(rect(28,1,30,2));
    grid1.Cells[28,1].ForeText:='实际库存';
    grid1.ColWidths[28]:=70;
    grid1.cells[28,3].ForeText:='成套数';
    grid1.ColWidths[29]:=60;
    grid1.cells[29,3].ForeText:='空箱数';
    grid1.ColWidths[30]:=60;
    grid1.cells[30,3].ForeText:='瓶数';

    grid1.SetMerges(rect(31,1,33,2));
    grid1.Cells[31,1].ForeText:='库存差额';
    grid1.ColWidths[31]:=70;
    grid1.cells[31,3].ForeText:='成套数';
    grid1.ColWidths[32]:=60;
    grid1.cells[32,3].ForeText:='空箱数';
    grid1.ColWidths[33]:=60;
    grid1.cells[33,3].ForeText:='瓶数';


    for i:=1 to grid1.ColCount-1 do
    begin
        grid1.Cells[i,1].Color:=rgb(0,143,247);
        grid1.Cells[i,2].Color:=rgb(0,143,247);
        grid1.Cells[i,1].FontColor:=rgb(255,255,255);
        grid1.Cells[i,2].FontColor:=rgb(255,255,255);
        grid1.Cells[i,3].Color:=rgb(0,143,247);
        grid1.Cells[i,3].FontColor:=rgb(255,255,255);
    end;
    grid1.Refresh;
end;

procedure TForm_DataCheck_2.BtnFindClick(Sender: TObject);
var
   param:TStringList;
   strsql:string;

   _CheckDate:string;
   _PrevDate:string;

   i:integer;
   {/*
      计算库存用变量
   */}
   _Col5,_Col8,_Col11:double;
   _Col14,_Col15,_Col17,_Col19,_Col20:double;

   _Col6,_Col9,_Col12:double;
   _Col21:double;

   _Col7,_Col10,_Col13:double;
   _Col16,_Col18,_Col22,_Col24:double;


   {/*
      
   */}
   _boxNum,_bottleNum,_emptyBoxNum:integer;
   _boxNum1,_bottleNum1,_emptyBoxNum1:integer;
   _boxNum2,_bottleNum2,_emptyBoxNum2:integer;
begin
   param:=TStringList.Create;
   param.Clear;
   _CheckDate:=formatDateTime('yyyy-mm-dd',now);
   _prevDate:=formatDateTime('yyyy-mm-dd',strToDate(_CheckDate)-1);
   {/*
       执行存储过程

   param.clear;

   param.Add(trim(_CheckDate));
   param.Add(trim(_whichStore));
   strsql:='Sale_followstore_1';
   _AdoNewproduce.actionSP(strsql,param);
    */}
   panel1.Visible:=true;
   panel1.Caption:='正在进行数据统计、并进行核对,请稍等片刻...';
   {/*
       查询当天的接班数据
   */}
   for i:=4 to grid1.RowCount-2 do
   begin
      ///showmessage(_CheckDate);
      param.clear;
      param.Add(trim(_whichStore));
      param.Add(trim(_CheckDate));
      param.Add(trim(grid1.cells[2,i].foretext));
      param.Add(trim(grid1.cells[3,i].foretext));
      param.Add(trim(grid1.cells[4,i].foretext));

      strsql:='select sum(convert(real,SF_BoxNum)) as a,sum(convert(real,SF_BottleNum)) as b,sum(convert(real,SF_EmptyBoxNum)) as c from   sale_followStore_#tmp where  ';
      strsql:=strsql+'SF_whichStore=:s1  and  substring(SF_CheckDate,1,10)=:s2 and  SF_produceName=:s3 and  SF_Specification=:s4  and  SF_unitName=:s5 ';// Union  ';

      grid1.Cells[5,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'a');
      grid1.Cells[6,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'c');
      grid1.Cells[7,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'b');
   end;
   {/*
       查询本班入库数据
   */}
   for i:=4 to grid1.RowCount-2 do
   begin
       param.Clear;
       param.Add(_whichStore);
       param.Add(trim(grid1.cells[2,i].foretext));
       param.Add(trim(grid1.cells[3,i].foretext));
       param.Add(trim(grid1.cells[4,i].foretext));
       param.Add(_CheckDate);
       strsql:='select sum(convert(real,SI_productNum)) as a,sum(convert(real,SI_bottleNum)) as b,sum(convert(real,SI_EmptyBoxNum)) as c   from  Sale_intoStore   where  SI_whichStore=:s1  and  ';
       strsql:=strsql+'SI_productName=:s2 and  SI_specification=:s3  and  SI_UnitName=:s4  and  SI_intodate=:s5';
       grid1.Cells[8,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'a');
       grid1.Cells[9,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'b');
       grid1.Cells[10,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'c');
   end;
   {/*
       查询倒箱入库数据
   */}
   for i:=4 to grid1.RowCount-2 do
   begin
       param.Clear;
       param.Add(_whichStore);
       param.Add(trim(grid1.cells[2,i].foretext));
       param.Add(trim(grid1.cells[3,i].foretext));
       param.Add(trim(grid1.cells[4,i].foretext));
       param.Add(_CheckDate);
       strsql:='select sum(convert(real,SIA_productNum)) as a,sum(convert(real,SIA_bottleNum)) as b,sum(convert(real,SIA_EmptyBoxNum)) as c   from  Sale_intoStore_DX_After   where  SIA_whichStore=:s1  and  ';
       strsql:=strsql+'SIA_productName=:s2 and  SIA_specification=:s3  and  SIA_UnitName=:s4  and  SIA_intodate=:s5';
       grid1.Cells[11,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'a');
       grid1.Cells[12,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'b');
       grid1.Cells[13,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'c');
   end;
   {/*
       当天销售调票数据
   */}
   for i:=4 to grid1.RowCount-2 do
   begin
       param.Clear;
       param.Add(_whichStore);
       param.Add(trim(grid1.cells[2,i].foretext)+'∕'+'1'+'×'+trim(grid1.cells[3,i].foretext)+'--'+trim(grid1.cells[4,i].foretext));
       param.Add('1'+'×'+trim(grid1.cells[3,i].foretext));
       param.Add(trim(grid1.cells[4,i].foretext));
       param.Add(_CheckDate);

       strsql:='select sum(saleNum) as a  from  Sale_changeBill   where  whichStore=:s1  and  ';
       strsql:=strsql+'productName=:s2 and  specification=:s3  and  UnitName=:s4  and  substring(outStoreDate,1,10)=:s5';
       grid1.Cells[14,i].ForeText:=_AdoNewproduce.getFieldValue(strsql,param,'a');
    end;
    {/*
       酒库当天的样品票
    */}
   for i:=4 to grid1.RowCount-2 do
   begin

⌨️ 快捷键说明

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