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

📄 u_form_accidentbill.~pas

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

interface

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

type
  TForm_AccidentBill = class(TForm)
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Edit1: TEdit;
    MakeDate: TMaskEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    Edit2: TEdit;
    OutDate: TMaskEdit;
    ComboBox4: TComboBox;
    ComboBox5: TComboBox;
    Grid1: TEasyGrid;
    OpenDate: TDateTimePicker;
    OpenDate1: TDateTimePicker;
    GroupBox1: TGroupBox;
    BtnSave: TButtonExCtl;
    BtnExit: TButtonExCtl;
    BtnEdit: TButtonExCtl;
    BtnDel: TButtonExCtl;
    Label11: TLabel;
    Edit3: TEdit;
    Label1: TLabel;
    Edit4: TEdit;
    Label12: TLabel;
    ComboBox6: TComboBox;
    Label13: TLabel;
    ComboBox7: TComboBox;
    Label14: TLabel;
    Edit5: TEdit;
    Label15: TLabel;
    ComboBox8: TComboBox;
    Label16: TLabel;
    Edit6: TEdit;
    ButtonExCtl1: TButtonExCtl;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure BtnExitClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure OpenDateCloseUp(Sender: TObject);
    procedure OpenDate1CloseUp(Sender: TObject);
    procedure BtnSaveClick(Sender: TObject);
    procedure Grid1DblClick(Sender: TObject);
    procedure BtnEditClick(Sender: TObject);
    procedure BtnDelClick(Sender: TObject);
    procedure ButtonExCtl1Click(Sender: TObject);
  private
    { Private declarations }
    _Adosale:TuAdoSet;
    _AdoNewproduce:TuAdoSet;
    _Check:TCheckValidate;
    _str:TuString;
  public
    { Public declarations }
  end;

var
  Form_AccidentBill: TForm_AccidentBill;
  F_BillCode:string;
  F_BoxNum:integer;
  F_BottleNum:integer;
  F_ProductName:string;
  F_Specification:string;
  F_UnitName:string;
implementation

uses U_Form_MainMenu,uGlobal,U_Form_AccidentBillFind;

{$R *.dfm}

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

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

procedure TForm_AccidentBill.FormCreate(Sender: TObject);
var
    param:TStringlist;
    strsql:string;
    i:integer;
    _RsCount:integer;
    _BillCode:string;
begin

    _Adosale:=TuAdoSet.Create('newsale',1);
    _AdoNewproduce:=TuAdoSet.Create('newproduce',1);
    _Check:=TCheckValidate.create;
    _str:=TuString.Create;

    MakeDate.Text:=formatDateTime('yyyy-mm-dd',now);
    OutDate.Text:=formatDateTime('yyyy-mm-dd',now);
    OpenDate.Date:=strTodate(formatDateTime('yyyy-mm-dd',now));
    OpenDate1.Date:=strToDate(formatDateTime('yyyy-mm-dd',now));

    combobox5.Text:=trim(_StoreMan);

    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('桶');

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

    

    grid1.Cells[1,1].ForeText:='编号';
    grid1.ColWidths[1]:=120;
    grid1.Cells[2,1].ForeText:='开票日期';
    grid1.ColWidths[2]:=120;

    grid1.Cells[3,1].ForeText:='单位名称';
    grid1.ColWidths[3]:=120;

    grid1.Cells[4,1].ForeText:='产品名称';
    grid1.ColWidths[4]:=110;
    grid1.Cells[5,1].ForeText:='规格';
    grid1.ColWidths[5]:=70;
    grid1.Cells[6,1].ForeText:='包装';
    grid1.ColWidths[6]:=70;
    grid1.Cells[7,1].ForeText:='整箱数';
    grid1.ColWidths[7]:=70;
    grid1.Cells[8,1].ForeText:='整瓶数';
    grid1.ColWidths[8]:=70;
    grid1.Cells[9,1].ForeText:='出库日期';
    grid1.ColWidths[9]:=120;
    grid1.Cells[10,1].ForeText:='酒库名称';
    grid1.ColWidths[10]:=80;
    grid1.Cells[11,1].ForeText:='保管员';

    for i:=1 to grid1.ColCount-1 do
    begin
         grid1.Cells[i,1].Color:=rgb(51,51,255);
         grid1.Cells[i,1].FontColor:=rgb(255,255,255);
    end;///
    {/*
        在表格中显示数据//////////////////////
    */}
    param.Clear;

    param.Add('0');
    param.Add(_whichStore);
    param.Add(trim(outDate.Text)); 
    strSql:='select sampleBillCode,sampleBillDate,TraderName,productName,specification,UnitName,productNum,bottleNum,OutStoreTime,';
    strSql:=strSql+'WhichStore,worker  from  sale_newsample_Accident  where   isCancel=:s2  and  whichStore=:s3  and  OutStoreTime=:s4';
    _AdoNewproduce.BindToGrid(grid1,strSql,param);

    combobox4.Items.Clear;
    if trim(_whichStore)='B'  then
    begin
       combobox4.Text:='一线酒库';
    end;
     if trim(_whichStore)='C'  then
    begin
       combobox4.Text:='二线酒库';
    end;
     if trim(_whichStore)='D'  then
    begin
       combobox4.Text:='三线酒库';
    end;
     if trim(_whichStore)='A'  then
    begin
       combobox4.Text:='高档酒库';
    end;
    {/*
       自动计算编号

    param.Clear;
    param.Add('SG');
    param.Add(_whichStore);
    param.add(trim(outDate.text));
    strSql:='select * from  sale_newSample  where substring(sampleBillCode,1,2)=:s1  ';
    strsql:=strsql+' and  whichStore=:s2  and  OutStoreTime=:s3';
    _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:='SG'+trim(FormatdateTime('yyyymmdd',now))+trim(_BillCode);
    */}
    edit2.text:='0';
    edit3.text:='0';
end;

procedure TForm_AccidentBill.OpenDateCloseUp(Sender: TObject);
begin
     MakeDate.Text:=formatDateTime('yyyy-mm-dd',openDate.Date);
end;

procedure TForm_AccidentBill.OpenDate1CloseUp(Sender: TObject);
begin
      outDate.Text:=formatDateTime('yyyy-mm-dd',openDate1.Date);
end;

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

   _StoreNum:integer;
   _bottleNum:integer;

   _OrderID:integer;
   _BillCode:string;
   _RsCount:integer;
begin
   param:=TStringList.Create;
   param.Clear;
    {/*
      2008.04.09
      入库之前先检查是否进行接班任务
     */}
   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(edit1,1,'编号不能为空...') then exit;
   if not _Check.Do_Control(combobox1,1,'请选择啤酒品种...') then exit;
   if not _Check.Do_Control(combobox2,1,'请选择啤酒规格...') then exit;
   if not _Check.Do_Control(combobox3,1,'请选择啤酒包装...') then exit;
   if not _Check.Do_Control(edit2,1,'请输整箱数量,如果没有输入0...') then exit;
   if not _Check.Do_Control(edit3,1,'请输整瓶数量,如果没有输入0...') then exit;
   if not _Check.Do_Control(edit4,1,'请输入单位名称...') then exit;
   {/*
      验证输入此编号的记录是否存在
   */}
   param.clear;
   param.Add(trim(edit1.Text));
   param.Add('0');
   param.Add(trim(_whichStore)); 
   strSql:='select * from  sale_newSample_Accident  Where  sampleBillCode=:s1  and  iscancel=:s2  and  whichStore=:s3';
   if _AdoNewproduce.getRecordCount(strsql,param)>0 then
   begin
      showmessage('记录已经存在...');
      exit;
   end;
   if _str.saveMessage  then
   begin
      {/*
         将输入的数据存储到入库表中(newproduce-->sale_newSample)
      */}
      param.Clear;
      param.Add(trim(edit1.Text));                                  /////1.编号
      param.Add(trim(MakeDate.Text));                               /////2.开票日期
      param.Add(trim(combobox1.Text));                              /////3.产品名称
      param.Add(trim(combobox2.Text));                              /////4.规格
      param.Add(trim(combobox3.Text));                              /////5.包装
      param.Add(trim(edit2.Text));                                  /////6.整箱数量
      param.Add(trim(outDate.Text));                                /////7.出库日期
      param.Add(trim(combobox5.Text));                              /////8.保管员
      param.Add(_whichStore);                                       /////9.酒库名称  B:代表一线  C:二线  D:三线
      param.Add('0');                                               /////10
      param.Add(trim(edit3.text));                                  /////11.瓶数量
      param.Add(trim(edit4.text));                                  /////12.单位名称
      param.Add(trim(combobox6.text));                              /////13.责任部门
      param.Add(trim(edit6.text));                                  /////14.事故原因
      param.Add(trim(combobox7.text));                              /////15.主管签字
      param.Add(trim(edit5.text));                                  /////16。经办人
      param.Add(trim(combobox8.text));                              /////17。提货人
      strSql:='insert into sale_newSample_Accident(sampleBillCode,sampleBillDate,productName,specification,unitName,';
      strSql:=strSql+'productNum,outStoreTime,worker,whichStore,isCancel,bottleNum,TraderName,DutyDept,AccidentReason,ZhuGuanRen,JingBanRen,TiHuoRen) Values(:s1,:s2,';
      strsql:=strsql+':s3,:s4,:s5,:s6,:s7,:s8,:s9,:s10,:s11,:s12,:s13,:s14,:s15,:s16,:s17)';
      _AdoNewproduce.actionRecord(strsql,param);

      {/*
          修改库存中的库存数量
      */}
      param.Clear;
      param.Add(_whichStore);                                           /////1.添加酒库名称/////////
      param.Add(combobox1.text);                                        /////2.产品名称
      param.Add(trim(combobox2.text));                                  /////3.规格//////
      param.Add(trim(combobox3.text));                                  /////4.包装//////////

      strSql:='select *  from  sale_storage Where  WhichStore=:s1  and  ';
      strsql:=strsql+' produceName=:s2 and Specification=:s3  and  UnitName=:s4';

      if _AdoNewproduce.getRecordCount(strsql,param)>0 then
      begin
        {/*
            首先得到原来库存的数量,然后存储到_StoreNum变量中
         */}
         param.clear;                                            ////清除查询条件
         param.Add(_whichStore);                                 ////1.添加酒库名称/////////
         param.Add(combobox1.text);                              ////2.产品名称
         param.Add(trim(combobox2.text));                        ////3.规格//////
         param.Add(trim(combobox3.text));

         strSql:='select *  from  sale_Storage Where  WhichStore=:s1  and  ';
         strsql:=strsql+' produceName=:s2 and Specification=:s3  and  UnitName=:s4';

        _StoreNum:=_AdoNewProduce.getFieldValue(strsql,param,'boxNum');
        _bottleNum:=_AdoNewProduce.getFieldValue(strsql,param,'bottleNum');
        {/*
            修改sale_Storage库存中的数量
        */}
        param.clear;
        param.Add(inttostr(_StoreNum-strtoint(edit2.text)));           ////1.修改整箱数量
        param.Add(inttostr(_bottleNum-strtoint(edit3.text)));          ////2.修改整瓶数量
        param.Add(_whichStore);                                        ////3.添加酒库名称/////////
        param.Add(combobox1.text);                                     ////4.产品名称
        param.Add(trim(combobox3.text));                               ////5.规格//////
        param.Add(trim(combobox2.text));                               ////6.包装//////////

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

⌨️ 快捷键说明

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