pm_qry_poexecutedetail_condition.pas

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

PAS
179
字号

unit Pm_Qry_PoExecuteDetail_Condition;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Dialog, StdCtrls, Mask, DBCtrls, ExtDBEdit, Db, AdODB, ExtCtrls,
  ExtEdit, ActnList;

Type
  TFrm_Pm_Qry_PoExecuteDetail_Condition = Class(TFrm_Base_Dialog)
    Label2: TLabel;
    ExtEdt_VendorCode: TExtEdit;
    Lbl_VendorName: TLabel;
    Label3: TLabel;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label1: TLabel;
    Label4: TLabel;
    MEdt_beginMonth: TMaskEdit;
    MEdt_EndMonth: TMaskEdit;
    ActionList1: TActionList;
    Action1: TAction;
    procedure GetVendorName(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
  private
    { Private declarations }
    function  VendorCodeUsable(R_VendorCode:String):Boolean;
    function  PickVendorCode(InitCode:String):String;

    procedure SetVendor(R_VendorCode:String);    
  public
    { Public declarations }
    VendorCode:string;
    status:integer;
    beginMonth,endMonth:string;
    procedure Initform(AdoConnection:TAdoConnection);
  end;

var
  Frm_Pm_Qry_PoExecuteDetail_Condition: TFrm_Pm_Qry_PoExecuteDetail_Condition;

implementation

uses Sys_Global;

{$R *.DFM}


{TFrm_Pm_Qry_PoExecuteDetail_Condition }

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.SetVendor(
  R_VendorCode: String);
begin
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select VendorName '+
            'from Vendor '+
            'where VendorCode='''+R_VendorCode+''' ');
    open;
    if not eof then
      Lbl_VendorName.Caption:=fieldbyname('VendorName').asString;
    Close;
  end;
end;

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.GetVendorName(
  Sender: TObject);
begin
  inherited;
  if ExtEdt_VendorCode.Text='' then
  begin
    Lbl_VendorName.Caption:='';
    exit;
  end;

  if VendorCodeUsable(ExtEdt_VendorCode.Text) then
  begin
    SetVendor(ExtEdt_VendorCode.Text);
  end
  else
  begin
    DispInfo('输入的代码没找到!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end;

end;

function TFrm_Pm_Qry_PoExecuteDetail_Condition.PickVendorCode(
  InitCode: String): String;
begin
  Result:=GetCodeHint(
        AdoQry_Tmp,
        'VendorName','供应商名称',
        'VendorCode','供应商代码',
        'Vendor',InitCode,'');
end;

function TFrm_Pm_Qry_PoExecuteDetail_Condition.VendorCodeUsable(
  R_VendorCode: String): Boolean;
var
  T_Count:integer;
  T_Sql:string;
begin
   T_Sql:=
    'Select Count(*) as RecordCount '+
    'from Vendor '+
    'where VendorCode='''+R_VendorCode+''' ';
    with AdoQry_Tmp do
    begin
      Close;
      SQL.clear;
      SQL.Add(T_Sql);
      open;
      T_Count:=fieldbyname('RecordCount').AsInteger;
      Close;
    end;
    if T_Count>0 then Result:=True
   else Result:=False;
end;

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.btn_okClick(
  Sender: TObject);
begin
  inherited;
  VendorCode:=Trim(ExtEdt_VendorCode.text);
  if RadioButton1.checked=True then
    status:=6;
  if RadioButton2.checked=True then
    status:=7;
  beginMonth:=Trim(MEdt_beginMonth.text);
  endMonth:=Trim(MEdt_EndMonth.text);
  ModalResult:=mrok;
end;

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.FormActivate(
  Sender: TObject);
begin
  inherited;
  if VendorCode<>'' then
  begin
    ExtEdt_VendorCode.text:= VendorCode;
    MEdt_beginMonth.text:=beginMonth;
    MEdt_EndMonth.text:=endMonth;
    if status=6 then
      RadioButton1.checked:=True;
    if status=7 then
      RadioButton1.checked:=True;
  end
  else
    RadioButton1.checked:=True;
end;

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.Action1Execute(
  Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='ExtEdt_VendorCode' then
  begin
    ExtEdt_VendorCode.Text:=PickVendorCode(ExtEdt_VendorCode.Text);
    ExtEdt_VendorCode.SetFocus;
  end;
end;

procedure TFrm_Pm_Qry_PoExecuteDetail_Condition.Initform(
  AdoConnection: TAdoConnection);
begin
  AdoQry_Tmp.Connection:=AdoConnection;
end;

end.

⌨️ 快捷键说明

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