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

📄 ad_enter_monthcheckout.pas

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

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Condition, Db, AdODB, StdCtrls,Sys_Global;

Type
  TFrm_Ad_Enter_MonthCheckout = Class(TFrm_Base_Condition)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    procedure btn_okClick(Sender: TObject);
    procedure btn_CancelClick(Sender: TObject);
  private
    { Private declarations }
    Function  ISMonthCheckout(R_AdoQry:TAdoQuery;R_StrMonthCheckoutMonth:String):Integer;//计提月份
  public
    { Public declarations }
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);
  end;

var
  Frm_Ad_Enter_MonthCheckout: TFrm_Ad_Enter_MonthCheckout;

implementation

{$R *.DFM}
procedure TFrm_Ad_Enter_MonthCheckout.InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);
var StrSqlText:String;
begin
  inherited;
  Caption:='月结';
  AdoQry_Tmp.Connection:=AdOConnection;
  StrSqlText:='Select Top 1 * '+
                     'From Ad_MonthCheckout '+
                     'Order By YearMonth DESC';
  ExecuteSql(AdoQry_Tmp,StrSqltext,0);
  Edit2.Text:=AdoQry_Tmp.fieldbyname('YearMonth').AsString;
  Edit1.Text:=Copy(DateToStr(Date),1,7);

end;


Function  TFrm_Ad_Enter_MonthCheckout.ISMonthCheckout(R_AdoQry:TAdoQuery;R_StrMonthCheckoutMonth:String):Integer;//计提月份
var StrSqlText:String;
    StrStartUseMonth:String;
    StrLastCheckoutMonth:String;
    IntCheckoutYear:Integer;
    IntCheckoutMonth:Integer;
    IntMonthChekYear:Integer;
    IntMonthCheck:Integer;
begin
  StrSqlText:='Select * '+
                     'From Ad_Param '+
                     'Where ParamCode=''StartUseAd'' And ParamValueN=1';
  ExecuteSql(R_AdoQry,StrSqltext,0);
  IF R_AdoQry.RecordCount=0 Then
  begin
    Result:=0;  //模块没有正式启用
    Exit;
  end;

  StrStartUseMonth:=R_AdoQry.fieldbyname('ParamValueC').AsString;
  IF StrStartUseMonth>R_StrMonthCheckoutMonth  Then
  begin
     Result:=1;
     Exit; //月结月份小于模块启用月份
  end;

  StrSqlText:='Select * '+
                     'From Ad_MonthCheckout '+
                     'Where YearMonth='+R_StrMonthCheckoutMonth+' ';
  ExecuteSql(R_AdoQry,StrSqltext,0);
  IF R_AdoQry.RecordCount=1 Then
  begin
    Result:=2;     //已月结了
    Exit;
  end;

  StrSqlText:='Select Top 1 * '+
                     'From Ad_MonthCheckout '+
                     'Order By YearMonth DESC';
  ExecuteSql(R_AdoQry,StrSqltext,0);
  StrLastCheckoutMonth:=R_AdoQry.fieldbyname('YearMonth').AsString;
  IF StrLastCheckoutMonth<>'' Then
  begin
    IntCheckoutYear:=StrToInt(Copy(StrLastCheckoutMonth,1,4));
    IntCheckoutMonth:=StrToInt(Copy(StrLastCheckoutMonth,6,2));
    IntMonthChekYear:=StrToInt(Copy(R_StrMonthCheckoutMonth,1,4));
    IntMonthCheck:=StrToInt(Copy(R_StrMonthCheckoutMonth,6,2));
    Case IntMonthChekYear-IntCheckoutYear Of
       0: begin
            If IntMonthCheck-IntCheckoutMonth<>1 Then
               Result:=3;     //跨月份了
               Exit;
          end;
       1: begin
            IF (IntMonthCheck=1) And (IntCheckoutMonth=12) Then
               Result:=3;     //跨月份了
               Exit;
          end
       Else begin
              Result:=3;     //跨月份了
              Exit;
            end;
    end;
  end
  Else begin
    IF R_StrMonthCheckoutMonth<>StrStartUseMonth Then
      begin
         Result:=3;     //跨月份了
         Exit;
      end;
  end;
end;

procedure TFrm_Ad_Enter_MonthCheckout.btn_okClick(Sender: TObject);
var  StrMonthCheckoutMonth:String;
     StrSqlText:String;
     AdODBConnect:TAdOConnection;
begin
  inherited;
  StrMonthCheckoutMonth:=Edit1.Text;
  Case ISMonthCheckout(AdoQry_Tmp,StrMonthCheckoutMonth) Of
    0: begin
         DispInfo('固定资产模块没有正式启用',1);
         Abort;
     end;
    1: begin
         DispInfo('月结月份小于模块启用月份',1);
         Abort;
     end;
    2: begin
         DispInfo('此月份已月结,不能再月结',1);
         Abort;
     end;
    3: begin
         DispInfo('不能跨月份月结',1);
         Abort;
     end;
     Else  begin
             IF DispInfo('您真的想对'+StrMonthCheckoutMonth+'月份进行月结吗?',2)='n' Then
                Abort;
           end;
  end;

  StrSqlText:='Exec Prod_Ad_MonthCheckout '''+StrMonthCheckoutMonth+''','''+UserCode+''' ';
  AdODBConnect:=AdoQry_Tmp.Connection;
  AdODBConnect.beginTrans;
  Try
    ExecuteSql(AdoQry_Tmp,StrSqlText,1);
    AdODBConnect.CommitTrans;
    DispInfo('月结成功',3);
  Except
    AdODBConnect.RollBackTrans;
    DispInfo('月结失败,稍后请重试',1);
  end;




end;

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


end.

⌨️ 快捷键说明

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