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

📄 gl_enter_foreigncurrencyrateh.pas

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

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
  ExtCtrls, ComCtrls, ToolWin;

Type
  TFrm_Gl_Enter_ForeignCurrencyRateH = Class(TFrm_Base_Entry_Head)
    AdoQry_HeadForeignCurrencyRateID: TAutoIncField;
    AdoQry_HeadCURRENCYCode: TStringField;
    AdoQry_HeadAccountPeriod: TStringField;
    AdoQry_HeadForeignRate: TFloatField;
    AdoQry_HeadChangeForeignRate: TFloatField;
    AdoQry_HeadRemArk: TStringField;
    AdoQry_HeadCurrencyName: TStringField;
    procedure Act_DeleteExecute(Sender: TObject);
  private
    procedure SaveHistoryFCurrencyRate(AdoConnection:TAdoConnection;ForeignCurrencyRateID:string;UserCode:string;HisType:integer);
    procedure SaveHistoryFCurrencyRateLine(AdoConnection:TAdoConnection;ForeignCurrencyRateID,days:string;UserCode:string;HisType:integer);

    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;  
    { Public declarations }
  end;

var
  Frm_Gl_Enter_ForeignCurrencyRateH: TFrm_Gl_Enter_ForeignCurrencyRateH;

implementation

uses Gl_Enter_ForeignCurrencyRate, Sys_Global;

{$R *.DFM}

{ TFrm_Gl_Enter_ForeignCurrencyRateH }

procedure TFrm_Gl_Enter_ForeignCurrencyRateH.InitForm(
  AdOConnection: TAdOConnection; ReadOnly: Boolean);
begin
  inherited;
  SelectFromSql:=' Select Gl_ForeignCurrencyRate.*,Currency.CurrencyName '
                +'        From Gl_ForeignCurrencyRate '
                +'             Join Currency '
                +'             On Gl_ForeignCurrencyRate.CurrencyCode=Currency.CurrencyCode ';
  OrderByFields:=' CurrencyCode,AccountPeriod ';
  GetData;
  Frm_Entry_Body:=TFrm_Gl_Enter_ForeignCurrencyRate.Create(Application);
end;

procedure TFrm_Gl_Enter_ForeignCurrencyRateH.SaveHistoryFCurrencyRate(
  AdoConnection: TAdoConnection; ForeignCurrencyRateID, UserCode: string;
  HisType: integer);
var AdoQry:TAdoQuery;
    AdoQrytmp:TAdoQuery;
    sqltext:string;
    chgType:string;
begin
 case hisType of
   0: chgType:='新增';
   1: chgType:='修改';
   2: chgType:='删除';
 end;
 AdoQry:=TAdoQuery.Create(Application);
 AdoQry.EnableBCD:=False;
 AdoQry.Connection:=AdoConnection;
 AdoQrytmp:=TAdoQuery.Create(Application);
 AdoQrytmp.EnableBCD:=False;
 AdoQrytmp.Connection:=AdoConnection;
 SqlText := ' Select * From Gl_ForeignCurrencyRate Where ForeignCurrencyRateID='''+ForeignCurrencyRateID+''' ';
 AdoQry.Close;
 AdoQry.SQL.clear;
 AdoQry.Sql.Text := SqlText;
 AdoQry.Open;
   SqlText:='Insert Gl_ForeignCurrencyRateHistory '
              +' (ForeignCurrencyRateID,CurrencyCode,AccountPeriod,ForeignRate,ChangeForeignRate,RemArk, '
              +'  ChgEmployeeCode,ChgTime,ChgType )'
              +'  Values('
              +''''+ AdoQry.fieldbyname('ForeignCurrencyRateID').AsString+''','
              +''''+ AdoQry.fieldbyname('CurrencyCode').AsString+''','
              +''''+ AdoQry.fieldbyname('AccountPeriod').AsString+''','
              +''''+ AdoQry.fieldbyname('ForeignRate').AsString+''','
              +''''+ AdoQry.fieldbyname('ChangeForeignRate').AsString+''','
              +''''+ AdoQry.fieldbyname('RemArk').AsString+''','
              +Quotedstr(userCode)+','
              +'getdate(),'
              +quotedstr(chgType)+')';

  with AdoQrytmp do
    begin
      Close;
      sql.clear;
      sql.Text:=sqltext;
      try
      execsql;
      except
      end;
    end;
 try
  AdoQry.Free;
  AdoQrytmp.Free;
 except
 end;
end;

procedure TFrm_Gl_Enter_ForeignCurrencyRateH.SaveHistoryFCurrencyRateLine(
  AdoConnection: TAdoConnection; ForeignCurrencyRateID, days,
  UserCode: string; HisType: integer);
var AdoQry:TAdoQuery;
    AdoQrytmp:TAdoQuery;
    sqltext:string;
    chgType:string;
begin
 case hisType of
   0: chgType:='新增';
   1: chgType:='修改';
   2: chgType:='删除';
 end;
 AdoQry:=TAdoQuery.Create(Application);
 AdoQry.EnableBCD:=False;
 AdoQry.Connection:=AdoConnection;
 AdoQrytmp:=TAdoQuery.Create(Application);
 AdoQrytmp.EnableBCD:=False;
 AdoQrytmp.Connection:=AdoConnection;
 with AdoQry do
   begin
    Close;
    sql.clear;
    sql.Text:='select * from Gl_ForeignCurrencyRateLine where ForeignCurrencyRateID='+ForeignCurrencyRateID
              +' and  AccountPeriodDate='+Days;
    Prepared;
    open;
   end;
   SqlText:='Insert Gl_ForeignCurrencyRateLineHist '
                +' (ForeignCurrencyRateID,AccountPeriodDate,ForeignRate,ChangeForeignRate, '
                +' RemArk,ChgEmployeeCode,ChgTime,ChgType)'
                +' Values('
                + Quotedstr(AdoQry.fieldbyname('ForeignCurrencyRateID').AsString)+','
                + Quotedstr(AdoQry.fieldbyname('AccountPeriodDate').AsString)+','
                + Quotedstr(AdoQry.fieldbyname('ForeignRate').AsString)+','
                + Quotedstr(AdoQry.fieldbyname('ChangeForeignRate').AsString)+','
                + Quotedstr(AdoQry.fieldbyname('RemArk').AsString)+','
                + quotedstr(userCode)+','
                +'getdate(),'
                + quotedstr(chgType)+')';
  with AdoQrytmp do
    begin
      Close;
      sql.clear;
      sql.Text:=sqltext;
      try
      execsql;
      except
      end;
    end;
  try
    AdoQry.Free;
    AdoQrytmp.Free;
  except
  end;

end;

procedure TFrm_Gl_Enter_ForeignCurrencyRateH.Act_DeleteExecute(
  Sender: TObject);
var
  IdentityNo:String;
begin
//  inherited;
  if(not AdoQry_Head.IsEmpty)and
    (DispInfo(' 真的删除当前记录吗? ',2)='y')then
  begin
    try
      DbConnect.beginTrans;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.sql.clear;
      AdoQry_Tmp.SQL.Text := ' Select ForeignCurrencyRateID From Gl_ForeignCurrencyRate '
                            +'     Where   CurrencyCode='''+AdoQry_Head.fieldbyname('CurrencyCode').AsString+''' '
                            +'         And  AccountPeriod='''+AdoQry_Head.fieldbyname('AccountPeriod').AsString+''' ' ;
      AdoQry_Tmp.Open;
      IdentityNo := AdoQry_Tmp.fieldbyname('ForeignCurrencyRateID').AsString;
      SaveHistoryFCurrencyRate(DbConnect,IdentityNo,UserCode,2);

      AdoQry_Tmp.Close;
      AdoQry_Tmp.sql.clear;
      AdoQry_Tmp.SQL.Text := ' Select AccountPeriodDate From Gl_ForeignCurrencyRateline '
                            +'     Where   ForeignCurrencyRateID='''+IdentityNo+''' ' ;
      AdoQry_Tmp.Open;
      while not AdoQry_Tmp.Eof do
      begin
        SaveHistoryFCurrencyRateLine(DbConnect,IdentityNo,IntToStr(AdoQry_Tmp.fieldbyname('AccountPeriodDate').AsInteger),UserCode,2);
        AdoQry_Tmp.Next;
      end;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.sql.clear;
      AdoQry_Tmp.SQL.Text := ' Delete Gl_ForeignCurrencyRateline '
                            +'     Where   ForeignCurrencyRateID='''+IdentityNo+''' ' ;
      AdoQry_Tmp.ExecSQL;

      AdoQry_Tmp.Close;
      AdoQry_Tmp.sql.clear;
      AdoQry_Tmp.SQL.Text := ' Delete Gl_ForeignCurrencyRate '
                            +'     Where   ForeignCurrencyRateID='''+IdentityNo+''' ' ;
      AdoQry_Tmp.ExecSQL;
      DbConnect.CommitTrans;
      AdoQry_Head.Delete;

    except
      DbConnect.RollBackTrans ; 
      DispInfo(' 无法删除当前记录,可能已经被其他数据表引用!',1);
      Abort;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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