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

📄 inv_opoutbilllistqry_c.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
//邓海文
unit Inv_OpOutBillListQry_C;

Interface

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

Type        
  TFrm_Inv_OpOutBillListQry_C = Class(TFrm_Base_Condition)
    ChLstBx_WhSelect: TCheckListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    MEdt_StArtDate: TMaskEdit;
    MEdt_EndDate: TMaskEdit;
    Edt_StArtNo: TEdit;
    Edt_EndNo: TEdit;
    Lbl_DeptName1: TLabel;
    Lbl_ItemName1: TLabel;
    Edt_MoNo: TEdit;
    Edt_MoLineNo: TEdit;
    Edt_StArtAmount: TEdit;
    Edt_EndAmount: TEdit;
    Label14: TLabel;
    ChBx_PrintTimes: TCheckBox;
    ChBx_SelectAll: TCheckBox;
    Label15: TLabel;
    lbl_Employee: TLabel;
    edt_Employee: TExtEdit;
    RBtn_Oprow: TRadioButton;
    Rbtn_Item: TRadioButton;
    ExtEdt_VendorCode: TLinkEdit;
    ExtEdt_ItemCode: TLinkEdit;
    Lbl_DeptName: TEdit;
    Lbl_ItemName: TEdit;
    procedure btn_okClick(Sender: TObject);
    procedure ChLstBx_WhSelectClickCheck(Sender: TObject);
    procedure MEdt_EndDateExit(Sender: TObject);
    procedure Edt_MoNoExit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ChBx_SelectAllClick(Sender: TObject);
    procedure edt_EmployeeExit(Sender: TObject);
    procedure ExtEdt_VendorCodeExit(Sender: TObject);
    procedure ExtEdt_VendorCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ExtEdt_VendorCodeButtonClick(Sender: TObject);
    procedure ExtEdt_ItemCodeExit(Sender: TObject);
    procedure ExtEdt_ItemCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ExtEdt_ItemCodeButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InitForm(AdOConnection:TAdOConnection;UserCode:String);
  end;

var
  Frm_Inv_OpOutBillListQry_C: TFrm_Inv_OpOutBillListQry_C;

implementation

uses Sys_Global,Inv_OpOutBillListQry;

{$R *.DFM}

procedure TFrm_Inv_OpOutBillListQry_C.InitForm(AdOConnection:TAdOConnection;UserCode:String);
begin
  inherited;
  SetDBConnect(AdOConnection);
  with AdoQry_Tmp do
  begin
    Close;
    SQL.Text:='Select Warehouse.WHCode+'' ''+Warehouse.WHName As CodeName '+
      'From Warehouse Join WHAccessCtrl On Warehouse.WHCode=WHAccessCtrl.WHCode '+
      'Where WHAccessCtrl.EmployeeCode='''+UserCode+'''';
    Open;
    ChLstBx_WhSelect.clear;
    First;
    while not Eof do
    begin
      ChLstBx_WhSelect.Items.Add(fieldbyname('CodeName').AsString);
      AdoQry_Tmp.Next;
    end;
  end;
  if not Frm_Inv_OpOutBillListQry.isop then
    Edt_MoLineNo.enabled:=False;
end;

procedure TFrm_Inv_OpOutBillListQry_C.btn_okClick(Sender: TObject);
var
  i:integer;
begin
  inherited;
  Condition:='';
  for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
  begin
    if ChLstBx_WhSelect.Checked[i] then
    begin
      if Condition='' then
      begin
        Condition:='('''+GetCode(ChLstBx_WhSelect.Items.Strings[i])+'''';
        ConditionHint:='仓库:'+GetName(ChLstBx_WhSelect.Items.Strings[i]);
      end
      else
      begin
        Condition:=Condition+','''+GetCode(ChLstBx_WhSelect.Items.Strings[i])+'''';
        ConditionHint:=ConditionHint+','+GetName(ChLstBx_WhSelect.Items.Strings[i]);
      end;
    end;
  end;
  Condition:=Condition+')';
  Condition:=' InvOutBill.WHCode In'+Condition;
  Condition:=Condition+' And InvOutBill.InvBillDate>='''+MEdt_StArtDate.Text+'''';
  Condition:=Condition+' And InvOutBill.InvBillDate<='''+MEdt_EndDate.Text+'''';
  ConditionHint:=ConditionHint+' 日期:从 '+MEdt_StArtDate.Text+' 到 '+MEdt_EndDate.Text;
  if(Edt_StArtNo.Text<>'')then
  begin
    Condition:=Condition+' And InvOutBill.InvBillNo>='''+Edt_StArtNo.Text+'''';
    ConditionHint:=ConditionHint+' 单号:从 '+Edt_StArtNo.Text;
  end;
  if(Edt_EndNo.Text<>'')then
  begin
    if(Edt_StArtNo.Text<>'')then
      ConditionHint:=ConditionHint+' 到 '+Edt_EndNo.Text
    else
      ConditionHint:=ConditionHint+' 单号到 '+Edt_EndNo.Text;
    Condition:=Condition+' And InvOutBill.InvBillNo<='''+Edt_EndNo.Text+'''';
  end;
  //By 
  if(edt_Employee.Text<>'') then
  begin
    condition:=condition+' and InvOutBill.Sal_EmployeeCode='''+edt_Employee.text+'''';
    conditionHint:=conditionHint+' 录入员:'+edt_Employee.text;
  end;
  //Over
  if(ExtEdt_VendorCode.Text<>'')then
  begin
    Condition:=Condition+' And InvOutBill.VendorCode like '''+ExtEdt_VendorCode.text+'%''';
    ConditionHint:=ConditionHint+' 供应商: '+ExtEdt_VendorCode.Text;
  end;
  if(ExtEdt_ItemCode.Text<>'')and(rbtn_Oprow.Checked)then
  begin
    Condition:=Condition+' And InvOutBillLine.ItemCode like '''+ExtEdt_ItemCode.Text+'%''';
    ConditionHint:=ConditionHint+' 物料代码: '+ExtEdt_ItemCode.Text;
  end;
  if(Edt_MoNo.Text<>'')then
  begin
    Condition:=Condition+' And InvOutBill.MoNo='''+Edt_MoNo.Text+'''';
    ConditionHint:=ConditionHint+' 采购订单号: '+Edt_MoNo.Text;
  end;
  if(Edt_MoLineNo.Text<>'')and(rbtn_Oprow.Checked)then
  begin
    Condition:=Condition+' And InvOutBillLine.MoLineNo='''+Edt_MoLineNo.Text+'''';
    ConditionHint:=ConditionHint+' 采购订单行号: '+Edt_MoLineNo.Text;
  end;
  if(Edt_StArtAmount.Text<>'')and(rbtn_Oprow.Checked)then
  begin
    Condition:=Condition+' And InvOutBillLine.InvBillQty>='+Edt_StArtAmount.Text;
    ConditionHint:=ConditionHint+' 数量:从 '+Edt_StArtAmount.Text;
  end;
  if(Edt_EndAmount.Text<>'')and(rbtn_Oprow.Checked)then
  begin
    Condition:=Condition+' And InvOutBillLine.InvBillQty<='+Edt_EndAmount.Text;
    if(Edt_StArtAmount.Text<>'')then
      ConditionHint:=ConditionHint+' 到 '+Edt_EndAmount.Text
    else
      ConditionHint:=ConditionHint+' 数量到 '+Edt_EndAmount.Text;
  end;
  if ChBx_PrintTimes.Checked then
    Condition:=Condition+' And InvOutBill.PrintTimes=0 ' ;
  Frm_Inv_OpOutBillListQry.isop:=rbtn_Oprow.Checked ;
  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OpOutBillListQry_C.ChLstBx_WhSelectClickCheck(
  Sender: TObject);
var
  i:Integer;
begin
  inherited;
  btn_ok.Enabled:=False;
  for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
  begin
    if ChLstBx_WhSelect.Checked[i] then
      btn_ok.Enabled:=True;
  end;
end;

procedure TFrm_Inv_OpOutBillListQry_C.MEdt_EndDateExit(Sender: TObject);
begin
  inherited;
  if ActiveControl.Name='btn_Cancel' then
    Exit;
  DateCheck(Sender);
  if StrToDateTime(MEdt_EndDate.Text)<StrToDateTime(MEdt_StArtDate.Text) then
  begin
    DispInfo('结束时间不能小于开始时间',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

procedure TFrm_Inv_OpOutBillListQry_C.Edt_MoNoExit(Sender: TObject);
begin
  inherited;
  if Edt_MoNo.Text='' then
    Edt_MoLineNo.Text:='';
end;

procedure TFrm_Inv_OpOutBillListQry_C.FormCreate(Sender: TObject);
begin
  inherited;
  MEdt_StArtDate.Text:=FormatDateTime('yyyy.mm.dd',Now-31);
  MEdt_EndDate.Text:=FormatDateTime('yyyy.mm.dd',Now);
end;

procedure TFrm_Inv_OpOutBillListQry_C.ChBx_SelectAllClick(Sender: TObject);
var
  i:integer;
begin
  inherited;
  if ChBx_SelectAll.Checked then
  begin
    for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
    begin
      ChLstBx_WhSelect.Checked[i]:=True;
    end;
    btn_ok.Enabled:=True;
  end
  else
  begin
    for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
    begin
      ChLstBx_WhSelect.Checked[i]:=False;
    end;
    btn_ok.Enabled:=False;
  end;
end;

procedure TFrm_Inv_OpOutBillListQry_C.edt_EmployeeExit(Sender: TObject);
begin
  inherited;
  if edt_Employee.Text<>'' then
  EmployeeCodeCheck(sender)
  else
  lbl_Employee.Caption:='';
end;

procedure TFrm_Inv_OpOutBillListQry_C.ExtEdt_VendorCodeExit(
  Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  with AdoQry_Tmp do
  begin
    Close;
    SQL.clear;
    SQL.Text:=' Select VendorName From Vendor '
             +' Where VendorCode='''+Trim(ExtEdt_VendorCode.Text)+''''
             +' and VendorUsable=1' ;
    Open;
    Lbl_DeptName.Text :=fieldbyname('VendorName').asstring;
  end;
end;

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

procedure TFrm_Inv_OpOutBillListQry_C.ExtEdt_ItemCodeExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  //CommonFindCode(Sender,AdoQry_Tmp,'ItemName','ItemCode','Item');
  with AdoQry_Tmp do
  begin
    Close;
    SQL.clear;
    SQL.Text:=' Select ItemName From  Item '
             +' Where ItemCode='''+Trim(ExtEdt_ItemCode.Text)+''''
             +' and ItemUsable=1';
    Open;
    Lbl_ItemName.text:=fieldbyname('ItemName').asstring;
  end;
end;

procedure TFrm_Inv_OpOutBillListQry_C.ExtEdt_ItemCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  if(Key=120)then
    CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode','物料代码','Item');
end;

procedure TFrm_Inv_OpOutBillListQry_C.ExtEdt_ItemCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode','物料代码','Item');
end;

end.

⌨️ 快捷键说明

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