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

📄 inv_otherinbilllistqty_c.pas

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

Interface

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

Type
  TFrm_Inv_OtherInBillListQty_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;
    Label12: TLabel;
    Label13: TLabel;
    MEdt_StArtDate: TMaskEdit;
    MEdt_EndDate: TMaskEdit;
    Edt_StArtNo: TEdit;
    Edt_EndNo: TEdit;
    Lbl_OutName: TLabel;
    ExtEdt_ItemCode: TExtEdit;
    Lbl_ItemName: TLabel;
    Edt_StArtAmount: TEdit;
    Edt_EndAmount: TEdit;
    cmbbx_BillType2Code: TComboBox;
    cmbbx_OutType: TComboBox;
    Label10: TLabel;
    Label11: TLabel;
    ChBx_PrintTimes: TCheckBox;
    ChBx_SelectAll: TCheckBox;
    Extedt_Employee: TExtEdit;
    Label14: TLabel;
    lbl_Employee: TLabel;
    CheckBox1: TCheckBox;
    ExtEdt_OutCode: TExtEdit;
    Label15: TLabel;
    chbx_Check0: TCheckBox;
    chbx_Check01: TCheckBox;
    chbx_Check01red: TCheckBox;
    chbx_Checkend1: TCheckBox;
    chbx_Checkend0: TCheckBox;
    procedure btn_okClick(Sender: TObject);
    procedure ChLstBx_WhSelectClickCheck(Sender: TObject);
    procedure MEdt_EndDateExit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ExtEdt_OutCodeExit(Sender: TObject);
    procedure ExtEdt_OutCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ExtEdt_OutCodeEnter(Sender: TObject);
    procedure ChBx_SelectAllClick(Sender: TObject);
  private
    procedure initcmbbx_BillType2Code;
    { Private declarations }
  public
    { Public declarations }
    procedure InitForm(AdOConnection:TAdOConnection;UserCode:String);
  end;

var
  Frm_Inv_OtherInBillListQty_C: TFrm_Inv_OtherInBillListQty_C;

implementation

uses Sys_Global;

{$R *.DFM}

procedure TFrm_Inv_OtherInBillListQty_C.initcmbbx_BillType2Code;
begin
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select BillType2Code,BillType2Name '+
            ' from BillType2  '+
            ' where io2=0 '+
            ' Order by BillType2Code');
    open;
    cmbbx_BillType2Code.clear;
    cmbbx_BillType2Code.Items.Add('全部');
    if not Eof then
    begin
      First;
      while not Eof do
      begin
        cmbbx_BillType2Code.Items.Add(fieldbyname('BillType2Code').asstring+' '+fieldbyname('BillType2Name').asstring);
        Next;
      end;
    end;
    cmbbx_BillType2Code.ItemIndex:=0;
  end;
end;


procedure TFrm_Inv_OtherInBillListQty_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;
  initcmbbx_BillType2Code;
end;

procedure TFrm_Inv_OtherInBillListQty_C.btn_okClick(Sender: TObject);
var
  i:integer;
  checksql:string;
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:=' InvInBill.WHCode In'+Condition;
  if CheckBox1.Checked then
    Condition:=Condition+' And InvInBill.OPBill=1';
  Condition:=Condition+' And InvInBill.InvBillDate>='''+MEdt_StArtDate.Text+'''';
  Condition:=Condition+' And InvInBill.InvBillDate<='''+MEdt_EndDate.Text+'''';
  ConditionHint:=ConditionHint+' 日期:从 '+MEdt_StArtDate.Text+' 到 '+MEdt_EndDate.Text;
  if(Edt_StArtNo.Text<>'')then
  begin
    Condition:=Condition+' And InvInBill.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 InvInBill.InvBillNo<='''+Edt_EndNo.Text+'''';
  end;

  if(ExtEdt_ItemCode.Text<>'')then
  begin
    Condition:=Condition+' And InvInBillline.ItemCode like '''+ExtEdt_ItemCode.Text+'%''';
    ConditionHint:=ConditionHint+' 物料代码: '+ExtEdt_ItemCode.Text;
  end;

  if(Extedt_Employee.Text<>'')then
  begin
    Condition:=Condition+' And InvInBill.Stk_EmployeeCode='''+Extedt_Employee.Text+'''';
    ConditionHint:=ConditionHint+' 制单员: '+Extedt_Employee.Text;
  end;

  if(ExtEdt_OutCode.Text<>'')then
  begin
    if cmbbx_OutType.text='部门' then
    begin
       Condition:=Condition+' And InvInBill.DeptCode='''+ExtEdt_OutCode.Text+'''';
       ConditionHint:=ConditionHint+' 部门: '+ExtEdt_OutCode.Text;
    end;

    if cmbbx_OutType.text='供应商' then
    begin
      Condition:=Condition+' And InvInBill.VendorCode='''+ExtEdt_OutCode.Text+'''';
      ConditionHint:=ConditionHint+'供应商: '+ExtEdt_OutCode.Text;
    end;
  end;


  if (cmbbx_BillType2Code.text<>'') then
  begin
    if cmbbx_BillType2Code.text='全部' then
   //    Condition:=Condition+' And InvInBill.BillType2Code in (select BillType2Code from BillType2 where io2=0) '
    else
       Condition:=Condition+' And InvInBill.BillType2Code='''+getCode(cmbbx_BillType2Code.text)+'''';
    ConditionHint:=ConditionHint+' 出库类型: '+cmbbx_BillType2Code.Text;
  end;

  if(Edt_StArtAmount.Text<>'')then
  begin
    Condition:=Condition+' And InvInBillline.InvBillQty>='+Edt_StArtAmount.Text;
    ConditionHint:=ConditionHint+' 数量:从 '+Edt_StArtAmount.Text;
  end;
  if(Edt_EndAmount.Text<>'')then
  begin
    Condition:=Condition+' And InvInBillline.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 InvInBill.PrintTimes=0 ' ;
  checksql:='';
  if chbx_Check0.Checked then
    checksql:=' (Sourceno='''' and InvBillStkchck=0 and realBillflag=1) ';
  if chbx_Check01.Checked then
  begin
    if checksql='' then
      checksql:=' (Sourceno='''' and InvBillStkchck=1 ) '
    else
      checksql:=checksql+' or (Sourceno='''' and InvBillStkchck=1 ) ';
  end;
  if chbx_Check01red.Checked then
  begin
    if checksql='' then
      checksql:=' (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select a.whCode+a.minInvBillno from '
               +' (select  min(InvBillno) as minInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''R'' and Sourceno<>'''' '
               +' group by Sourceno,whCode ) a )) '
    else
      checksql:=checksql+' or (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select a.whCode+a.minInvBillno from '
               +' (select  min(InvBillno) as minInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''R'' and Sourceno<>'''' '
               +' group by Sourceno,whCode ) a )) ';
  end;
  if chbx_Checkend0.Checked then
  begin
    if checksql='' then
      checksql:=' (Sourceno='''' and InvBillStkchck=1 and realBillflag=1 and InvBillValuation=1) or '
               +' (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select b.whCode+maxInvBillno from '
               +' (select  max(InvBillno) as maxInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''B'' and Sourceno<>'''' and InvBillValuation=1 '
               +' group by whCode,Sourceno ) b) ) '
    else
      checksql:=checksql+' or (Sourceno='''' and InvBillStkchck=1 and realBillflag=1 and InvBillValuation=1) or '
               +' (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select b.whCode+maxInvBillno from '
               +' (select  max(InvBillno) as maxInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''B'' and Sourceno<>'''' and InvBillValuation=1 '
               +' group by whCode,Sourceno ) b) ) ';
  end;
  if chbx_Checkend1.Checked then
  begin
    if checksql='' then
      checksql:=' (Sourceno='''' and InvBillStkchck=1 and realBillflag=1 and InvBillValuation=0) or '
               +' (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select c.whCode+maxInvBillno from '
               +' (select  max(InvBillno) as maxInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''B'' and Sourceno<>'''' and InvBillValuation=0 '
               +' group by whCode,Sourceno ) c) ) '
    else
      checksql:=checksql+' or (Sourceno='''' and InvBillStkchck=1 and realBillflag=1 and InvBillValuation=0) or '
               +' (InvInBill.whCode+InvInBill.InvBillno in '
               +' ( select c.whCode+maxInvBillno from '
               +' (select  max(InvBillno) as maxInvBillno ,whCode,Sourceno from InvInBill '
               +' where bluered=''B'' and Sourceno<>'''' and InvBillValuation=0 '
               +' group by whCode,Sourceno ) c) ) ';
  end;
  if checksql<>'' then
    Condition:=Condition+' and '+'('+checksql+')';

  {
  if chbx_Price.Checked then
   //原始单据+最小红单+最大蓝单
   // Condition:=Condition+' And InvInBill.RealBillFlag=1 ' ;
   Condition:=Condition+' and ( Sourceno='''' or  (InvInBill.whCode+InvInBill.InvBillno in ( select a.whCode+minInvBillno from (select  min(InvBillno) as minInvBillno ,whCode,Sourceno from InvInBill '
                       +' where bluered=''R'' and Sourceno<>'''' '
                       +' group by Sourceno,whCode ) as a)  )'
                       +' or '
                       +' (InvInBill.whCode+InvInBill.InvBillno in ( select b.whCode+maxInvBillno from (select  max(InvBillno) as maxInvBillno ,whCode,Sourceno from InvInBill '
                       +' where bluered=''B'' and Sourceno<>'''' '
                       +' group by whCode,Sourceno ) as b) ))';
   }

  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OtherInBillListQty_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_OtherInBillListQty_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_OtherInBillListQty_C.FormCreate(Sender: TObject);
begin
  inherited;
  MEdt_StArtDate.Text:=FormatDateTime('yyyy.mm.dd',incMonth(now,-1));
  MEdt_EndDate.Text:=FormatDateTime('yyyy.mm.dd',Now);
  cmbbx_OutType.ItemIndex:=0;
end;

procedure TFrm_Inv_OtherInBillListQty_C.ExtEdt_OutCodeExit(
  Sender: TObject);
begin
  //inherited;
  if cmbbx_OutType.text='供应商' then
     VendorCodecheck(sender)
  else if cmbbx_OutType.text='部门' then
    DeptCodecheck(sender)
  else
    lbl_OutName.Caption:='';
end;

procedure TFrm_Inv_OtherInBillListQty_C.ExtEdt_OutCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
 // inherited;
  if key=vk_F9 then
  begin
    if cmbbx_OutType.text='供应商' then  UsableVendorHint(sender,key,shift);
    if cmbbx_OutType.text='部门' then  DeptHint(sender,key,shift);
  end
end;

procedure TFrm_Inv_OtherInBillListQty_C.ExtEdt_OutCodeEnter(
  Sender: TObject);
begin
  inherited;
  if (cmbbx_OutType.text='全部') or (cmbbx_OutType.text='') then
  begin
     Extedt_OutCode.ReadOnly:=True;
     Extedt_OutCode.text:='';
     lbl_OutName.Caption:='';
  end
  else
  begin
    Extedt_OutCode.ReadOnly:=False;
  end;
end;

procedure TFrm_Inv_OtherInBillListQty_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;
end.

⌨️ 快捷键说明

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