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

📄 gl_enter_foreigncurrencyrate.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Gl_Enter_ForeignCurrencyRate;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Body, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  ExtCtrls, ComCtrls, ToolWin, Mask, StdCtrls, linkedit;

Type
  TFrm_Gl_Enter_ForeignCurrencyRate = Class(TFrm_Base_Entry_Body)
    Label1: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edt_CurrencyCode: TLinkEdit;
    Edt_CurrencyName: TEdit;
    Edt_AccountPeriod: TMaskEdit;
    Edt_ChangeForeignRate: TEdit;
    Edt_ForeignRate: TEdit;
    Edt_RemArk: TEdit;
    Label14: TLabel;
    AdoQry_BodyForeignCurrencyRateID: TIntegerField;
    AdoQry_BodyAccountPeriodDate: TIntegerField;
    AdoQry_BodyForeignRate: TFloatField;
    AdoQry_BodyChangeForeignRate: TFloatField;
    AdoQry_BodyRemArk: TStringField;
    procedure FormCreate(Sender: TObject);
    procedure Edt_CurrencyCodeExit(Sender: TObject);
    procedure Act_InsertLineExecute(Sender: TObject);
    procedure Edt_AccountPeriodEnter(Sender: TObject);
    procedure Edt_AccountPeriodExit(Sender: TObject);
  private
    IdentityNo,CurrentFormStatus,Month:String;
    procedure ChangeDetill;
    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 SetStatus(CurrentStatus:String;var AnswerStatus,
      EnableControls:String); Override;//设置各种状态下那些控件Enable
    procedure InitControls; Override;//初始化Form上所有控件
    procedure SaveData; Override;//把表头控件写入缓存,不要Post
    { Public declarations }
  end;

var
  Frm_Gl_Enter_ForeignCurrencyRate: TFrm_Gl_Enter_ForeignCurrencyRate;
  Month:String;

implementation

uses Gl_Enter_ForeignCurrencyRate_D, Sys_Global;

{$R *.DFM}

{ TFrm_Gl_Enter_ForeignCurrencyRate }


procedure TFrm_Gl_Enter_ForeignCurrencyRate.FormCreate(Sender: TObject);
begin
  inherited;
  Frm_Gl_Enter_ForeignCurrencyRate_D:=TFrm_Gl_Enter_ForeignCurrencyRate_D.Create(Self);
  Frm_Entry_Detail:=Frm_Gl_Enter_ForeignCurrencyRate_D;
end;

procedure TFrm_Gl_Enter_ForeignCurrencyRate.Edt_CurrencyCodeExit(
  Sender: TObject);
begin
  inherited;
  CurrencyCodeCheck(sender);
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := ' Select CurrencyName From Currency '
                        +'        Where CurrencyCode = '''+Edt_CurrencyCode.Text+'''';
  AdoQry_Tmp.Open;
  Edt_CurrencyName.Text := AdoQry_Tmp.fieldbyname('CurrencyName').AsString;
end;

procedure TFrm_Gl_Enter_ForeignCurrencyRate.Act_InsertLineExecute(
  Sender: TObject);
begin
  if Status = 'Add' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text := ' Select * From Gl_ForeignCurrencyRate '
                          +'       Where CURRENCYCode = '''+Edt_CurrencyCode.Text+''' '
                          +'             And AccountPeriod = '''+Edt_AccountPeriod.text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      DispInfo('月份为'+Edt_AccountPeriod.Text +'的'''+Edt_CurrencyName.Text+'''汇率已设定!',1);
      Edt_CurrencyCode.SetFocus;
      Abort;
    end;
    Month := Edt_AccountPeriod.Text ;
  end;
  inherited;

end;

procedure TFrm_Gl_Enter_ForeignCurrencyRate.SetStatus(
  CurrentStatus: String; var AnswerStatus, EnableControls: String);
begin
  inherited;
  IF Status='Add' then
    EnableControls:=' Edt_CurrencyCode,Edt_AccountPeriod,Edt_ForeignRate,'
                   +' Edt_ChangeForeignRate, Edt_RemArk, '
  else
    EnableControls:=' Edt_ForeignRate,'
                   +' Edt_ChangeForeignRate, Edt_RemArk, '

end;

procedure TFrm_Gl_Enter_ForeignCurrencyRate.InitControls;
var
  SqlText:String;
begin
  inherited;
  Edt_CurrencyName.Enabled := False;
  If Status='Add' then
  begin
    CurrentFormStatus:='Add';
    Edt_AccountPeriod.Text :=Copy(FormatDateTime('YYYY.MM.DD',Date()),1,7);
    Month:= Trim(Edt_AccountPeriod.Text);
    Edt_ForeignRate.Text := '0' ;
    Edt_ChangeForeignRate.Text := '0';
    Edt_RemArk.Text := '';
    SqlText:=' Select top 0 * '
            +' From Gl_ForeignCurrencyRateLine ';
     AdoQry_Body.Close;
     AdoQry_Body.SQL.Text:=SqlText;
     AdoQry_Body.Open;
//
   ChangeDetill;
//
     DataSource.DataSet:=AdoQry_Body;
  end
      else
      begin
        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;
        With AdoQry_Head do
        begin
          Edt_CurrencyCode.Text := fieldbyname('CurrencyCode').AsString;
          Edt_CurrencyName.Text := fieldbyname('CurrencyName').AsString;
          Edt_AccountPeriod.Text := fieldbyname('AccountPeriod').AsString;
          Edt_ForeignRate.Text := fieldbyname('ForeignRate').AsString;
          Edt_ChangeForeignRate.Text := fieldbyname('ChangeForeignRate').AsString;
          Edt_RemArk.Text := fieldbyname('RemArk').AsString;
          SqlText:=' Select  * '
                  +' From Gl_ForeignCurrencyRateLine '
                  +'     where ForeignCurrencyRateID= '''+IdentityNo+''' ' ;
         AdoQry_Body.Close;
         AdoQry_Body.SQL.Text:=SqlText;
         AdoQry_Body.Open;
        end;
    end;
  if Status='Add' then
  begin
    if Edt_CurrencyCode.CanFocus then
      Edt_CurrencyCode.SetFocus;
  end
  else
  begin
    if Edt_ForeignRate.CanFocus then
      Edt_ForeignRate.SetFocus;
  end;

end;

procedure TFrm_Gl_Enter_ForeignCurrencyRate.SaveData;
var
  SqlText:String;
begin
  inherited;
  if (Status='Add') then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text := ' Select * From Gl_ForeignCurrencyRate '
                          +'       Where CURRENCYCode = '''+Edt_CurrencyCode.Text+''' '
                          +'             And AccountPeriod = '''+Edt_AccountPeriod.text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      DispInfo('月份为'+Edt_AccountPeriod.Text +'的'''+Edt_CurrencyName.Text+'''汇率已设定!',1);
      Edt_CurrencyCode.SetFocus;
      Abort;
    end;
  end;
  DbConnect.beginTrans;
  Try
    AdoQry_Tmp.Close;
    If (Status='Add') Then
    begin
      SqlText:='Insert Gl_ForeignCurrencyRate '
              +' (CurrencyCode,AccountPeriod,ForeignRate,ChangeForeignRate,RemArk)'
              +'  Values('
              +''''+Trim(Edt_CurrencyCode.Text)+''','
              +''''+Trim(Edt_AccountPeriod.Text)+''','
              +''''+Trim(Edt_ForeignRate.Text)+''','
              +''''+Trim(Edt_ChangeForeignRate.Text)+''','
              +''''+Trim(Edt_RemArk.Text)+''')';
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:=SqlText;
      AdoQry_Tmp.ExecSQL;
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.clear;
      AdoQry_Tmp.SQL.Text := 'Select @@Identity As Number';
      AdoQry_Tmp.Open;
      IdentityNo := AdoQry_Tmp.fieldbyname('Number').AsString;

      SaveHistoryFCurrencyRate(DbConnect,IdentityNo,UserCode,0);

      AdoQry_Body.First;
      While Not AdoQry_Body.Eof Do
      begin
        SqlText:='Insert Gl_ForeignCurrencyRateLine '
                +' (ForeignCurrencyRateID,AccountPeriodDate,ForeignRate,ChangeForeignRate,RemArk)'
                +'Values('
                +''''+IdentityNo+''','
                +''''+IntToStr(AdoQry_Body.fieldbyname('AccountPeriodDate').AsInteger)+''','
                +''''+AdoQry_Body.fieldbyname('ForeignRate').AsString+''','
                +''''+AdoQry_Body.fieldbyname('ChangeForeignRate').AsString+''','
                +''''+AdoQry_Body.fieldbyname('RemArk').AsString+''')';
        AdoQry_Tmp.Close;
        AdoQry_Tmp.SQL.Text:=SqlText;
        AdoQry_Tmp.ExecSQL;

⌨️ 快捷键说明

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