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

📄 inv_oppoinvqry_c.pas

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

Interface

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

Type
  TFrm_Inv_OpPoInvQry_C = Class(TFrm_Base_Condition)
    Extedt_VendorCode1: TExtEdit;
    Label1: TLabel;
    Label2: TLabel;
    lbl_VendorName1: TLabel;
    Label6: TLabel;
    lbl_UomName: TLabel;
    Extedt_Pono_begin: TExtEdit;
    Extedt_Pono_End: TExtEdit;
    lbl_VendorName: TEdit;
    Extedt_VendorCode: TLinkEdit;
    Label3: TLabel;
    procedure btn_okClick(Sender: TObject);
    procedure Extedt_Pono_beginExit(Sender: TObject);
    procedure Extedt_Pono_beginKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_Pono_EndKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_Pono_EndExit(Sender: TObject);
    procedure Extedt_VendorCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_VendorCodeButtonClick(Sender: TObject);
    procedure Extedt_VendorCodeExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Inv_OpPoInvQry_C: TFrm_Inv_OpPoInvQry_C;

implementation

uses Inv_OpPoInvQry_Hint,Sys_Global,Inv_Global;

{$R *.DFM}


procedure TFrm_Inv_OpPoInvQry_C.btn_okClick(Sender: TObject);
var
  sqltext1,sqltext2:string;
begin
  inherited;
  if Trim(Extedt_Pono_begin.text)='' then
  begin
    DispInfo('必须输入采购订单号!',1);
    abort;
  end;
  sqltext1:=
    'select a.pono,'+
      ' a.polineno,'+
      ' a.ItemCode,'+
      ' a.ItemCode+'+''' '''+'+i.ItemName as ItemCodeName,'+
      ' u.UomName, '+
      ' a.poCtrlqty,'+
      ' a.opBillqty,'+
      ' a.InvBillqty,'+
      ' a.remnant '+
    'from '+
       '(select l.pono,'+
           'l.polineno,'+
           'l.ItemCode,'+
           'sum(isnull(l.poCtrlqty,0)) as poCtrlqty,'+
           'sum(isnull(o.opBillqty,0)) as opBillqty,'+
           'sum(isnull(i.InvBillqty,0)) as InvBillqty,'+
           'sum(isnull(o.opBillqty,0))-sum(isnull(i.InvBillqty,0)) as remnant'+
         ' from po p '+
         ' left  join opItemList l on '+
         '    p.pono=l.pono '+
         ' left join InvOutBillline i on '+
            ' l.pono=i.pono and '+
            ' l.polineno=i.polineno and '+
            ' l.ItemCode=i.ItemCode'+
        ' left join InvInBillline il on '+
            ' l.pono=il.pono and '+
            ' l.polineno=il.polineno '+
        ' left join opBill o on '+
            ' il.InvBillid=o.InvBillid and '+
            ' il.InvBilllineno=o.InvBilllineno ';


   sqltext2:=' group by l.pono, '+
            ' l.polineno,'+
            ' l.ItemCode) a '+
   ' left join Item i '+
   '  on a.ItemCode=i.ItemCode '+
   ' left join Uom u '+
   '  on i.UomCode=u.UomCode ';
  condition:='';
  ConditionHint:='';
  if Trim(Extedt_VendorCode.text)<>'' then
  begin
    condition:='p.VendorCode ='''+Extedt_VendorCode.text+'''';
    ConditionHint:='供应商:'+Extedt_VendorCode.text+ ' '+lbl_VendorName.text;
  end;

  if (Trim(Extedt_Pono_begin.text)<>'') and (Trim(Extedt_Pono_End.text)<>'') then
  begin
    if condition<>'' then
      condition:=condition+' and p.pono>='''+Extedt_Pono_begin.text+''' and p.pono<='''+Extedt_Pono_End.text+''''
    else
      condition:=' p.pono>='''+Extedt_Pono_begin.text+''' and p.pono<='''+Extedt_Pono_End.text+'''';

      ConditionHint:=ConditionHint+'  采购订号从:'+Extedt_Pono_begin.text+ '  到: '+Extedt_Pono_End.text;
  end;

  if (Trim(Extedt_Pono_begin.text)<>'') and  (Trim(Extedt_Pono_End.text)='') then
  begin
    condition:=condition+' and p.pono='''+Extedt_Pono_begin.text+'''';
    ConditionHint:=ConditionHint+'  采购订号:'+Extedt_Pono_begin.text;
  end;

  if condition<>'' then condition:=sqltext1+' where ('+condition+') '+sqltext2;
  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OpPoInvQry_C.Extedt_Pono_beginExit(Sender: TObject);
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;

  if Trim(Extedt_Pono_begin.text)<>'' then
  //begin
  //  DispInfo('该订单号不存在!',1);
  //   twincontrol(sender).setfocus;
  //end
  //else
  begin
    AdoQry_tmp.Close;
    AdoQry_tmp.sql.clear;
    AdoQry_tmp.sql.text:=
      'select pono'+
      '  from po '+
      '  where VendorCode='''+Extedt_VendorCode.text+''' and '+
      '        pono='''+Extedt_Pono_begin.text+''' and '+
      '        poType=1 ';
    AdoQry_tmp.open;
    if AdoQry_tmp.eof then
    begin
      DispInfo('该订单号不是以上供应商的委外加工订单!',1);
      twincontrol(sender).setfocus;
    end;
    if Trim(Extedt_Pono_End.text)='' then
       Extedt_Pono_End.text:=Extedt_Pono_begin.text;
  end;
end;

procedure TFrm_Inv_OpPoInvQry_C.Extedt_Pono_beginKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=vk_f9 then
     Extedt_Pono_begin.Text :=GetPONo(Extedt_VendorCode.text,'1',AdoQry_tmp.Connection);
end;

procedure TFrm_Inv_OpPoInvQry_C.Extedt_Pono_EndKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
if key=vk_f9 then
     Extedt_Pono_End.Text :=GetPONo(Extedt_VendorCode.text,'1',AdoQry_tmp.Connection);
end;

procedure TFrm_Inv_OpPoInvQry_C.Extedt_Pono_EndExit(Sender: TObject);
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;

  if Trim(Extedt_Pono_End.text)<>'' then
  begin
    AdoQry_tmp.Close;
    AdoQry_tmp.sql.clear;
    AdoQry_tmp.sql.text:=
      'select pono'+
      '  from po '+
      '  where VendorCode='''+Extedt_VendorCode.text+''' and '+
      '        pono='''+Extedt_Pono_End.text+''' and '+
      '        poType=1 ';
    AdoQry_tmp.open;
    if AdoQry_tmp.eof then
    begin
      DispInfo('该订单号不是以上供应商的委外加工订单!',1);
      twincontrol(sender).setfocus;
    end
    else
    begin
      if Extedt_Pono_End.text<Extedt_Pono_begin.text then
      begin
        DispInfo('终止订单号不能小于起始订单号!',1);
        twincontrol(sender).setfocus;
      end;
    end;
  end
  else
  begin
   // Extedt_Pono_End.text:=Extedt_Pono_begin.text;
  end;
end;

procedure TFrm_Inv_OpPoInvQry_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_OpPoInvQry_C.Extedt_VendorCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
    '供应商代码','Vendor','VendorUsable=1');
end;

procedure TFrm_Inv_OpPoInvQry_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;

end.

⌨️ 快捷键说明

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