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

📄 sfc_monthsumqrybcppj.pas

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


Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls;

Type
  TFrm_Sfc_MonthSumQrybcppj = Class(TFrm_Base_Qry)
    DBText1: TDBText;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Button1: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure AdoQueryAfterOpen(DataSet: TDataSet);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    DeptCode,theMonth:string;
    procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    procedure GetData; Override;
  end;

var
  Frm_Sfc_MonthSumQrybcppj: TFrm_Sfc_MonthSumQrybcppj;

implementation

uses Sfc_MonthSumQrybcppj_C, Sfc_MonthSumQrybcppj_D;

{$R *.DFM}

procedure TFrm_Sfc_MonthSumQrybcppj.InitForm(AdOConnection: TAdOConnection;
  ShowExtendColumn: Boolean);
begin
  inherited;
  AmountFields:='aInvBlncQty,aInvOutQty,aInvInQty,aInvLMQty,';
  PriceFields:='Price1,Price2,Price3,Price4,';
  try
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Drop TABLE #MonthSumQry,#MonthSumQry1,#MonthSumQry2,#sonItemCode';
    AdoQry_Tmp.ExecSQL;
  except
  end;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='CREATE TABLE #MonthSumQry ('
    +' [JournalQryId] [numeric](18, 0) IDENTITY (1, 1) NOT NULL'
    +',[ItemCode] [varchAr] (16) NULL'
    +',[DeptCode] [varchAr] (8) NULL'
    +',[whCode] [varchAr] (8) NULL'
    +',[InvLMQty] [float] default 0'
    +',[InvLMAmount] decimal(14,2) default 0'
    +',[InvInQty] [float] default 0'
    +',[InvInAmount] decimal(14,2) default 0'
    +',[InvoutQty] [float] default 0'
    +',[InvoutAmount] decimal(14,2) default 0'
    +',[InvBlncQty] [float] default 0'
    +',[InvBlncAmount] decimal(14,2) default 0'
    +',[Dept] [varchAr](8) NULL'
    +' )'
    +' CREATE TABLE #MonthSumQry1 ('
    +' [JournalQryId] [numeric](18, 0) IDENTITY (1, 1) NOT NULL'
    +',[DeptCode] [varchAr] (8) NULL'
    +',[ItemCode] [varchAr] (16) NULL'
    +',[InvLMQty] [float] default 0'
    +',[InvLMAmount] decimal(14,2) default 0'
    +',[InvInQty] [float] default 0'
    +',[InvInAmount] decimal(14,2) default 0'
    +',[InvoutQty] [float] default 0'
    +',[InvoutAmount] decimal(14,2) default 0'
    +',[InvBlncQty] [float] default 0'
    +',[InvBlncAmount] decimal(14,2) default 0'
    +' )'
    +' CREATE TABLE #MonthSumQry2 ('
    +' [JournalQryId] [numeric](18, 0) IDENTITY (1, 1) NOT NULL'
    +',[DeptCode] [varchAr] (8) NULL'
    +',[ItemCode] [varchAr] (16) NULL'
    +',[InvLMQty] [float] default 0'
    +',[InvLMAmount] decimal(14,2) default 0'
    +',[InvInQty] [float] default 0'
    +',[InvInAmount] decimal(14,2) default 0'
    +',[InvoutQty] [float] default 0'
    +',[InvoutAmount] decimal(14,2) default 0'
    +',[InvBlncQty] [float] default 0'
    +',[InvBlncAmount] decimal(14,2) default 0'
    +' )'
    +' CREATE TABLE #sonItemCode('
    +' [DeptCode] [varchAr] (8) null '
    +',[ite_ItemCode] [varchAr] (16) NULL'
    +',[ItemCode] [varchAr] (16) NULL'
    +',[Bomqty] [float] default 0'
    +',[BomScrAp_Percent] [float] default 0'
    +',[sonqty] [float] default 0'
    +',[BomItemType] int,flag int)';
  AdoQry_Tmp.ExecSQL;
  OrderByFields:='DeptCodeName,ItemCode';

  Frm_Sys_Condition:=TFrm_Sfc_MonthSumQrybcppj_C.Create(Self);
  Act_Filter.Execute;
end;

procedure TFrm_Sfc_MonthSumQrybcppj.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  try
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Drop TABLE #MonthSumQry,#MonthSumQry1,#MonthSumQry2,#sonItemCode';
    AdoQry_Tmp.ExecSQL;
  except
  end;
end;

procedure TFrm_Sfc_MonthSumQrybcppj.GetData;
begin
  SelectFromSQL:=Condition;
  Condition:='';
  inherited;
end;

procedure TFrm_Sfc_MonthSumQrybcppj.AdoQueryAfterOpen(DataSet: TDataSet);
var
  sql_txt:string;
  i:integer;
  sumAmounts,sumAmountr,sumAmountc,sumAmountb:real;
begin
  inherited;
  sumAmounts:=0;
  sumAmountr:=0;
  sumAmountc:=0;
  sumAmountb:=0;
  //计算汇总金额
  If Not AdoQry_Main.IsEmpty then
  begin
    AdoQry_Main.DisableControls;
    AdoQry_Main.First;
    for I:=0 to AdoQry_Main.RecordCount-1 do
    begin
      SumAmounts:=SumAmounts+AdoQry_Main.fieldbyname('aInvLMQty').asFloat;
      SumAmountr:=SumAmountr+AdoQry_Main.fieldbyname('aInvInQty').asFloat;
      SumAmountc:=SumAmountc+AdoQry_Main.fieldbyname('aInvOutQty').asFloat;
      SumAmountb:=SumAmountb+AdoQry_Main.fieldbyname('aInvBlncQty').asFloat;
      AdoQry_Main.next;
    end;
    AdoQry_Main.First;
    AdoQry_Main.enableControls;
  end;
  edit1.text:=FormatFloat('#.##',SumAmounts);
  edit2.text:=FormatFloat('#.##',SumAmountr);
  edit3.text:=FormatFloat('#.##',SumAmountc);
  edit4.text:=FormatFloat('#.##',SumAmountb);
end;


procedure TFrm_Sfc_MonthSumQrybcppj.Button1Click(Sender: TObject);
begin
  inherited;
  Frm_Sfc_MonthSumQrybcppj_D:=TFrm_Sfc_MonthSumQrybcppj_D.Create(self);
  Frm_Sfc_MonthSumQrybcppj_D.InitForm(AdoQry_Main.Connection,False);
  Frm_Sfc_MonthSumQrybcppj_D.Showfilter(Lbl_Condition.Caption,DeptCode,theMonth);
  Frm_Sfc_MonthSumQrybcppj_D.Showmodal;

end;

end.

⌨️ 快捷键说明

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