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

📄 u_form_producestock_tk1.pas

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

interface

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

type
  TForm_ProduceStock_TK1 = class(TForm)
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label1: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Edit1: TEdit;
    beginDate: TMaskEdit;
    _beginDate: TDateTimePicker;
    beginTime: TDateTimePicker;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    Edit2: TEdit;
    BtnFind: TButtonExCtl;
    ButtonExit: TButtonExCtl;
    Grid1: TEasyGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ButtonExitClick(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure BtnFindClick(Sender: TObject);
  private
    { Private declarations }
    _AdoNewProduce:TuAdoSet;
    _Adosale:TuAdoSet;
    _Check:TCheckValidate;
    _str:TuString;
  public
    { Public declarations }
  end;

var
  Form_ProduceStock_TK1: TForm_ProduceStock_TK1;

implementation

{$R *.dfm}
uses uGlobal, U_Form_ProduceStock_TK;
procedure TForm_ProduceStock_TK1.FormCreate(Sender: TObject);
begin
     _AdoNewProduce:=TuAdoSet.Create('newProduce',1);
     _Adosale:=TuAdoSet.Create('newsale',1);
     _Check:=TCheckValidate.create;
     _str:=TuString.Create;
     
     with _AdoNewProduce do
     begin
         setGridTitle(grid1,1,'单据号',120);
         setGridTitle(grid1,2,'退库日期',120);
         setGridTitle(grid1,3,'退库时间',120);
         setGridTitle(grid1,4,'产品名称',140);
         setGridTitle(grid1,5,'规格',80);
         setGridTitle(grid1,6,'单位',80);
         setGridTitle(grid1,7,'成套数',90);

     end;
end;

procedure TForm_ProduceStock_TK1.FormShow(Sender: TObject);
var
   param:TStringList;
   strSql:string;
   _RsCount:integer;
   _billcode:string;
begin
     param:=TStringList.Create;
     param.Clear;
     {/*
         计算倒箱前的编号
     */}
     param.clear;
     param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
     param.Add(trim(_whichStore));
     strSql:='select * from  sale_IntoStore_TK  where  SIT_intoDate=:s1  and  SIT_whichStore=:s2';
     _RsCount:=_AdoNewProduce.getRecordCount(strSql,param);
     if  (_RsCount>=0) and (_RsCount<9) then
     begin
        _BillCode:='00'+intToStr(_RsCount+1)
     end;
     if  (_RsCount>=9) and (_RsCount<99) then
     begin
        _BillCode:='0'+intToStr(_RsCount+1)
     end;
     if  (_RsCount>=99) and (_RsCount<999) then
     begin
        _BillCode:=intToStr(_RsCount+1)
     end;
     edit1.Text:='TK'+trim(FormatdateTime('yyyymmdd',now))+'_'+trim(_whichStore)+trim(_BillCode);
     {/*
     */}
     beginDate.Text:=trim(formatDateTime('yyyy-mm-dd',now));
     beginTime.Time:=strToDateTime(trim(formatDateTime('hh:mm:ss',now)));

    

     combobox1.Text:=trim(TK_produceName);
     combobox2.Text:=trim(TK_specification);
     combobox3.Text:=trim(TK_unitName);
     edit2.Text:=trim(TK_boxNum);
end;

procedure TForm_ProduceStock_TK1.ButtonExitClick(Sender: TObject);
begin
     EnableWindow(Form_produceStock_TK.Handle,true);
     Close;
end;

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

procedure TForm_ProduceStock_TK1.BtnFindClick(Sender: TObject);
var
   param:TStringList;
   strSql:string;

   _boxNum,_boxNum1:integer;
   _RSCount:integer;
   _Billcode:string;
begin
   param:=TStringList.Create;
   param.Clear;
   {/*
      2008.06.06
      倒箱入库之前先检查是否进行接班任务
   */}
   param.clear;
   param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
   param.add('1');
   param.add(trim(_whichStore));
   strsql:='select * from  sale_followStore_Flag   where  SF_CheckDate=:s1 and  SF_Flag=:s2  and  SF_whichStore=:s3';
   if _AdoNewProduce.getRecordCount(strsql,param)<=0 then
   begin
      showmessage('请首先进行接班库存盘点工作,然后在进行其他操作...');
      exit;
   end;
   {/*
      存盘前验证输入数据
   */}
   if not _check.Do_Control(edit2,1,'请输入要退库的数量...') then exit;
   if _str.saveMessage   then
   begin
      {/*
          查询当前编号的记录是否存在
      */}
      param.clear;
      param.Add(trim(_whichStore));
      param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
      strsql:='select * from  sale_IntoStore_TK where SIT_whichStore=:s1  and  SIT_IntoDate=:s2';
      if _adonewproduce.getRecordCount(strsql,param)>0 then
      begin
         showmessage('此编号的退库记录已经存在...');
         exit;
      end;
      {/*
          首先将退回记录存储到表newproduce-->sale_IntoStore_TK中

          
      */}
      param.clear;
      param.Add(trim(edit1.text));
      param.Add(trim(beginDate.text));
      param.Add(trim(TimeTostr(beginTime.Time)));
      param.Add(trim(combobox1.text));
      param.Add(trim(combobox2.text));
      param.Add(trim(combobox3.text));
      param.Add(trim(edit2.text));
      param.Add('0');
      param.Add('0');
      param.Add(trim(_whichStore));
      param.Add(trim(_StoreMan));
      strSql:='insert into sale_IntoStore_TK(SIT_IntoBillCode,SIT_IntoDate,SIT_IntoTime,SIT_productName,SIT_specification,SIT_unitName,';
      strSql:=strSql+'SIT_productNum,SIT_EmptyBoxNum,SIT_bottleNum,SIT_whichStore,SIT_StoreMan) Values(:s1,:s2,:s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10,:s11)';
      _AdoNewproduce.actionRecord(strsql,param);
    end;///if save
    {/*
      (一)更改库存记录
    */}
    param.Clear;
    param.Add(_whichStore);                                                          /////1.添加酒库名称/////////
    param.Add(combobox1.text);                                                       /////2.产品名称
    param.Add(trim(combobox3.text));                                                 /////3.包装//////
    param.Add(trim(combobox2.text));
    strSql:='select *  from  sale_Storage Where  WhichStore=:s1  and  ';
    strsql:=strsql+' produceName=:s2  and  UnitName=:s3  and Specification=:s4';
    if _AdoNewproduce.getRecordCount(strsql,param)>0 then
    begin
        {/*
            品种存在,首先得到原来库存的数量,然后存储到_StoreNum变量中
         */}
         param.clear;                                                               ////清除查询条件
         param.Add(_whichStore);                                                    ////1.添加酒库名称/////////
         param.Add(combobox1.text);                                                 ////2.产品名称
         param.Add(trim(combobox3.text));                                           ////3.规格//////
         param.Add(trim(combobox2.text));                                           ////4.包装//////////

         strSql:='select *  from  sale_Storage Where  WhichStore=:s1  and  ';
         strsql:=strsql+' produceName=:s2  and  UnitName=:s3  and Specification=:s4';
         _boxNum:=_AdoNewProduce.getFieldValue(strsql,param,'boxNum');              /////得到成套数量

         //showmessage(inttostr(_storeNum));
         {/*
             修改sale_storage库存中的数量,使库存中倒箱前的产品数量减少
         */}
         param.clear;
         param.Add(inttostr(_boxNum-strtoint(edit2.text)));                         ////1.修改整箱数量
         param.Add(_whichStore);                                                    ////2.添加酒库名称/////////
         param.Add(combobox1.text);                                                 ////3.产品名称
         param.Add(trim(combobox3.text));                                           ////4.规格//////
         param.Add(trim(combobox2.text));                                           ////5.包装//////////

        strSql:='update sale_Storage set boxNum=:s1  Where  WhichStore=:s2  ';
        strsql:=strsql+' and  produceName=:s3  and  UnitName=:s4 and Specification=:s5';
        _AdoNewProduce.actionRecord(strSql,param);

     end; ////以上品种存在则,以下是品种不存在则添加
     showmessage('退库成功...');
     {/*
         在表格中显示退库记录
     */}
     param.Clear;
     param.Add(trim(beginDate.text));
     param.Add(trim(_whichStore));
     strsql:='select SIT_IntoBillCode,SIT_IntoDate,SIT_IntoTime,SIT_productName,SIT_specification,SIT_unitName,';
     strsql:=strsql+'SIT_productNum from  sale_IntoStore_TK  where  SIT_intodate=:s1  and  SIT_whichStore=:s2 order by SIT_IntoBillCode';
     _AdoNewproduce.BindToGrid(grid1,strsql,param);
     grid1.Refresh;
     {/*
        清空控件内容
     */}
     {/*
         计算退库的编号
     */}
     param.clear;
     param.Add(trim(formatDateTime('yyyy-mm-dd',now)));
     param.Add(trim(_whichStore));
     strSql:='select * from  sale_IntoStore_TK  where  SIT_intoDate=:s1  and  SIT_whichStore=:s2';
     _RsCount:=_AdoNewProduce.getRecordCount(strSql,param);
     if  (_RsCount>=0) and (_RsCount<9) then
     begin
        _BillCode:='00'+intToStr(_RsCount+1)
     end;
     if  (_RsCount>=9) and (_RsCount<99) then
     begin
        _BillCode:='0'+intToStr(_RsCount+1)
     end;
     if  (_RsCount>=99) and (_RsCount<999) then
     begin
        _BillCode:=intToStr(_RsCount+1)
     end;
     edit1.Text:='TK'+trim(FormatdateTime('yyyymmdd',now))+'_'+trim(_whichStore)+trim(_BillCode);

     combobox1.Text:='';
     combobox2.Text:='';
     combobox3.Text:='';
     edit2.Text:='0';
end;

end.

⌨️ 快捷键说明

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