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

📄 f_manoeuvre.pas

📁 仓库管理系统 仓库管理系统
💻 PAS
字号:
unit f_manoeuvre;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, DB, ADODB, StdCtrls, ExtCtrls, Grids, DBGrids, Buttons,
  DBCtrls, Mask, DBGridEh, ppPrnabl, ppClass, ppCtrls, ppDB, ppBands,
  ppCache, ppProd, ppReport, ppComm, ppRelatv, ppDBPipe;

type
  Tdfmmanoeuvre = class(TForm)
    StatusBar1: TStatusBar;
    Panel2: TPanel;
    DataSource1: TDataSource;
    ATblstointemp: TADOTable;
    delbtn: TBitBtn;
    postbtn: TBitBtn;
    DataSource2: TDataSource;
    Atblbranch: TADOTable;
    ATblspec: TADOTable;
    DataSource3: TDataSource;
    DataSource4: TDataSource;
    AQryware: TADOQuery;
    cancelbtn: TBitBtn;
    BitBtn1: TBitBtn;
    ADOQuery1: TADOQuery;
    ADOQuery4: TADOQuery;
    Atblstoin: TADOTable;
    DataSource5: TDataSource;
    Atblvstotemp: TADOTable;
    DataSource6: TDataSource;
    Atblstore: TADOTable;
    DataSource7: TDataSource;
    DataSource8: TDataSource;
    ADOTable1: TADOTable;
    Panel3: TPanel;
    Label1: TLabel;
    Label9: TLabel;
    MaskEdit1: TMaskEdit;
    ComboBox3: TComboBox;
    Panel4: TPanel;
    Label6: TLabel;
    Label8: TLabel;
    Label4: TLabel;
    Label10: TLabel;
    MaskEdit2: TMaskEdit;
    MaskEdit3: TMaskEdit;
    MaskEdit4: TMaskEdit;
    Edit2: TEdit;
    Panel1: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    DateTimePicker1: TDateTimePicker;
    Label5: TLabel;
    Label7: TLabel;
    StaticText1: TStaticText;
    atblin: TADOTable;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    ADOQuery5: TADOQuery;
    ADOTable2: TADOTable;
    DataSource9: TDataSource;
    ADOQuery6: TADOQuery;
    ADOTable3: TADOTable;
    ADOTable4: TADOTable;
    DBGridEh1: TDBGridEh;
    CheckBox1: TCheckBox;
    ppDBPipeline1: TppDBPipeline;
    ppReport1: TppReport;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand1: TppDetailBand;
    ppFooterBand1: TppFooterBand;
    ppLabel1: TppLabel;
    ppLabel2: TppLabel;
    ppLabel3: TppLabel;
    ppLabel4: TppLabel;
    ppLabel5: TppLabel;
    ppLabel6: TppLabel;
    ppLabel7: TppLabel;
    ppLabel8: TppLabel;
    ppDBText1: TppDBText;
    ppDBText2: TppDBText;
    ppDBText3: TppDBText;
    ppDBText4: TppDBText;
    ppDBText5: TppDBText;
    ppSummaryBand1: TppSummaryBand;
    ppLabel9: TppLabel;
    ppDBCalc1: TppDBCalc;
    ppDBText6: TppDBText;
    ppDBText7: TppDBText;
    ppLine1: TppLine;
    ppLine2: TppLine;
    ppLine3: TppLine;
    atblslday: TADOTable;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DataSource1StateChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure MaskEdit3Exit(Sender: TObject);
    procedure delbtnClick(Sender: TObject);
    procedure postbtnClick(Sender: TObject);
    procedure cancelbtnClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure sumno;
    procedure insumno;
    procedure FormShow(Sender: TObject);
    procedure ComboBox2Enter(Sender: TObject);
    procedure ComboBox1Enter(Sender: TObject);
    procedure ComboBox3Enter(Sender: TObject);
    procedure appstore;
    procedure delstore;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dfmmanoeuvre: Tdfmmanoeuvre;
  ina,fst:string;

implementation

uses dbmRainbowMis, chHeadUnit;

{$R *.dfm}

procedure Tdfmmanoeuvre.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ADOTable4.Close;
  ATblstointemp.Active := false;
  Atblbranch.Active := false;
  ATblspec.Active := false;
  Atblstore.Active := false;
  Atblstoin.active := false;
  ADOTable2.Active := false;
  ADOTable1.Close;
  action:=cafree;
end;

procedure Tdfmmanoeuvre.DataSource1StateChange(Sender: TObject);
begin
    case ATblstointemp.State of
      dsbrowse:
        begin
          delbtn.Enabled :=true;
          cancelbtn.Enabled :=false;
        end;
      dsinsert:
        begin
          delbtn.Enabled :=false;
          cancelbtn.Enabled :=true;
        end;
      dsedit:
        begin
          delbtn.Enabled :=false;
          cancelbtn.Enabled :=true;
        end;
    end;
end;

procedure Tdfmmanoeuvre.FormCreate(Sender: TObject);
begin
  fst := ExtractFilePath(Application.ExeName);
  DateTimePicker1.Date:=date();
  ATblstointemp.Active := true;
  Atblbranch.Active := true;
  ATblspec.Active := true;
  Atblstore.Active := true;
  Atblstoin.active := true;
  ADOTable4.open;
  ADOTable1.Open;
  ADOTable2.Open;
  chHeadunit.combolist(combobox1,Atblbranch,'bmh','bmmc',1);
  chHeadunit.combolist(combobox2,Atblbranch,'bmh','bmmc',1);     
  combobox2.Text:=dmRainbowMIS.atbldefault['cbmh'];
  combobox3.Text:=dmRainbowMIS.atbldefault['clabel'];  
end;

procedure Tdfmmanoeuvre.MaskEdit3Exit(Sender: TObject);
begin
  with AQryware do
  begin
    close;
    Parameters.ParamByName ('vlabel').value:=trim(ComboBox3.text);
    Parameters.ParamByName ('vspbh').value:=trim(maskedit2.text)+trim(edit2.Text)+trim(maskedit3.text);
    open;
  end;
  if TCustomADODataSet(AQryware).RecordCount>0 then
    StaticText1.Caption :=ATblspec['cname']
  else
    StaticText1.Caption :='库存中没有此款信息!';
end;

procedure Tdfmmanoeuvre.delbtnClick(Sender: TObject);
begin
  ATblstointemp.Delete ;
end;

procedure Tdfmmanoeuvre.postbtnClick(Sender: TObject);
begin
  if not atblslday.Locate ('cdate',formatdatetime('yyyy-mm-dd',datetimepicker1.Date),[loPartialKey]) then
  begin
    with AQryware do
    begin
      close;
      Parameters.ParamByName ('vlabel').value:=trim(ComboBox3.text);
      Parameters.ParamByName ('vspbh').value:=trim(maskedit2.text)+trim(edit2.Text)+trim(maskedit3.text);
      open;
    end;
    if TCustomADODataSet(AQryware).RecordCount>0 then
    begin
      if aqryware['dqsl']-strtoint(trim(maskedit4.Text))>=0 then
      begin
        if ATblstointemp.Locate('clabel;spbh',VarArrayOf([ComboBox3.Text,trim(maskedit2.text)+trim(edit2.Text)+trim(maskedit3.text)]),[loPartialKey]) then
        begin
          ATblstointemp.Edit ;
          ATblstointemp['sl']:=ATblstointemp['sl']+maskedit4.Text;
        end
        else
        begin
          ATblstointemp.Append ;
          ATblstointemp['cstoutno']:=maskedit1.Text ;
          ATblstointemp['cinceptbra']:=ComboBox1.Text ;
          ATblstointemp['csendbra']:=ComboBox2.Text ;
          ATblstointemp['cuser']:=g_uInfo.fuserName;
          ATblstointemp['cdate']:=formatdatetime('yyyy,mm,dd',DateTimePicker1.Date); ;
          ATblstointemp['clabel']:=ComboBox3.Text;
          ATblstointemp['spbh']:=trim(maskedit2.text)+trim(edit2.Text)+trim(maskedit3.text);
          ATblstointemp['sl']:=maskedit4.Text ;
          ATblstointemp['cdbj']:=aqryware['lsj'];
          ATblstointemp['clsj']:=aqryware['lsj'];
        end;

        ATblstointemp.Post;
        ATblstointemp.Close;
        ADOTable2.Active := false;
        ATblstointemp.Open;
        ADOTable2.Open;
      end
      else
        application.messagebox('库存此款商品数量不足,无法出库','错误提示',mb_ok) ;
    end
    else
      application.messagebox('库存此款商品不存在,请重新输入','错误提示',mb_ok) ;
    maskedit2.SetFocus;
  end
  else
    application.messagebox('这个日期已日结封帐,不允许继续输入!',
        '提示信息', MB_OK)    
end;

procedure Tdfmmanoeuvre.cancelbtnClick(Sender: TObject);
begin
  ATblstointemp.Cancel ;
end;

procedure Tdfmmanoeuvre.FormKeyPress(Sender: TObject; var Key: Char);
begin
  chHeadUnit.tabventer(dfmmanoeuvre,key);
end;

procedure Tdfmmanoeuvre.sumno;
var
  n:integer;
  a:string;
begin
  if ATblstointemp.IsEmpty then
  begin
    Atblstoin.Close;
    Atblstoin.Open;
    Atblstoin.Last;
    n:=strtoint(Atblstoin['cstoutno'])+1;
    a:=inttostr(n);
    while length(a)<10 do
    begin
      a:='0'+a;
    end;
    maskedit1.Text:=a;
  end
  else
    maskedit1.Text:=ATblstointemp['cstoutno'];
end;

procedure Tdfmmanoeuvre.FormShow(Sender: TObject);
begin
  if ATblstoin.IsEmpty then
    maskedit1.Text:='0000000001'
  else
    sumno;
end;

procedure Tdfmmanoeuvre.ComboBox2Enter(Sender: TObject);
begin
//  chHeadunit.combolist(combobox1,Atblbranch,'bmh','bmmc',1);
end;

procedure Tdfmmanoeuvre.ComboBox1Enter(Sender: TObject);
begin
//  chHeadunit.combolist(combobox2,Atblbranch,'bmh','bmmc',1);
end;

procedure Tdfmmanoeuvre.ComboBox3Enter(Sender: TObject);
begin
  chHeadunit.combolist(combobox3,ADOTable1,'clabel','cfactory',1);
end;

procedure Tdfmmanoeuvre.insumno;
var
  n:integer;
begin
    atblin.Close;
    atblin.indexfieldnames:='cstinno';
    atblin.Open;
    atblin.Last;
    n:=strtoint(atblin['cstinno']);
    n:=n+1;
    ina:=inttostr(n);
    while length(ina)<10 do
    begin
      ina:='0'+ina;
    end;
end;

procedure Tdfmmanoeuvre.appstore;
var
  fstr:string;
begin
  if Application.MessageBox('你确定记录准确无误,给予审核保存吗?',
        '提示信息', MB_OKCANCEL + MB_DEFBUTTON1) = IDOK then
  begin
    insumno;
    {保存出库信息}
    ADOQuery1.ExecSQL;
    {转存为入库信息}
    fstr:='insert into t_stoin (cstinno, cdate, csendbra,cinceptbra, clabel, spbh, sl, cuser)'
       +' select ''%s'', cdate, csendbra,cinceptbra, clabel, spbh, sl, cuser from t_stoouttemp';
    with ADOQuery2 do
    begin
      close;
      sql.Clear ;
      sql.Add(Format(fstr,[ina]));
      Prepared;
      execsql;
    end;
    {更新进仓库存}
    ADOQuery3.ExecSQL;
    ADOQuery5.ExecSQL;
    {更新出仓库存}
    ADOQuery6.ExecSQL;
    if checkbox1.Checked then
    begin
      ppReport1.Print;
    end;
    ADOQuery4.ExecSQL;
    ATblstointemp.Active :=false;
    ATblstointemp.Active :=true;
    sumno;
  end;
end;

procedure Tdfmmanoeuvre.delstore;
begin
  if Application.MessageBox('你确定记录准确无误,给予审核保存吗?',
        '提示信息', MB_OKCANCEL + MB_DEFBUTTON1) = IDOK then
  begin
    ADOQuery1.ExecSQL;
    ATblstointemp.SaveToFile(fst+'dataout\'+trim(ADOTable4['cbmh'])+'db'+ATblstointemp['cstoutno']+'.dtg');
    ADOQuery6.ExecSQL;
    if checkbox1.Checked then
    begin
      ppReport1.Print;
    end;
    ADOQuery4.ExecSQL;
    ATblstointemp.Active :=false;
    ATblstointemp.Active :=true;
    sumno;
  end;
end;

procedure Tdfmmanoeuvre.BitBtn1Click(Sender: TObject);
begin
  if ATblstointemp.IsEmpty = false then
  begin
    ADOTable3.Close;
    ADOTable3.Open;
    if ADOTable3.RecordCount=1 then
    begin
      if ADOTable2['cid']='1' then
        appstore;
      if ADOTable2['cid']='0' then
        delstore;
    end
    else
      Application.MessageBox('输入记录有错,一个单据的日期,发货部门,收货部门要唯一!','提示信息', MB_OK)        
  end
  else
    Application.MessageBox('没有输入记录,无法审核!','提示信息', MB_OK);
end;

end.

⌨️ 快捷键说明

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