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

📄 inv_otheriohsum_c.pas

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

Interface

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

Type
  TFrm_Inv_OtherIoHSum_C = Class(TFrm_Base_Condition)
    ChLstBx_WhSelect: TCheckListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    MEdt_StArtDate: TMaskEdit;
    MEdt_EndDate: TMaskEdit;
    CmBx_DeptVendorCustomer: TComboBox;
    CheckBox1: TCheckBox;
    procedure btn_okClick(Sender: TObject);
    procedure ChLstBx_WhSelectClickCheck(Sender: TObject);
    procedure MEdt_EndDateExit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Inv_OtherIoHSum_C: TFrm_Inv_OtherIoHSum_C;

implementation

uses Sys_Global,Inv_Global;

{$R *.DFM}

procedure TFrm_Inv_OtherIoHSum_C.btn_okClick(Sender: TObject);
var
  i:integer;
  DeptVendorCustomer,StrTemp,StrTemp1,BillName,InStrTemp,DeptVendorCustomerName:String;
begin
  inherited;
  if CmBx_DeptVendorCustomer.Text='本厂部门' then
  begin
    DeptVendorCustomer:='Dept';
    DeptVendorCustomerName:='部门';
  end
  else if CmBx_DeptVendorCustomer.Text='供应商' then
  begin
    DeptVendorCustomer:='Vendor';
    DeptVendorCustomerName:='供应商';
  end
  else if CmBx_DeptVendorCustomer.Text='客户' then
  begin
    DeptVendorCustomer:='Customer';
    DeptVendorCustomerName:='客户';
  end;
  if Param1='0199' then
    BillName:='InvInBill'
  else if Param1='0299' then
    BillName:='InvOutBill';
  StrTemp:='';
  StrTemp1:='';
  InStrTemp:='';
  for i:=0 to ChLstBx_WhSelect.Items.Count-1 do
  begin
    if ChLstBx_WhSelect.Checked[i] then
    begin
      StrTemp:=StrTemp+',Sum'+IntToStr(i)+'.SumAmount'
        +' As ['+GetName(ChLstBx_WhSelect.Items[i])+']';
      StrTemp1:=StrTemp1+' Left Join (Select '+BillName+'.'+DeptVendorCustomer
        +'Code,Sum(InvBillNoTaxAmount) As SumAmount From '+BillName+'Line'
        +' Join '+BillName+' On '+BillName+'Line.InvBillId='+BillName+'.InvBillId'
        +' Where '+BillName+'.BillType2Code='''+GetCode(ChLstBx_WhSelect.Items[i])
        +''' And '+BillName+'.InvBillMonth>='''+MEdt_StArtDate.Text+''''
        +' And '+BillName+'.InvBillMonth<='''+MEdt_EndDate.Text+''''
        +' Group By '+BillName+'.'+DeptVendorCustomer+'Code) Sum'+IntToStr(i)
        +' On '+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code=Sum'+IntToStr(i)
        +'.'+DeptVendorCustomer+'Code';
      if InStrTemp='' then
        InStrTemp:=''''+GetCode(ChLstBx_WhSelect.Items[i])+''''
      else
        InStrTemp:=InStrTemp+','''+GetCode(ChLstBx_WhSelect.Items[i])+'''';
    end;
  end;
  StrTemp:=StrTemp+',SumTatol.SumAmount'
  +' As '+'合计';
  StrTemp1:=StrTemp1+' Left Join (Select '+BillName+'.'+DeptVendorCustomer
    +'Code,Sum(InvBillNoTaxAmount) As SumAmount From '+BillName+'Line'
    +' Join '+BillName+' On '+BillName+'Line.InvBillId='+BillName+'.InvBillId'
    +' Where '+BillName+'.BillType2Code In ('+InStrTemp+')'
    +' And '+BillName+'.InvBillMonth>='''+MEdt_StArtDate.Text+''''
    +' And '+BillName+'.InvBillMonth<='''+MEdt_EndDate.Text+''''
    +' Group By '+BillName+'.'+DeptVendorCustomer+'Code) SumTatol'
    +' On '+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code=SumTatol'
    +'.'+DeptVendorCustomer+'Code';
    
  Condition:='Select '+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code'
    +' As '+DeptVendorCustomerName+'代码'
    +','+DeptVendorCustomer+'.'+DeptVendorCustomer+'Name'
    +' As '+DeptVendorCustomerName+'名称'
    +','+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code+'' ''+'
      +DeptVendorCustomer+'.'+DeptVendorCustomer+'Name'
    +' As '+DeptVendorCustomerName+'标识'
    +StrTemp
    +' From '+DeptVendorCustomer
    +StrTemp1
    +' Where '+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code is not Null'
    +' And '+DeptVendorCustomer+'.'+DeptVendorCustomer+'Code In'
    +' (Select '+DeptVendorCustomer+'Code From '+BillName
    +' Where '+BillName+'.BillType2Code In ('+InStrTemp+')'
    +' And '+BillName+'.InvBillMonth>='''+MEdt_StArtDate.Text+''''
    +' And '+BillName+'.InvBillMonth<='''+MEdt_EndDate.Text+''')';
    
  ConditionHint:='月份:从 '+MEdt_StArtDate.Text+' 到 '+MEdt_EndDate.Text
    +'/'+Label4.Caption+' '+CmBx_DeptVendorCustomer.Text;
  
  ModalResult:=mrOk;
end;

procedure TFrm_Inv_OtherIoHSum_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_OtherIoHSum_C.MEdt_EndDateExit(Sender: TObject);
begin
  inherited;  
  if ActiveControl.Name='btn_Cancel' then
    Exit;
  MonthCheck(Sender);
  if StrToDateTime(MEdt_EndDate.Text+'.01')<StrToDateTime(MEdt_StArtDate.Text+'.01')then
  begin
    DispInfo('查询终止月份不能小于起始月份!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
  InvDataChangeCheck(AdoQry_Tmp,TEdit(Sender).Text);
end;

procedure TFrm_Inv_OtherIoHSum_C.FormCreate(Sender: TObject);
begin
  inherited;
  MEdt_StArtDate.Text:=FormatDateTime('yyyy.mm',IncMonth(Now,-1));
  MEdt_EndDate.Text:=FormatDateTime('yyyy.mm',Now);
end;

procedure TFrm_Inv_OtherIoHSum_C.FormActivate(Sender: TObject);
begin
  inherited;
  if ChLstBx_WhSelect.Items.Count=0 then
  with AdoQry_Tmp do
  begin
    Close;
    if Param1='0199' then
    begin
      Label4.Caption:='入库对象:';
      Label1.Caption:='入库类型:';
      SQL.Text:='Select BillType2Code+'' ''+BillType2Name As CodeName From BillType2'
        +' Where IO2=0'
        +' Order By BillType2Code';
    end
    else if Param1='0299' then
    begin
      Label4.Caption:='出库对象:';
      Label1.Caption:='出库类型:';
      SQL.Text:='Select BillType2Code+'' ''+BillType2Name As CodeName From BillType2'
        +' Where IO2=1'
        +' Order By BillType2Code';
    end;
    Open;
    First;
    while not Eof do
    begin
      ChLstBx_WhSelect.Items.Add(fieldbyname('CodeName').AsString);
      AdoQry_Tmp.Next;
    end;
  end; 
  if CmBx_DeptVendorCustomer.Text='' then
    CmBx_DeptVendorCustomer.ItemIndex:=0;
end;

procedure TFrm_Inv_OtherIoHSum_C.CheckBox1Click(Sender: TObject);
var
 i:integer;
begin
  inherited;
  if CheckBox1.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 + -