inv_invagingdefine.pas

来自「一个MRPII系统源代码版本」· PAS 代码 · 共 144 行

PAS
144
字号
unit Inv_InvAgingDefine;

Interface

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

Type
  TFrm_Inv_InvAgingDefine = Class(TFrm_Base_Dialog)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    edt_time1: TEdit;
    edt_time2: TEdit;
    edt_time3: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure edt_time1Exit(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure btn_CancelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Inv_InvAgingDefine: TFrm_Inv_InvAgingDefine;

implementation
uses Sys_Global;
{$R *.DFM}

procedure TFrm_Inv_InvAgingDefine.edt_time1Exit(Sender: TObject);
begin
  inherited;
  floatcheck(sender);
  if strtofloat((sender as tedit).Text)<=0 then
  begin
     DispInfo('时间段必须大于零!',3);
     twincontrol(sender).setfocus;
     abort;
  end;
{  if (sender as tedit).Name='edt_time1' then
  begin
    if strtofloat(edt_time2.text)<=strtofloat((sender as tedit).Text) then
    begin
      DispInfo('时间段1必须小于时间段2!',3);
      twincontrol(sender).setfocus;
      abort;
    end;
  end;  }
  if (sender as tedit).Name='edt_time2' then
  begin
    if strtofloat(edt_time1.text)>=strtofloat((sender as tedit).Text) then
    begin
      DispInfo('时间段2必须大于等于时间段1!',3);
      twincontrol(sender).setfocus;
      abort;
    end;
  end;
  if (sender as tedit).Name='edt_time3' then
  begin
    if strtofloat(edt_time2.text)>=strtofloat((sender as tedit).Text) then
    begin
      DispInfo('时间段3必须大于等于时间段2!',3);
      twincontrol(sender).setfocus;
      abort;
    end;
  end;
end;

procedure TFrm_Inv_InvAgingDefine.FormActivate(Sender: TObject);
begin
  inherited;
  with AdoQry_tmp do
  begin
    Close;
    sql.Text:='select InvValuen from InvParam where InvParamCode='''+'InvAging1'+'''';
    open;
    edt_time1.Text :=fieldbyname('InvValuen').asstring;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.Text:='select InvValuen from InvParam where InvParamCode='''+'InvAging2'+'''';
    open;
    edt_time2.Text :=fieldbyname('InvValuen').asstring;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.Text:='select InvValuen from InvParam where InvParamCode='''+'InvAging3'+'''';
    open;
    edt_time3.Text :=fieldbyname('InvValuen').asstring;
  end;
  edt_time1.SetFocus ;
end;

procedure TFrm_Inv_InvAgingDefine.btn_okClick(Sender: TObject);
begin
  inherited;
  AdoQry_tmp.Connection.beginTrans ;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='update InvParam set InvValuen='+edt_time1.text+' where InvParamCode='''+'InvAging1'+'''';
    execsql;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='update InvParam set InvValuen='+edt_time2.text+' where InvParamCode='''+'InvAging2'+'''';
    execsql;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='update InvParam set InvValuen='+edt_time3.text+' where InvParamCode='''+'InvAging3'+'''';
    execsql;
  end;
  try
    AdoQry_tmp.Connection.CommitTrans ;
    modalResult:=mrok;
  except
    DispInfo('分段时间定义设置失败,请稍后执行。',3);
    AdoQry_tmp.Connection.RollBackTrans ;
    abort;
  end;
  Close;
end;

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

end.

⌨️ 快捷键说明

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