📄 mrp_qry_uprightmrp_d_parentmo.pas
字号:
unit Mrp_Qry_UpRightMrp_D_ParentMo;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin;
Type
TFrm_Mrp_Qry_UpRightMrp_D_ParentMo = Class(TFrm_Base_Qry)
AdoQry_MainItemCode: TStringField;
AdoQry_MainDueDate: TDateTimeField;
AdoQry_MainReleaseDate: TDateTimeField;
AdoQry_MaInOrderNo: TStringField;
AdoQry_MainGrossQty: TFloatField;
AdoQry_MaInOrderQty: TFloatField;
AdoQry_MainOnHand: TFloatField;
AdoQry_MainCanUseOnHand: TFloatField;
AdoQry_MainNetQty: TFloatField;
AdoQry_MainOrdinal: TIntegerField;
AdoQry_MainSSCode: TIntegerField;
AdoQry_MainPmCode: TIntegerField;
AdoQry_MaInOrderLineStatus: TIntegerField;
AdoQry_MaInOrderLineno: TIntegerField;
AdoQry_Mainpegging: TStringField;
AdoQry_Mainoncheck: TFloatField;
AdoQry_MainItemflag: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainMrpqty: TFloatField;
AdoQry_MainBomqty: TFloatField;
AdoQry_MainScrAprate: TStringField;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
ItemCode:string;
requiredate:string;
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
{ Public declarations }
end;
var
Frm_Mrp_Qry_UpRightMrp_D_ParentMo: TFrm_Mrp_Qry_UpRightMrp_D_ParentMo;
implementation
uses Mrp_Qry_UpRightMrp_D,Sys_Global;
{$R *.DFM}
{ TFrm_Mrp_Qry_UpRightMrp_D_ParentMo }
procedure TFrm_Mrp_Qry_UpRightMrp_D_ParentMo.InitForm(
AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var
AdoQry_Tmp:TAdoQuery;
SqlText,Tmp_ItemCode:String;
I:Integer;
begin
AdoQry_Tmp:=TAdoQuery.Create(Nil);
AdoQry_tmp.EnableBCD:=False;
AdoQry_Tmp.Connection:=AdOConnection;
SqlText:=' Create Table #TmPmdlOpenBom(ItemCode varChAr(16),MNLDTime Float) '
+' Create Table #TmpOpenBom(ItemCode varChAr(16),MNLDTime Float) '
+' Create Table #TmpComponent(ItemCode varchAr(16),MNLDTime Float) '
+' Insert #TmpComponent(ItemCode,MNLDTime)Values('''+ItemCode+''',0) '
+' While Exists (Select * From #TmpComponent) '
+' begin '
+' Delete From #TmPmdlOpenBom '
+' Insert #TmPmdlOpenBom(ItemCode,MNLDTime) '
+' Select Ite_ItemCode As ItemCode,Case Item.PmCode '
+' When 1 then #TmpComponent.MNLDTime+Item.PurchLDTime '
+' When 2 then #TmpComponent.MNLDTime+Item.PurchLDTime '
+' Else #TmpComponent.MNLDTime+Item.MNLDTime '
+' end As MNLDTime '
+' From Bom '
+' Join Item On Bom.Ite_ItemCode=Item.ItemCode '
+' Join #TmpComponent On Bom.ItemCode=#TmpComponent.ItemCode '
+' Delete From #TmpComponent '
+' Insert #TmpComponent '
+' Select * From #TmPmdlOpenBom '
+' Insert #TmpOpenBom '
+' Select * From #TmPmdlOpenBom '
+' end '
+' Drop Table #TmpComponent '
+' Drop Table #TmPmdlOpenBom '
+' select * From #TmpOpenBom '
+' Drop Table #TmpOpenBom ';
AdoQry_Tmp.Close;
AdoQry_Tmp.Sql.Text:=SqlText;
AdoQry_Tmp.Open;
Tmp_ItemCode:='';
I:=0;
While NOT AdoQry_Tmp.Eof Do
begin
If I=0 Then
begin
Tmp_ItemCode:='(MrpResult.ItemCode='''+AdoQry_Tmp.fieldbyname('ItemCode').AsString +''' And '
+' MrpResult.releaseDate='''+SlCalendar(AdoConnection,requireDate,-AdoQry_Tmp.fieldbyname('MNLDTime').AsInteger)+''')';
end
Else
Tmp_ItemCode:=Tmp_ItemCode+' Or (MrpResult.ItemCode='''+AdoQry_Tmp.fieldbyname('ItemCode').AsString +''' And '
+' MrpResult.releaseDate='''+SlCalendar(AdoConnection,requireDate,-AdoQry_Tmp.fieldbyname('MNLDTime').AsInteger)+''')';
I:=I+1;
AdoQry_Tmp.Next;
end;
SelectFromSql:=' select distinct MrpResult.*,Bom.Bomqty,Mrpqty=case ordinal when 2 then Orderqty when 5 then netqty end, '
+' ScrAprate=convert(varchAr,Bom.BomScrAp_Percent)+''%'','
+' Itemflag=MrpResult.ItemCode+'' ''+Item.ItemName, '
+' Uom.UomName '
+' from MrpResult '
+' join Item on MrpResult.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode'
+' join Bom on MrpResult.ItemCode=Bom.ite_ItemCode';
ConditionUserDefine:='(ordinal=2 or ordinal=5) and Bom.ItemCode='+quotedstr(ItemCode)+' and ('+tmp_ItemCode+')';
OrderByFields:='ItemCode,dueDate ';
GetData;
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_ParentMo.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Mrp_Qry_UpRightMrp_D_Parentmo:=nil;
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_ParentMo.FormCreate(Sender: TObject);
begin
inherited;
tlbtn_Sum.Action:=action1;
tlbtn_look.Action:=action2;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -