mrp_qry_analyzermrpmo_h.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 443 行 · 第 1/2 页
PAS
443 行
+' and MoLine.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and MoLine.MoLinedate > '+quotedstr(mindate)
+' and MoLine.MoLinedate<='+quotedstr(AdoQry.fieldbyname('requiredate').asstring);
Executesql(AdoQry_tmp,txt,0) ;
tmPMoNoFinishqty:=AdoQry_tmp.fieldbyname('MoNoFinishqty').asfloat;
txt:='update #tmpBomResult'
+' set wipqty= '+floattostr(tmpponoFinishqty+tmPMoNoFinishqty)
+' from #tmpBomResult '
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,1);
if (AdoQry.RecNo=1) or (AdoQry.fieldbyname('ItemCode').asstring<>tmpItemCode) then
begin
txt:='update #tmpBomResult'
+' set Planqty=CurrentonhandInv+CurrentonCheckInv,'
+' minflag=1 '
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,1);
end
else
begin
if AdoQry.fieldbyname('ItemCode').asstring=tmpItemCode then
begin
txt:='update #tmpBomResult'
+' set CurrentonCheckInv=0, '
+' CurrentonhandInv=case when '+floattostr(tmprequireqty)+'-('+floattostr(tmpPlanqty)+')>0 then 0 else '+floattostr(tmpPlanqty-tmprequireqty)+' end'
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,1);
end;
txt:='update #tmpBomResult'
+' set Planqty=case when '+floattostr(tmprequireqty)+'-('+floattostr(tmpPlanqty)+')-CurrentonCheckInv>0 then 0 else '+floattostr(tmpPlanqty-tmprequireqty)+'+CurrentonCheckInv end'
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,1);
end;
txt:='update #tmpBomResult'
+' set lessqty=case when netqty-Planqty>0 then netqty-Planqty else 0 end'
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,1);
txt:='select * from #tmpBomResult'
+' where #tmpBomResult.ItemCode='+quotedstr(AdoQry.fieldbyname('ItemCode').asstring)
+' and #tmpBomResult.mono='+quotedstr(AdoQry.fieldbyname('mono').asstring)
+' and #tmpBomResult.MoLineno='+inttostr(AdoQry.fieldbyname('MoLineno').asinteger);
Executesql(AdoQry_tmp,txt,0);
tmpPlanqty:=AdoQry_tmp.fieldbyname('Planqty').asfloat;
tmprequireqty:=AdoQry_tmp.fieldbyname('netqty').asfloat;
mindate:=AdoQry.fieldbyname('requiredate').asstring;
tmpItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
AdoQry.Next;
end;
if AdoQry<>nil then AdoQry.Free;
Application.ProcessMessages;
if Frm_Mrp_Qry_AnalyzerMrpMo=nil then
begin
Frm_Mrp_Qry_AnalyzerMrpMo:=TFrm_Mrp_Qry_AnalyzerMrpMo.Create(self);
Frm_Mrp_Qry_AnalyzerMrpMo.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
Frm_Mrp_Qry_AnalyzerMrpMo.Orderno:=AdoQry_Head.fieldbyname('mono').asstring;
Frm_Mrp_Qry_AnalyzerMrpMo.Orderlineno:=AdoQry_Head.fieldbyname('MoLineno').asinteger;
Frm_Mrp_Qry_AnalyzerMrpMo.InitForm(dbconnect,True);
end
else Frm_Mrp_Qry_AnalyzerMrpMo.Show;
AdoQry_Head.BookmArk:=BookmArk;
end;
procedure TFrm_Mrp_Qry_AnalyzerMrpMo_H.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('drop table #tmPMoLinenoFinish');
try
execsql;
except
end;
end;
inherited;
end;
procedure TFrm_Mrp_Qry_AnalyzerMrpMo_H.openBom(ItemCode:string;Mpsqty:real;requiredate:string);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(Application);
AdoQry.EnableBCD:=False;
AdoQry.Connection:=dbconnect;
try
sqltext:='Select Bom.ItemCode,Bom.BomItemType,Item.PmCode, '+#13+
' Item.MnLdTime, '+#13+
' t2.mnldtime as Itemnldtime, '+
floattostr(Mpsqty)+'*Bom.BomQty*(1+ BomScrAp_Percent/100) as requireqty,'
+' Item.ItemName,Item.CurrentonhandInv,Item.CurrentonCheckInv, '+#13+
' Itemflag=Bom.ItemCode+'' ''+Item.ItemName'+#13+
// ' into #tmpBom '+#13+
' From Bom '+#13+
' Join Item On Bom.ItemCode=Item.ItemCode '+#13+
' join Item t2 on t2.ItemCode=Bom.ite_ItemCode '+
' where Bom.ite_ItemCode='''+ItemCode+''''+
' and Bom.Bomstatus in (0,2) ';
Executesql(AdoQry,sqltext,0);
with AdoQry do
begin
First;
while not eof do
begin
if fieldbyname('BomItemType').asinteger<>3 then
begin
sqltext:='insert into #tmpBom '
+'Values('+quotedstr(fieldbyname('ItemCode').asstring)+','
+quotedstr(AdoQry_Head.fieldbyname('mono').asstring)+','
+inttostr(AdoQry_Head.fieldbyname('MoLineno').asinteger)+','
+inttostr(fieldbyname('BomItemType').asinteger)+','
+inttostr(fieldbyname('PmCode').asinteger)+','
+quotedstr(slCalendar(dbconnect,requiredate,(fieldbyname('Itemnldtime').asinteger)))+','
+floattostr(fieldbyname('requireqty').asfloat)+','
+quotedstr(fieldbyname('ItemName').asstring)+','
+floattostr(fieldbyname('CurrentonhandInv').asfloat)+','
+floattostr(fieldbyname('CurrentonCheckInv').asfloat)+','
+quotedstr(fieldbyname('Itemflag').asstring)
+')';
Executesql(AdoQry_tmp,sqltext,1);
end;
if existssonItem(fieldbyname('ItemCode').asstring) and (fieldbyname('BomItemType').asinteger=3) then
openBom(fieldbyname('ItemCode').asstring,fieldbyname('requireqty').asfloat,slCalendar(dbconnect,requiredate,-(fieldbyname('mnldtime').asinteger)));
next;
end;
end;
finally
AdoQry.Free;
end;
end;
function TFrm_Mrp_Qry_AnalyzerMrpMo_H.existssonItem(ItemCode:string):boolean;
var AdoQry:TAdoQuery;
sqltext:string;
begin
Result:=False;
AdoQry:=TAdoQuery.Create(Application);
AdoQry.EnableBCD:=False;
AdoQry.Connection:=dbconnect;
sqltext:='select ItemCode from Bom where ite_ItemCode='+quotedstr(ItemCode);
// +' and ItemCode not in (select ItemCode from Item where PmCode=1 or PmCode=2)';
try
Executesql(AdoQry,sqltext,0);
if AdoQry.RecordCount>0 then
Result:=True;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Mrp_Qry_AnalyzerMrpMo_H.DBGridEhTitleClick(
Column: TColumnEh);
var BookmArk : String;
begin
inherited;
If Trim(Column.Title.Caption)<>'标记' Then
Abort;
If AdoQry_Head.RecordCount=0 Then
Abort;
BookMArk:=AdoQry_Head.BookmArk;
If Not Flag Then
begin
AdoQry_Head.First;
While Not AdoQry_Head.Eof Do
begin
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('CheckFlag').AsInteger:=1;
AdoQry_Head.Post;
AdoQry_Head.Next;
end;
end
Else
begin
AdoQry_Head.First;
While Not AdoQry_Head.Eof Do
begin
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('CheckFlag').AsInteger:=0;
AdoQry_Head.Post;
AdoQry_Head.Next;
end;
end;
AdoQry_Head.BookmArk:=BookMArk;
Flag:=Not Flag;
end;
procedure TFrm_Mrp_Qry_AnalyzerMrpMo_H.AdoQry_HeadAfterPost(
DataSet: TDataSet);
begin
inherited;
if AdoQry_Head.fieldbyname('CheckFlag').AsInteger=1 then
inc(SelectedCount)
else if SelectedCount>0 then dec(SelectedCount);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?