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

📄 inv_opvendorinvqry_c.pas

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

Interface

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

Type
  TFrm_Inv_OpVendorInvQry_C = Class(TFrm_Base_Condition)
    Extedt_VendorCode1: TExtEdit;
    Extedt_ItemCode1: TExtEdit;
    Label1: TLabel;
    Label2: TLabel;
    lbl_VendorName1: TLabel;
    Label4: TLabel;
    lbl_ItemName1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    lbl_UomName1: TLabel;
    Extedt_VendorCode: TLinkEdit;
    Extedt_ItemCode: TLinkEdit;
    lbl_VendorName: TEdit;
    lbl_ItemName: TEdit;
    lbl_UomName: TEdit;
    procedure btn_okClick(Sender: TObject);
    procedure Extedt_ItemCode1Exit(Sender: TObject);
    procedure Extedt_VendorCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_VendorCodeButtonClick(Sender: TObject);
    procedure Extedt_VendorCodeExit(Sender: TObject);
    procedure Extedt_ItemCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_ItemCodeButtonClick(Sender: TObject);
    procedure Extedt_ItemCodeExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Inv_OpVendorInvQry_C: TFrm_Inv_OpVendorInvQry_C;

implementation

uses Sys_Global;

{$R *.DFM}

procedure TFrm_Inv_OpVendorInvQry_C.btn_okClick(Sender: TObject);
var
  tmp_SumAmount:string;
begin
  inherited;
  condition:='';
  ConditionHint:='';
  if Trim(Extedt_VendorCode.text)<>'' then
  begin
    condition:='opCurrentInv.VendorCode like '''+Extedt_VendorCode.text+'%''';
    ConditionHint:='供应商:'+Extedt_VendorCode.text+ ' '+lbl_VendorName.text;
  end
  else
  begin
    condition:='';
    ConditionHint:='供应商:所有';
  end;

  if Trim(Extedt_ItemCode.text)<>'' then
  begin
    if condition<>'' then
       condition:=condition+' and opCurrentInv.ItemCode like '''+Extedt_ItemCode.text+'%'''
    else
       condition:='opCurrentInv.ItemCode like '''+Extedt_ItemCode.text+'%''';

    if ConditionHint<>'' then
      ConditionHint:=ConditionHint+',物料:'+Extedt_ItemCode.text+ ' '+lbl_ItemName.text
    else
      ConditionHint:='物料:'+Extedt_ItemCode.text+ ' '+lbl_ItemName.text;
  end
  else
  begin
    condition:=condition+'';
    if ConditionHint<>'' then
      ConditionHint:=ConditionHint+',物料:所有'
    else
      ConditionHint:=ConditionHint+'物料:所有';
  end;
  if condition='' then
     condition:=' abs(opCurrentInv.opInv)>=0.01 '
  else
     condition:=condition+' and abs(opCurrentInv.opInv)>=0.01 ';
  if condition<>'' then condition:='('+condition+')';
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    if condition='' then
      sql.text:=
        ' select round(sum(isnull(opCurrentInv.opInv*opAveragePrice.opAveragePrice,0)),2) as sumAmount '+
        ' from  opCurrentInv '+
        '  left join opAveragePrice '+
        '   on  opCurrentInv.VendorCode=opAveragePrice.VendorCode '+
        '   and opCurrentInv.ItemCode=opAveragePrice.ItemCode '
    else
      sql.text:=
        ' select round(sum(opCurrentInv.opInv*opAveragePrice.opAveragePrice),2) as sumAmount '+
        ' from  opCurrentInv '+
        '  left join opAveragePrice '+
        '   on  opCurrentInv.VendorCode=opAveragePrice.VendorCode '+
        '   and opCurrentInv.ItemCode=opAveragePrice.ItemCode '+
        ' where '+condition;
    open;
    tmp_SumAmount:=fieldbyname('sumAmount').asstring;
    if tmp_SumAmount='' then tmp_SumAmount:='0';
    FatherForm.SetFormParam(tmp_SumAmount,'','','','','');
  end;

  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_ItemCode1Exit(Sender: TObject);
begin
  inherited;
  if Extedt_ItemCode.text<>'' then
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select Item.ItemName,Uom.UomName from Uom,Item where Item.ItemCode='''+Extedt_ItemCode.text+''' and Item.UomCode=Uom.UomCode ');
    open;
    if not eof then
    begin
      lbl_UomName.text:=fieldbyname('UomName').asstring;
      lbl_ItemName.text:=fieldbyname('ItemName').asstring;
    end
    else
    begin
      lbl_UomName.text:='';
      lbl_ItemName.text:='';
    end;
  end;
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_VendorCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  if(Key=120)then
    CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
      '供应商代码','Vendor','VendorUsable=1');
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_VendorCodeButtonClick(
  Sender: TObject);
begin
  inherited;
   CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
      '供应商代码','Vendor','VendorUsable=1');
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_VendorCodeExit(Sender: TObject);
begin
  inherited;
  with AdoQry_Tmp do
  begin
    Close;
    sql.clear;
    sql.Add(' select VendorName from Vendor where VendorCode='''+Trim(Extedt_VendorCode.text)+''''
           +' and VendorUsable=1');
    open;
    lbl_VendorName.text:=fieldbyname('VendorName').asstring;
  end;
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_ItemCodeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if(Key=120)then
    CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode',
      '物料代码','Item','ItemUsable=1 and ItemType in (0,2)');
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_ItemCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode',
      '物料代码','Item','ItemUsable=1 and ItemType in (0,2)');
end;

procedure TFrm_Inv_OpVendorInvQry_C.Extedt_ItemCodeExit(Sender: TObject);
begin
  inherited;
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.text:=' select Item.ItemName,Uom.UomName from Item ,Uom '
             +' where  Item.UomCode=Uom.UomCode and Item.ItemCode='''+Trim(Extedt_ItemCode.text)+''''
             +' and Item.ItemUsable=1 and Item.ItemType in (0,2)';
    open;
    if not isempty then
    begin
      lbl_ItemName.text:=fieldbyname('ItemName').asstring;
      lbl_UomName.text:=fieldbyname('UomName').asstring;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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