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

📄 sfc_mninqry.pas

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

Interface

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

Type
  TFrm_Sfc_MnInQry = Class(TFrm_Base_Qry)
    Label1: TLabel;
    DBEdt_Item: TDBEdit;
    Label3: TLabel;
    AdoQry_MainItemCodeName: TStringField;
    AdoQry_MainUomName: TStringField;
    AdoQry_MainOverPlanQty: TFloatField;
    AdoQry_MainInPlanQty: TFloatField;
    AdoQry_MainOverPlanAmount: TBCDField;
    AdoQry_MainQtyDiffPercent: TStringField;
    procedure Act_FilterExecute(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Act_PreviewExecute(Sender: TObject);
    procedure Act_PrintExecute(Sender: TObject);
    procedure Act_ExcelExecute(Sender: TObject);
  private
    FStArtDate,FendDate,FDeptCode :String;
    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    { Public declarations }
  end;

var
  Frm_Sfc_MnInQry: TFrm_Sfc_MnInQry;

implementation
Uses Sfc_MnInQry_C;
{$R *.DFM}

{ TFrm_Sfc_MoInQry }

procedure TFrm_Sfc_MnInQry.InitForm(AdOConnection: TAdOConnection;
  ShowExtendColumn: Boolean);
begin
  inherited;
   Application.CreateForm(TFrm_Sfc_MnInQry_C,Frm_Sfc_MnInQry_C);
   Act_Filter.Execute;
end;

procedure TFrm_Sfc_MnInQry.Act_FilterExecute(Sender: TObject);
begin
//  inherited;
  Frm_Sfc_MnInQry_C.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
  Frm_Sfc_MnInQry_C.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
  Frm_Sfc_MnInQry_C.SetDBConnect(DBConnect);
  if Frm_Sfc_MnInQry_C.Showmodal=mrOk then
  begin
    Lbl_Condition.Caption:=Frm_Sfc_MnInQry_C.ConditionHint;
    FStArtDate:=Frm_Sfc_MnInQry_C.FStArtDate;
    FendDate:=Frm_Sfc_MnInQry_C.FendDate;
    FDeptCode:=Frm_Sfc_MnInQry_C.FDeptCode;
    SelectFromSql:=' select '+
                   '  Case  '+
                   '    When AllTable.OItemCode Is Null '+
                   '      Then AllTable.InItemCode+'' ''+Item.ItemName '+
                   ' Else AllTable.OItemCode+'' ''+Item.ItemName '+
                   ' end ItemCodeName '+
                   '  ,Uom.UomName,AllTable.OverPlanQty, '+
                   '  AllTable.InPlanQty,AllTable.OverPlanAmount, '+
                   ' Case '+
                   '   When AllTable.InPlanQty=0 then ''--'''+
                   '    else Convert(varchAr(20),AllTable.OverPlanQty/AllTable.InPlanQty) '+
                   ' end  QtyDiffPercent     '+
                   ' from (select * from '+
                   ' (select InvInBillline.ItemCode OItemCode,  '+
                   '    Sum(InvInBillline.InvBillQty) As OverPlanQty '+
                   '  ,Sum(InvInBillline.InvBillQty*StandardPrice.SPPrice) As OverPlanAmount '+
                   '  from InvInBillline,InvInBill,StandardPrice '+
                   ' where InvInBillline.InvBillId=InvInBill.InvBillId '+
                   '   and InvInBill.DeptCode='''+FDeptCode+''' and '+
                   '      InvInBill.OverPlan=1 '+
                   '   and InvInBill.InvBillDate between '''+FStArtDate+''''+
                   '                                 and '''+FendDate+''''+
                   '    and InvInBill.InvBillWHChck=1 '+
                   '    and StandardPrice.ItemCode=InvInBillLine.ItemCode '+
                   '    and StandardPrice.SPStArtMonth=InvInBill.InvBillMonth '+
                   '  Group by InvInBillline.ItemCode) OverPlanTable '+
                   '  Full Join '+
                   ' (select InvInBillline.ItemCode InItemCode, '+
                   '    Sum(InvInBillline.InvBillQty) As InPlanQty '+
                   '  from InvInBillline,InvInBill '+
                   '  where InvInBillline.InvBillId=InvInBill.InvBillId '+
                   '    and InvInBill.DeptCode='''+FDeptCode+''' and '+
                   '    InvInBill.OverPlan=0 '+
                   '   and InvInBill.InvBillDate between '''+FStArtDate+''''+
                   '                                 and '''+FendDate+''''+
                   '      and InvInBill.InvBillWHChck=1 '+
                   '  Group by InvInBillline.ItemCode) InTable '+
                   '    On OItemCode=InItemCode) AllTable '+
                   '  Left Join Item on (Item.ItemCode=Alltable.OItemCode) '+
                   '     Or (Item.ItemCode=AllTable.InItemCode) '+
                   '  Join Uom On Uom.UomCode=Item.UomCode ';

    OrderByFields:='ItemCodeName';
    Lbl_Condition.Caption:=Frm_Sfc_MnInQry_C.ConditionHint;
    GetData;
  end;

end;

procedure TFrm_Sfc_MnInQry.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Sfc_MnInQry_C.Release;
end;

procedure TFrm_Sfc_MnInQry.Act_PreviewExecute(Sender: TObject);
begin
  If AdoQry_Main.IsEmpty then Exit;
  inherited;

end;

procedure TFrm_Sfc_MnInQry.Act_PrintExecute(Sender: TObject);
begin
  If AdoQry_Main.IsEmpty then Exit;
  inherited;

end;

procedure TFrm_Sfc_MnInQry.Act_ExcelExecute(Sender: TObject);
begin
  If AdoQry_Main.IsEmpty then Exit;
  inherited;

end;

end.                                                 

⌨️ 快捷键说明

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