mrp_qry_uprightmrp_d_newmossparent.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 283 行
PAS
283 行
unit Mrp_Qry_UpRightMrp_D_NewMossParent;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Db, Menus, ExtPrintReport, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin;
Type
TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent = Class(TFrm_Base_Qry)
Panel1: TPanel;
Panel2: TPanel;
DBGridEh1: TDBGridEh;
AdoQuery1: TAdoQuery;
DataSource1: TDataSource;
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainItemType: TIntegerField;
AdoQry_MainPmCode: TIntegerField;
AdoQry_MainBatchStrat: TIntegerField;
AdoQry_MainMaxQty: TFloatField;
AdoQry_MainMinQty: TFloatField;
AdoQry_MainPurchLDTime: TFloatField;
AdoQry_MainItemflag: TStringField;
AdoQry_MainMNLDTime: TFloatField;
AdoQry_MainUomName: TStringField;
AdoQry_MainPmBatch: TIntegerField;
AdoQuery1Orderno: TStringField;
AdoQuery1Orderlineno: TIntegerField;
AdoQuery1Orderlinestatus: TIntegerField;
AdoQuery1Orderqty: TFloatField;
AdoQuery1duedate: TDateTimeField;
AdoQuery1releasedate: TDateTimeField;
AdoQuery1Itemflag: TStringField;
AdoQuery1UomName: TStringField;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
AdoQry_MainPrepareLT: TIntegerField;
AdoQry_MainRunLT: TIntegerField;
AdoQry_MainQcLT: TIntegerField;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label30: TLabel;
Bevel1: TBevel;
Label31: TLabel;
Label32: TLabel;
AdoQuery1MoNoFinishqty: TFloatField;
Label33: TLabel;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
lowItemPmCode:integer;
requiredate:string;
peggingno:string;
ItemCode:string;
traceType:integer;
Qclt:string;
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
function getlt(ItemCode:string;ltType:integer):integer;
procedure setItemInfo(ItemCode:string);
procedure setqtyInfo(peggingno,ItemCode:string);
{ Public declarations }
end;
var
Frm_Mrp_Qry_UpRightMrp_D_NewMossParent: TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Mrp_Qry_UpRightMrp_D_NewMossParent:=nil;
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.InitForm(
AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext,tMpsqltext,tmpcondition:string;
i:integer;
begin
Application.ProcessMessages;
inherited;
AdoQuery1.Connection:=AdoQry_Main.Connection;
//Executesql(AdoQry_Main,'select * from #tmpuPMrpResult1',0);
sqltext:='select MoLine.mono as Orderno, '
+' MoLine.MoLineno as Orderlineno, '
+' MoLine.MoLinestatus as Orderlinestatus, '
+' MoLine.moqty as Orderqty, '
+' MoLine.MoNoFinishqty, '
+' MoLine.mostArtworkdate as duedate, '
+' MoLine.MoLinedate as releasedate, '
// +' Bom.Bomqty, '
// +' ScrAprate=convert(varchAr,BomScrAp_Percent)+''%'', '
+' Itemflag=MoLine.ItemCode+'' ''+Item.ItemName, '
+' Item.Qclt,Item.Preparelt, '
+' Uom.UomName '
+' from MoLine,Uom,Item '
+' where MoLine.ItemCode=Item.ItemCode '
+' and Item.UomCode*=Uom.UomCode '
// +' and MoLine.ItemCode=Bom.ite_ItemCode '
// +' and Bom.ItemCode='+quotedstr(ItemCode)
+' and mono+convert(varchAr,MoLineno)='+quotedstr(peggingno)
+' union '
+' select poline.pono as Orderno, '
+' poline.polineno as Orderlineno, '
+' poline.polinestatus as Orderlinestatus, '
+' poline.poqty as Orderqty, '
+' poline.ponoFinishqty, '
+' poline.postArtworkdate as duedate, '
+' poline.polinedate as releasedate, '
// +' Bom.Bomqty, '
// +' ScrAprate=convert(varchAr,BomScrAp_Percent)+''%'', '
+' Itemflag=poline.ItemCode+'' ''+Item.ItemName, '
+' Item.Qclt,Item.Preparelt, '
+' Uom.UomName '
+' from poline,Uom,Item '
+' where poline.ItemCode=Item.ItemCode '
+' and Item.UomCode*=Uom.UomCode '
// +' and MoLine.ItemCode=Bom.ite_ItemCode '
// +' and Bom.ItemCode='+quotedstr(ItemCode)
+' and pono+convert(varchAr,polineno)='+quotedstr(peggingno);
//showmessage(sqltext);
Executesql(AdoQuery1,sqltext,0);
sqltext:='select Item.*,Uom.UomName,Itemflag=ItemCode+'' ''+ItemName'+
' from Item,Uom '+
' where Item.UomCode*=Uom.UomCode '+
' and ( (Item.ItemCode in (select ItemCode '+
' from MoLine '+
' where mono+convert(varchAr,MoLineno)='+quotedstr(peggingno)+'))'
+' or (Item.ItemCode in (select ItemCode '+
' from poline '+
' where pono+convert(varchAr,polineno)='+quotedstr(peggingno)+') ))';
Executesql(AdoQry_Main,sqltext,0);
setItemInfo(ItemCode);
setqtyInfo(peggingno,ItemCode);
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
try
Executesql(AdoQry_tmp,'drop table #tmpopenBom,#tmpopenBomResult,#tmpopenBomResult1,#tmpuPMrpResult,#tmpuPMrpResult1',1);
except
end;
end;
function TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.getlt(ItemCode: string;
ltType: integer): integer;
var AdoQry:TAdoQuery;
begin
Result:=0;
AdoQry:=TAdoQuery.Create(self);
AdoQry.EnableBCD:=False;
try
with AdoQry do
begin
Close;
Connection:=dbconnect;
sql.clear;
sql.Add('select Preparelt,Qclt,runlt from Item where ItemCode='
+quotedstr(ItemCode));
open;
case ltType of
1: Result:=fieldbyname('Preparelt').asinteger;
2: Result:=fieldbyname('Qclt').asinteger;
3: Result:=fieldbyname('runlt').asinteger;
end;
end;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.setItemInfo(
ItemCode: string);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.EnableBCD:=False;
AdoQry.Connection:=dbconnect;
sqltext:='select Item.*,Uom.UomName,Itemflag=ItemCode+'' ''+ItemName'+
' from Item,Uom '+
' where Item.UomCode*=Uom.UomCode '+
' and Item.ItemCode ='+quotedstr(ItemCode);
try
Executesql(AdoQry,sqltext,0);
label3.Caption:=ItemCode;
label4.Caption:=AdoQry.fieldbyname('ItemName').asstring;
label6.Caption:=AdoQry.fieldbyname('UomName').asstring;
case AdoQry.fieldbyname('ItemType').asinteger of
0: label8.Caption:='0 普通物料';
1: label8.Caption:='1 资源';
2: label8.Caption:='2 工具';
3: label8.Caption:='3 参考';
4: label8.Caption:='4 虚项';
5: label8.Caption:='5 劳务';
6: label8.Caption:='6 副产品';
7: label8.Caption:='7 成本';
end;
case AdoQry.fieldbyname('PmCode').asinteger of
0: label10.Caption:='0 制造';
1: label10.Caption:='1 采购';
2: label10.Caption:='2 委外';
3: label10.Caption:='3 既自制又委外';
end;
// label24.Caption:=floattostr(AdoQry.fieldbyname('mnldtime').asfloat);
// label26.Caption:=floattostr(AdoQry.fieldbyname('purchldtime').asfloat);
label28.Caption:=floattostr(AdoQry.fieldbyname('Preparelt').asfloat);
label30.Caption:=floattostr(AdoQry.fieldbyname('runlt').asfloat);
label32.Caption:=floattostr(AdoQry.fieldbyname('Qclt').asfloat);
case AdoQry.fieldbyname('Batchstrat').asinteger of
0: label12.Caption:='0 直接批量法';
1: label12.Caption:='1 固定批量法';
end;
label14.Caption:=floattostr(AdoQry.fieldbyname('PmBatch').asfloat);
label16.Caption:=floattostr(AdoQry.fieldbyname('maxqty').asfloat);
label18.Caption:=floattostr(AdoQry.fieldbyname('minqty').asfloat);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Mrp_Qry_UpRightMrp_D_NewMossParent.setqtyInfo(peggingno,
ItemCode: string);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.EnableBCD:=False;
AdoQry.Connection:=dbconnect;
if uppercase(copy(peggingno,1,1))='M' then
sqltext:='select moCtrlqty=sum(isnull(moCtrlqty,0)),MoRealqty=sum(isnull(MoRealqty,0))'+
' from mnItemList '+
' where mono+convert(varchAr,MoLineno)= '+quotedstr(peggingno)
+' and ItemCode ='+quotedstr(ItemCode)
else
sqltext:='select moCtrlqty=sum(isnull(poCtrlqty,0)),MoRealqty=sum(isnull(porealqty,0))'+
' from opItemList '+
' where pono+convert(varchAr,polineno)= '+quotedstr(peggingno)
+' and ItemCode ='+quotedstr(ItemCode);
try
Executesql(AdoQry,sqltext,0);
label20.Caption:=floattostr(AdoQry.fieldbyname('moCtrlqty').asfloat);
label22.Caption:=floattostr(AdoQry.fieldbyname('MoRealqty').asfloat);
finally
AdoQry.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?