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

📄 sfc_wipinvlock.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Sfc_WipInvLock;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Dialog, Db, AdODB, StdCtrls, Mask;

Type
  TFrm_Sfc_WipInvLock = Class(TFrm_Base_Dialog)
    Label1: TLabel;
    Lbl_State: TLabel;
    Label2: TLabel;
    CmBx_DeptCode: TComboBox;
    MEdt_Month: TMaskEdit;
    procedure btn_okClick(Sender: TObject);
    procedure CmBx_DeptCodeChange(Sender: TObject);
    procedure btn_CancelClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
  end;

var
  Frm_Sfc_WipInvLock: TFrm_Sfc_WipInvLock;

implementation

uses Sys_Global;

{$R *.DFM}

procedure TFrm_Sfc_WipInvLock.btn_okClick(Sender: TObject);
begin
  inherited;
  if Lbl_State.Caption<>'' then
  begin
    Close;
    Exit;
  end
  else if DispInfo('锁定月份后,该月的车间月末库存记录将不允许更改'+#13
    +#10+#13+#10+'请确认!',2)='y' then
  begin
    btn_ok.Enabled:=False;
    btn_Cancel.Enabled:=False;

    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Select InvStatus From InvStatus'
      +' Where InvStatusName=''wipInv'''
      +' And WHCode='''+GetCode(CmBx_DeptCode.Text)+'''';
    AdoQry_Tmp.Open;

    if AdoQry_Tmp.fieldbyname('InvStatus').AsString<>'' then
    begin
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Update InvStatus Set InvStatus='''+MEdt_Month.Text+''''
        +' Where InvStatusName=''wipInv'''
      +' And WHCode='''+GetCode(CmBx_DeptCode.Text)+'''';
      AdoQry_Tmp.ExecSQL;
    end
    else
    begin
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Insert InvStatus(InvStatus,InvStatusName,WHCode)'
        +' Values('
        +''''+MEdt_Month.Text+''''
        +',''wipInv'''
        +','''+GetCode(CmBx_DeptCode.Text)+''''
        +')';
      AdoQry_Tmp.ExecSQL;
    end;
    Lbl_State.Caption:='月末库存记录锁定成功';
//    btn_ok.Enabled:=True;
    btn_Cancel.Enabled:=True;
  end;
end;

procedure TFrm_Sfc_WipInvLock.CmBx_DeptCodeChange(Sender: TObject);
begin
  inherited;
  Lbl_State.Caption:='';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select InvStatus'
    +' From InvStatus'
    +' Where InvStatusName=''wipInv'''
    +' And WHCode='''+GetCode(CmBx_DeptCode.Text)+'''';
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.fieldbyname('InvStatus').AsString='' then
    MEdt_Month.Text:=FormatDateTime('yyyy.mm',Now)
  else
    MEdt_Month.Text:=FormatDateTime('yyyy.mm',IncMonth(StrToDateTime(
      AdoQry_Tmp.fieldbyname('InvStatus').AsString+'.01'),1));
  btn_ok.Enabled :=True;    
end;

procedure TFrm_Sfc_WipInvLock.SetDBConnect(AdOConnection: TAdOConnection);
var
  DeptCode:String;
begin
  inherited;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select DeptCode From Employee'
    +' Where EmployeeCode='''+UserCode+'''';
  AdoQry_Tmp.Open;
  DeptCode:=AdoQry_Tmp.fieldbyname('DeptCode').AsString;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select DeptCode+'' ''+DeptName As DeptCodeName'
    +' From Dept'
    +' Where DeptCode Like '''+DeptCode+'%''';
  AdoQry_Tmp.Open;
  while not AdoQry_Tmp.Eof do
  begin
    CmBx_DeptCode.Items.Add(AdoQry_Tmp.fieldbyname('DeptCodeName').AsString);
    AdoQry_Tmp.Next;
  end;
  Lbl_State.Caption:='';
  MEdt_Month.Text:=FormatDateTime('yyyy.mm',Now);
end;

procedure TFrm_Sfc_WipInvLock.btn_CancelClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TFrm_Sfc_WipInvLock.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=caFree;
end;

end.

⌨️ 快捷键说明

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