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

📄 u_form_initstorage.pas

📁 这是一个啤酒行业的软件
💻 PAS
字号:
unit U_Form_InitStorage;

interface

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

type
  TForm_InitStorage = class(TForm)
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Grid1: TEasyGrid;
    BtnSave: TButtonExCtl;
    BtnExit: TButtonExCtl;
    BtnFind: TButtonExCtl;
    Label3: TLabel;
    beginDate: TMaskEdit;
    _beginDate: TDateTimePicker;
    Label1: TLabel;
    GroupBox3: TGroupBox;
    Label4: TLabel;
    ComboBox1: TComboBox;
    Label5: TLabel;
    ComboBox2: TComboBox;
    Label6: TLabel;
    ComboBox3: TComboBox;
    Label7: TLabel;
    Edit2: TEdit;
    Label8: TLabel;
    Edit3: TEdit;
    Label2: TLabel;
    Edit1: TEdit;
    Label9: TLabel;
    Edit4: TEdit;
    Label10: TLabel;
    Edit5: TEdit;
    ButtonExCtl1: TButtonExCtl;
    ButtonExCtl2: TButtonExCtl;
    ButtonExCtl3: TButtonExCtl;
    ButtonExCtl4: TButtonExCtl;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure BtnExitClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BtnFindClick(Sender: TObject);
    procedure Grid1KeyPress(Sender: TObject; var Key: Char);
    procedure BtnSaveClick(Sender: TObject);
    procedure _beginDateCloseUp(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ButtonExCtl1Click(Sender: TObject);
    procedure ButtonExCtl4Click(Sender: TObject);
  private
    { Private declarations }
    _AdoNewProduce:TuAdoSet;
    _Adosale:TuAdoSet;
    _Check:TCheckValidate;
    _str:TuString;
  public
    { Public declarations }
  end;

var
  Form_InitStorage: TForm_InitStorage;

implementation

uses U_Form_MainMenu,uGlobal,U_Form_InitStorageFind,U_Form_InitStorage_SUB;

{$R *.dfm}

procedure TForm_InitStorage.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
      EnableWindow(Form_MainMenu.Handle,true);
      CanClose:=true;
end;

procedure TForm_InitStorage.BtnExitClick(Sender: TObject);
begin
     EnableWindow(Form_MainMenu.Handle,true);
     Close;
end;

procedure TForm_InitStorage.FormCreate(Sender: TObject);
var
   param:TStringList;
   strsql:string;
   
begin

    _AdoNewProduce:=TuAdoSet.Create('newProduce',1);
     _Adosale:=TuAdoSet.Create('newsale',1);

    _Check:=TCheckValidate.create;
    _str:=TuString.Create;



     with _AdoNewProduce do
     begin
         setGridTitle(grid1,1,'序号',60);
         setGridTitle(grid1,2,'产品名称',140);
         setGridTitle(grid1,3,'规格',80);
         setGridTitle(grid1,4,'单位',80);
         setGridTitle(grid1,5,'成套数',90);
         setGridTitle(grid1,6,'空箱数',80);
         setGridTitle(grid1,7,'整瓶数',100);
         setGridTitle(grid1,8,'酒库名称',80);
     end;



     beginDate.Text:=formatDateTime('yyyy-mm-dd',now);
     _beginDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));

    param:=TStringList.Create;
    param.clear;
    strsql:='select wareTypeName from  saleArea_tmp order By orderCode';
    _Adosale.FillControl(combobox1,strsql,param,'wareTypeName');


      ///////添加规格/////////////////////////////
    combobox2.Items.Add('24');
    combobox2.Items.Add('15');
    combobox2.Items.Add('12');
    combobox2.Items.Add('10');
    combobox2.Items.Add('8');
    combobox2.Items.Add('6');
    combobox2.Items.Add('9');

    ///////添加包装//////////////
    combobox3.Items.Add('塑箱');
    combobox3.Items.Add('塑包');
    combobox3.Items.Add('纸箱');
    combobox3.Items.Add('千升');
    combobox3.Items.Add('桶');

    edit2.text:='0';
    edit3.text:='0';
    edit5.text:='0';
end;

procedure TForm_InitStorage.BtnFindClick(Sender: TObject);
var
   param:TStringList;
   strsql:string;
   i:integer;
begin
   param:=TStringList.Create;
   param.clear;
   {/*
       开始检索数据 ,fxdgdfg
   */}
   param.Add(_whichStore);
   strSql:='select  OrderID,ProduceName,specification,UnitName  from  sale_Storage  Where  whichStore=:s1  order by  OrderID';
   _AdoNewproduce.BindToGrid(grid1,strsql,param);
   grid1.Colcount:=9;
   with _AdoNewProduce do
   begin
         setGridTitle(grid1,1,'序号',60);
         setGridTitle(grid1,2,'产品名称',140);
         setGridTitle(grid1,3,'规格',80);
         setGridTitle(grid1,4,'单位',80);
         setGridTitle(grid1,5,'成套数',90);
         setGridTitle(grid1,6,'空箱数',80);
         setGridTitle(grid1,7,'整瓶数',100);
         setGridTitle(grid1,8,'酒库名称',80);
   end;
   for i:=2 to grid1.RowCount-2 do
   begin
       grid1.cells[8,i].ForeText:=trim(_whichStore);
   end;
   grid1.Refresh;
    
end;

procedure TForm_InitStorage.Grid1KeyPress(Sender: TObject; var Key: Char);
begin
     if key=#13 then
     begin
        if grid1.row<grid1.RowCount-2 then
        begin
           grid1.row:=grid1.row+1;
           
        end;
     end;
end;

procedure TForm_InitStorage.BtnSaveClick(Sender: TObject);
var
   param:TStringList;
   strsql:string;

   _begindate:string;
    _endDate:string;
   i:integer;
   _Checkdate:string;


begin
   param:=TStringList.Create;
   param.Clear;
   _beginDate:= trim(begindate.text)+' 00:00:00';
   _endDate:= trim(begindate.text)+' 23:59:59';

   //showmessage(_loginName);

   {/*
      验证当天的接班数据是否存在
    */}
    param.Clear;
    param.Add(trim(_beginDate));
    param.Add(trim(_endDate));
    param.Add(_whichStore);
    strsql:='select * from  sale_followStore  where  (SF_Checkdate>=:s1  and  SF_Checkdate<=:s2)  and  SF_whichStore=:s3 ';
    if _AdoNewproduce.getRecordCount(strsql,param)>0 then
    begin
         showmessage('当天的接班库存已经存在...');
         exit;
    end;

   {/*
      存盘操作
   */}
   if _str.saveMessage then
   begin
      {/*
          接班盘点数据与交班盘点数据进行核对,
          正常   :数据完全一致
          不正常 :数据对不匹配
      */}
      
      {/*
         验证在sale_followStore_flag中是否存在接班信息,如果存在说明已经存过盘
         不能再存盘了
      */}
      param.Clear;
      param.Add(trim(beginDate.text));
      param.Add(_whichStore);
      strsql:='select * from  sale_followStore_flag where  SF_CheckDate=:s1  and  SF_WhichStore=:s2';
      if _AdoNewProduce.getRecordCount(strsql,param)>0 then
      begin
         showmessage('接班库存已经盘点完成,不能在存盘...');
         exit;
      end;
      _CheckDate:=trim(begindate.text)+' '+trim(formatDateTime('hh:mm:ss',now));

      {/*
         进行存盘操作,将早晨接班盘点库存存入接班库存表newproduce-->sale_followStore
         这个表是每天的接班盘点表,sale_storage表是查询中间的一个表,每天库存盘点结束
         后sale_storage表清零
      */}
      for i:=2 to grid1.RowCount-2 do
      begin
          param.clear;
          param.Add(trim(grid1.cells[1,i].foretext));           ///1.
          param.Add(trim(grid1.cells[2,i].foretext));           ///2.
          param.Add(trim(grid1.cells[3,i].foretext));           ///3.
          param.Add(trim(grid1.cells[4,i].foretext));           ///4.
          if grid1.cells[5,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[5,i].foretext));        ///5.
          end
          else
             param.Add('0');

          if grid1.cells[6,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[6,i].foretext));        ///6.
          end
          else
             param.Add('0');

          if grid1.cells[7,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[7,i].foretext));        ///7.
          end
          else
             param.Add('0');
          param.Add(trim(grid1.cells[8,i].foretext));           ///8.
          param.Add(trim(_CheckDate));                          ///9.
          param.Add(trim(_LoginName));                          ///10.


          strsql:='insert into  sale_followStore(SF_OrderID,SF_produceName,SF_specification,SF_UnitName,';
          strsql:=strsql+'SF_boxNum,SF_EmptyBoxNum,SF_bottleNum,SF_WhichStore,SF_CheckDate,SF_StoreMan) Values(:s1,';
          strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10)';
          _AdoNewProduce.actionRecord(strsql,param);
      end;//for i
      {/*
          修改交班库存数量sale_handStore表,而这个表是中间的一个存放当天库存的表
          入库,付出酒都修改这个表,然后库存盘点完后将sale_handStore表的数据存储
          到日库存盘点表sale_CheckStore中,最后将sale_handStore 表清零
      */}
      for i:=2 to grid1.RowCount-2 do
      begin
          param.clear;
          param.Add(trim(grid1.cells[1,i].foretext));
          param.Add(trim(grid1.cells[2,i].foretext));
          param.Add(trim(grid1.cells[3,i].foretext));
          param.Add(trim(grid1.cells[4,i].foretext));
          if grid1.cells[5,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[5,i].foretext));
          end
          else
             param.Add('0');
          if grid1.cells[6,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[6,i].foretext));
          end
          else
             param.Add('0');
          if grid1.cells[7,i].foretext<>'' then
          begin
             param.Add(trim(grid1.cells[7,i].foretext));
          end
          else
             param.Add('0');

          param.Add(trim(grid1.cells[8,i].foretext));
          
          strsql:='insert into  sale_handStore(SH_OrderID,SH_produceName,SH_specification,SH_UnitName,';
          strsql:=strsql+'SH_boxNum,SH_EmptyBoxNum,SH_bottleNum,SH_WhichStore) Values(:s1,';
          strsql:=strsql+':s2,:s3,:s4,:s5,:s6,:s7,:s8)';
          _AdoNewProduce.actionRecord(strsql,param);
      end;//for i

      {/*
          将接班信息存储到撒了sale_followStore_Flag中
      */}
      param.Clear;
      param.Add(trim(beginDate.text));
      param.Add('1');
      param.Add(_storeMan);
      param.Add(_whichStore);
      strsql:='insert into sale_followStore_flag(SF_CheckDate,SF_flag,SF_StoreMan,SF_WhichStore) values(:s1,:s2,:s3,:s4)';
      _AdoNewProduce.actionRecord(strsql,param);
      _str.actionOK(at_save);
      
   end;///_str.savemessage

end;

procedure TForm_InitStorage._beginDateCloseUp(Sender: TObject);
begin
      beginDate.Text:=formatDateTime('yyyy-mm-dd',_beginDate.Date);
end;

procedure TForm_InitStorage.FormShow(Sender: TObject);
var
   i,j:integer;
begin
   grid1.rowcount:=5;
   for i:=2 to grid1.rowcount-1 do
   begin
       for j:=1 to grid1.colcount-1 do
       begin
           grid1.cells[j,i].foretext:='';
       end;
   end;
   grid1.refresh;
end;

procedure TForm_InitStorage.ButtonExCtl1Click(Sender: TObject);
begin
   if Form_InitStorageFind=nil then
   begin
      EnableWindow(Form_InitStorage.Handle,false);
      Form_InitStorageFind:=TForm_InitStorageFind.Create(Application);
      Form_InitStorageFind.Show;
   end
   else
   begin
      EnableWindow(Form_InitStorage.Handle,false);
      Form_InitStorageFind.Show;
   end;
end;

procedure TForm_InitStorage.ButtonExCtl4Click(Sender: TObject);
begin
   JB_Storage_Date:=trim(beginDate.text);
   if Form_InitStorage_SUB=nil then
   begin
      EnableWindow(Form_InitStorage.Handle,false);
      Form_InitStorage_SUB:=TForm_InitStorage_SUB.Create(Application);
      Form_InitStorage_SUB.Show;
   end
   else
   begin
      EnableWindow(Form_InitStorage.Handle,false);
      Form_InitStorage_SUB.Show;
   end;
end;

end.

⌨️ 快捷键说明

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