📄 pm_enter_possparent.pas
字号:
+' Item.Qclt,'
+' Item.Preparelt,'
+' 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.ItemCode'
+' where (ordinal=2 or ordinal=5) and Bom.ite_ItemCode='
+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)
+'and MrpResult.ItemCode= '+quotedstr(copy(strpath,1,pos(',',strpath)-1))
+' and MrpResult.releasedate='+quotedstr(slCalendar(dbconnect,AdoQry_Main.fieldbyname('duedate').asstring,fieldbyname('Qclt').asinteger+AdoQry_Main.fieldbyname('Preparelt').asinteger))
else
tMpsqltext:='insert into #tmpuPMrpResult'
+' 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, '
+' Item.Qclt,'
+' Item.Preparelt,'
+' 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.ItemCode'
+' where (ordinal=2 or ordinal=5) and Bom.ite_ItemCode='
+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)
+'and MrpResult.ItemCode= '+quotedstr(copy(strpath,1,pos(',',strpath)-1))
+' and MrpResult.releasedate='+quotedstr(slCalendar(dbconnect,AdoQry_Main.fieldbyname('duedate').asstring,AdoQry_Main.fieldbyname('Preparelt').asinteger));
Executesql(AdoQry,tMpsqltext,1);
next;
end;
end;
Executesql(AdoQry_Main,'select * from #tmpuPMrpResult',0);
finally
AdoQry.free;
end;
strpath:=copy(strpath,pos(',',strpath)+1,length(strpath)-pos(',',strpath));
end;
procedure TFrm_Pm_Enter_PoSsParent.Action2Execute(Sender: TObject);
var tMpstr:string;
begin
inherited;
tMpstr:=strpath;
if not existsfArItemCode(AdoQry_Main.fieldbyname('ItemCode').asstring) then
begin
DispInfo(AdoQry_Main.fieldbyname('ItemCode').asstring+'无父项物料!',3);
exit;
end;
strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+','+strpath;
if not ifexistsiteItemCode(AdoQry_Main.fieldbyname('ItemCode').asstring,AdoQry_Main.fieldbyname('releasedate').asstring,inttostr(AdoQry_Main.fieldbyname('Qclt').asinteger)) then
begin
DispInfo(AdoQry_Main.fieldbyname('ItemCode').asstring+'无父项物料需求!',3);
strpath:=tMpstr;
exit;
end;
tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
Executesql(AdoQry_Main,'select * from #tmpuPMrpResult',0);
end;
procedure TFrm_Pm_Enter_PoSsParent.FormCreate(Sender: TObject);
begin
inherited;
tlbtn_Sum.Action:=action1;
tlbtn_look.Action:=action2;
end;
function TFrm_Pm_Enter_PoSsParent.ifexistsiteItemCode(ItemCode,
date,Qclt: string): boolean;
var AdoQry:TAdoQuery;tMpsqltext:string;
begin
Result:=False;
AdoQry:=TAdoQuery.Create(self);
AdoQry.EnableBCD := False;
AdoQry.Connection:=dbconnect;
try
try
Executesql(AdoQry_tmp,'drop table #tmpopenBom,#tmpopenBomResult,#tmpuPMrpResult',1);
except
end;
tMpsqltext:=' select top 0 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, '
+' Item.Qclt, '
+' Item.Preparelt,'
+' Uom.UomName '
+' into #tmpuPMrpResult '
+' 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';
Executesql(AdoQry_tmp,tMpsqltext,1);
Bomopen(dbconnect,ItemCode);
//tMpsqltext:='select Bom.ite_ItemCode as ItemCode,Item.Preparelt from Bom,Item where Bom.ite_ItemCode=Item.ItemCode and Bom.ItemCode='+quotedstr(ItemCode);
tMpsqltext:='select distinct ItemCode,Preparelt,Bomqty=sum(Bomqty),BomScrAprate=sum(BomScrAprate) '
+' into #tmpopenBomResult '
+' From #TmpOpenBom '
+' group by ItemCode,Preparelt';
Executesql(AdoQry_tmp,tMpsqltext,1);
Executesql(AdoQry_tmp,'select * from #tmpopenBomResult',0);
with AdoQry_tmp do
begin
First;
while not eof do
begin
if tmplowPmCode=0 then
tMpsqltext:='insert into #tmpuPMrpResult'
+' select distinct MrpResult.*,#tmpopenBomResult.Bomqty,Mrpqty=case ordinal when 2 then Orderqty when 5 then netqty end, '
+' ScrAprate=convert(varchAr,#tmpopenBomResult.BomScrAprate)+''%'','
+' Itemflag=MrpResult.ItemCode+'' ''+Item.ItemName, '
+' Item.Qclt,'
+' Item.Preparelt,'
+' Uom.UomName '
+' from MrpResult '
+' join Item on MrpResult.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode'
+' join #tmpopenBomResult on MrpResult.ItemCode=#tmpopenBomResult.ItemCode'
+' where (ordinal=2 or ordinal=5) '
+'and MrpResult.ItemCode= '+quotedstr(fieldbyname('ItemCode').asstring)
+' and MrpResult.duedate='+quotedstr(slCalendar(dbconnect,date,-(strtoint(Qclt)+fieldbyname('Preparelt').asinteger)))
else
tMpsqltext:='insert into #tmpuPMrpResult'
+' select distinct MrpResult.*,#tmpopenBomResult.Bomqty,Mrpqty=case ordinal when 2 then Orderqty when 5 then netqty end, '
+' ScrAprate=convert(varchAr,#tmpopenBomResult.BomScrAprate)+''%'','
+' Itemflag=MrpResult.ItemCode+'' ''+Item.ItemName, '
+' Item.Qclt,'
+' Item.Preparelt,'
+' Uom.UomName '
+' from MrpResult '
+' join Item on MrpResult.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode'
+' join #tmpopenBomResult on MrpResult.ItemCode=#tmpopenBomResult.ItemCode'
+' where (ordinal=2 or ordinal=5) '
+'and MrpResult.ItemCode= '+quotedstr(fieldbyname('ItemCode').asstring)
+' and MrpResult.duedate='+quotedstr(slCalendar(dbconnect,date,-(fieldbyname('Preparelt').asinteger)));
Executesql(AdoQry,tMpsqltext,1);
next;
end;
end;
Executesql(AdoQry,'select * from #tmpuPMrpResult',0);
if AdoQry.RecordCount>0 then
Result:=True
else
Result:=False;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Pm_Enter_PoSsParent.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
try
Executesql(AdoQry_tmp,'drop table #tmpopenBom,#tmpopenBomResult,#tmpuPMrpResult',1);
except
end;
end;
function TFrm_Pm_Enter_PoSsParent.existsfArItemCode(
ItemCode: string): boolean;
var AdoQry:TAdoQuery;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.EnableBCD := False;
try
with AdoQry do
begin
Close;
Connection:=dbconnect;
sql.clear;
sql.Add('select ite_ItemCode from Bom where ItemCode='
+quotedstr(ItemCode));
open;
if recordCount=0 then
Result:=False
else Result:=True;
end;
finally
AdoQry.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -