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

📄 inv_opinvqry_c.pas

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

Interface

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

Type
  TFrm_Inv_OpInvQry_C = Class(TFrm_Base_Condition)
    Extedt_ItemCode1: TExtEdit;
    Label4: TLabel;
    lbl_ItemName1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    lbl_UomName1: TLabel;
    lbl_ItemName: TEdit;
    lbl_UomName: TEdit;
    Extedt_ItemCode: TLinkEdit;
    procedure btn_okClick(Sender: TObject);
    procedure FindItemCode(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_OpInvQry_C: TFrm_Inv_OpInvQry_C;

implementation

uses Sys_Global;

{$R *.DFM}

procedure TFrm_Inv_OpInvQry_C.btn_okClick(Sender: TObject);
var
  tmp_Sqltext:string;
begin
  inherited;
  //这个是查询的固定语句
  tmp_Sqltext:='select a.ItemCode,'+
                       ' a.ItemCode+'+''' '''+'+i.ItemName as ItemCodeName,'+
                       ' a.opInv,'+
                       ' Price='+
                       '   case a.opInv '+
                       '    when 0 then 0 '+
                       '    else a.Amount/a.opInv end,'+
                       ' round(a.Amount,2) as Amount '+
                       ' from '+
                       '  (select opCurrentInv.ItemCode,'+
                                ' sum(isnull(opCurrentInv.opInv,0)) as opInv,'+
                                ' sum(isnull(opCurrentInv.opInv*opAveragePrice.opAveragePrice,0)) as Amount '+
                        ' from opCurrentInv '+
                        ' left join opAveragePrice '+
                        '   on opCurrentInv.VendorCode=opAveragePrice.VendorCode and '+
                        '      opCurrentInv.ItemCode=opAveragePrice.ItemCode '+
                        '      group by opCurrentInv.ItemCode) a '+
                 'left join Item i '+
                 'on a.ItemCode=i.ItemCode';
   //下面为条件的组合语句
  condition:='';
  ConditionHint:='';
  if Trim(Extedt_ItemCode.text)<>'' then
  begin
    condition:=' a.ItemCode like '''+Extedt_ItemCode.text+'%''';
    ConditionHint:='物料:'+Extedt_ItemCode.text+ ' '+lbl_ItemName.text;
  end
  else
  begin
    condition:='';
    ConditionHint:='物料:所有';
  end;

  //如果条件不为空,则固定语句+条件回传AdoQry_Main,如果为空,则固定语句回传AdoQry_Main
  if condition<>'' then condition:=tmp_Sqltext+' where ('+condition+')'
  else
    condition:=tmp_Sqltext;

  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OpInvQry_C.FindItemCode(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_OpInvQry_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_OpInvQry_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_OpInvQry_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 + -