📄 pm_enter_sspoinfo.pas
字号:
Result:=True
else Result:=False;
end;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.btn_uPMrpClick(Sender: TObject);
var AdoQry:TAdoQuery;
sqltext:string;
begin
inherited;
{ if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger<>1 then
begin
activecontrol:=dbgrideh;
exit;
end;}
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
try
sqltext:='select distinct ItemCode,PmCode, min(releasedate) as releasedate '
+' into #tmPmm '
+' from MrpResult '
+' where ordinal=3 '
+' and ItemCode='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)
+' and PmCode<>9 '
+' group by ItemCode,PmCode '
+' select t1.ItemCode,t1.PmCode,t1.onhand,t1.oncheck,t1.Assignedqty,t1.releasedate,t1.ordinal '
+' into #tmponhandm '
+' from MrpResult t1, #tmPmm t2 '
+' where t1.ItemCode=t2.ItemCode '
+' and t1.releasedate=t2.releasedate '
+' and t1.ordinal=3 '
+' and t1.PmCode=t2.PmCode';
Executesql(AdoQry,sqltext,1);
sqltext:=' Select distinct Item.ItemCode,Item.ItemName,Item.minqty,MrpResult.PmCode,Item.Batchstrat,'+
' Itemflag=Item.ItemCode+'' ''+Item.ItemName,'+
' UomName=Uom.UomName,'+
' ldtime=case MrpResult.PmCode '+
' when 0 then Item.mnldtime '+
' else Item.purchldtime '+
' end,'+
' Item.Preparelt,'+
' Item.runlt,'+
' Item.Qclt,'+
' Item.PmBatch, '+
' #tmponhandm.onhand-isnull(#tmponhandm.Assignedqty,0) as CurrentonhandInv, '+
' Assignedqty=isnull(#tmponhandm.Assignedqty,0), '+
' #tmponhandm.oncheck as oncheckqty '+
//' Item.CurrentonhandInv '+
//' into #tmpItemResult'+
' From Item '+
' Join MrpResult On Item.ItemCode=MrpResult.ItemCode and MrpResult.ordinal=1'+
' Join #tmponhandm On Item.ItemCode=#tmponhandm.ItemCode and MrpResult.PmCode=#tmponhandm.PmCode '+
' left outer join Uom on Item.UomCode=Uom.UomCode ';
Executesql(AdoQry,sqltext,0);
if Frm_Mrp_Qry_UpRightMrp_D=nil then
begin
Frm_Mrp_Qry_UpRightMrp_D:=TFrm_Mrp_Qry_UpRightMrp_D.Create(Self);
Frm_Mrp_Qry_UpRightMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
Frm_Mrp_Qry_UpRightMrp_D.ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
Frm_Mrp_Qry_UpRightMrp_D.ItemName:=AdoQry.fieldbyname('ItemName').asstring;
Frm_Mrp_Qry_UpRightMrp_D.Uom:=AdoQry.fieldbyname('UomName').asstring;
Frm_Mrp_Qry_UpRightMrp_D.ldtime:=floattostr(AdoQry.fieldbyname('ldtime').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.Preparelt:=floattostr(AdoQry.fieldbyname('Preparelt').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.runlt:=floattostr(AdoQry.fieldbyname('runlt').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.Qclt:=floattostr(AdoQry.fieldbyname('Qclt').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.PmBatch:=floattostr(AdoQry.fieldbyname('PmBatch').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.ItemPmCode:=AdoQry.fieldbyname('PmCode').asinteger;
Frm_Mrp_Qry_UpRightMrp_D.CurrentInv:=floattostr(AdoQry.fieldbyname('CurrentonhandInv').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.RunMrp:=0;
Frm_Mrp_Qry_UpRightMrp_D.Assignedqty:=floattostr(AdoQry.fieldbyname('Assignedqty').asfloat);
Frm_Mrp_Qry_UpRightMrp_D.oncheckqty:=floattostr(AdoQry.fieldbyname('oncheckqty').asfloat);
if AdoQry.fieldbyname('PmCode').asinteger=0 then
Frm_Mrp_Qry_UpRightMrp_D.PmCode:='0 制造';
if AdoQry.fieldbyname('PmCode').asinteger=1 then
Frm_Mrp_Qry_UpRightMrp_D.PmCode:='1 采购';
if AdoQry.fieldbyname('PmCode').asinteger=2 then
Frm_Mrp_Qry_UpRightMrp_D.PmCode:='2 委外加工';
if AdoQry.fieldbyname('PmCode').asinteger=3 then
Frm_Mrp_Qry_UpRightMrp_D.PmCode:='3 既制造又委外';
Frm_Mrp_Qry_UpRightMrp_D.minqty:=floattostr(AdoQry.fieldbyname('minqty').asfloat);
if AdoQry.fieldbyname('Batchstrat').asinteger=0 then
Frm_Mrp_Qry_UpRightMrp_D.Batchstrat:='直接批量法';
if AdoQry.fieldbyname('Batchstrat').asinteger=1 then
Frm_Mrp_Qry_UpRightMrp_D.Batchstrat:='固定批量法';
try
Executesql(AdoQry,'drop table #tmponhandm,#tmPmm',1);
AdoQry.Free;
except
end;
Frm_Mrp_Qry_UpRightMrp_D.InitForm(AdoQry_Main.Connection,True);
end
else Frm_Mrp_Qry_UpRightMrp_D.Show;
finally
activecontrol:=dbgrideh;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.btn_OblongMrpClick(Sender: TObject);
begin
{ if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger<>1 then
begin
activecontrol:=dbgrideh;
exit;
end;}
// inherited;
try
if Frm_Mrp_Qry_OblongMrp_D=nil then
begin
Frm_Mrp_Qry_OblongMrp_D:=TFrm_Mrp_Qry_OblongMrp_D.Create(Self);
Frm_Mrp_Qry_OblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
Frm_Mrp_Qry_OblongMrp_D.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
Frm_Mrp_Qry_OblongMrp_D.mRunMrp:=0;
Frm_Mrp_Qry_OblongMrp_D.InitForm(dbconnect,True);
end
else Frm_Mrp_Qry_OblongMrp_D.Show;
finally
activecontrol:=dbgrideh;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.GetData;
begin
// inherited;
PcNo:='';
PmCode:=0;
Selected:=0;
if SelectFromSQL<>'' then
begin
AdoQry_Main.DisableControls;
AdoQry_Main.Close;
AdoQry_Main.SQL.clear;
AdoQry_Main.SQL.Text:=SelectFromSQL;
if(Condition<>'')then
begin
if(ConditionUserDefine<>'')then
AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+Condition+' and '+ConditionUserDefine
else
AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+Condition;
end
else if(ConditionUserDefine<>'')then
AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+ConditionUserDefine;
AdoQry_Main.Open;
AdoQry_Main.Sort:=OrderByFields;
AdoQry_Main.EnableControls;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.Button1Click(Sender: TObject);
begin
inherited;
{try
If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
if Frm_Mrp_Enter_MoSsParent=nil then
begin
Frm_Mrp_Enter_MoSsParent:=TFrm_Mrp_Enter_MoSsParent.Create(Self);
Frm_Mrp_Enter_MoSsParent.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
Frm_Mrp_Enter_MoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
Frm_Mrp_Enter_MoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
Frm_Mrp_Enter_MoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('realreleasedate').asdatetime);
Frm_Mrp_Enter_MoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
Frm_Mrp_Enter_MoSsParent.InitForm(dbconnect,True);
end
else Frm_Mrp_Enter_MoSsParent.Show;
finally
activecontrol:=dbgrideh;
end; }
try
If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
if Frm_Mrp_Enter_MoSsParent=nil then
begin
Frm_Mrp_Enter_MoSsParent:=TFrm_Mrp_Enter_MoSsParent.Create(Self);
Frm_Mrp_Enter_MoSsParent.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Mrp_Enter_MoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
Frm_Mrp_Enter_MoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
Frm_Mrp_Enter_MoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('ssdate').asdatetime);
Frm_Mrp_Enter_MoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
Frm_Mrp_Enter_MoSsParent.InitForm(dbconnect,True);
end
else Frm_Mrp_Enter_MoSsParent.Show;
finally
activecontrol:=dbgrideh;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.Button2Click(Sender: TObject);
begin
inherited;
try
If Frm_Pm_Enter_ClosePo1=Nil Then
begin
Frm_Pm_Enter_ClosePo1:=TFrm_Pm_Enter_ClosePo1.Create(Self);
Frm_Pm_Enter_ClosePo1.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Enter_ClosePo1.InItForm(Dbconnect,False);
end
else
Frm_Pm_Enter_ClosePo1.Show;
finally
ActiveControl:=DBGridEh;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.Act_SumExecute(Sender: TObject);
var
I:Boolean;
BookMArk:String;
begin
inherited;
If AdoQry_Main.RecordCount=0 Then
begin
Abort;
end;
I:=False;
BookMArk:=AdoQry_Main.BookmArk ;
AdoQry_Main.First;
While Not AdoQry_Main.Eof do
begin
If AdoQry_Main.fieldbyname('PcNo').AsString<>'' Then
begin
I:=True;
BookMArk:=AdoQry_Main.BookmArk ;
Break;
end;
AdoQry_Main.Next;
end;
If I=True Then
begin
Frm_Pm_Enter_SsPoInfo4:=TFrm_Pm_Enter_SsPoInfo4.Create(Application);
Frm_Pm_Enter_SsPoInfo4_C:=TFrm_Pm_Enter_SsPoInfo4_C.Create(Application);
Frm_Pm_Enter_SsPoInfo4_C.InitForm(DbConnect,'Add',AdoQry_Main);
Frm_Pm_Enter_SsPoInfo4_C.SetFormParam(PcNo,IntToStr(PmCode),'','','','');
Frm_Pm_Enter_SsPoInfo4_C.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Enter_SsPoInfo4_C.ShowModal;
Frm_Pm_Enter_SsPoInfo4_C.Free;
Frm_Pm_Enter_SsPoInfo4.InitForm(Dbconnect,False);
Frm_Pm_Enter_SsPoInfo4.SetFormParam(PcNo,IntToStr(PmCode),'','','','');
Frm_Pm_Enter_SsPoInfo4.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Enter_SsPoInfo4.Show;
end
Else
begin
AdoQry_Main.BookmArk:=BookMArk;
DispInfo('没有含合同号记录,不能执行汇总操作!',3);
Abort;
end;
AdoQry_Main.BookmArk:=BookMArk;
end;
procedure TFrm_Pm_Enter_SsPoInfo.DataSourceDataChange(Sender: TObject;
Field: TField);
begin
inherited;
if AdoQry_Main.Active = True then
begin
case AdoQry_Main.fieldbyname('SsSysInfoFlag').Asinteger of
1 :Label7.Caption :='' ;
2 :Label7.Caption :='应取消的原因:父项需求发生改变,当前数量的订单没有父项需求' ;
3 :Label7.Caption :='应关闭的原因:订单生产/(采购/委外加工)完毕' ;
4 :Label7.Caption :='应重排的原因:订单的约定交货日小于Mrp展开运算的日期' ;
end;
end;
end;
procedure TFrm_Pm_Enter_SsPoInfo.Button3Click(Sender: TObject);
begin
inherited;
Frm_Bas_Qry_MultiBomSViewMaster:=TFrm_Bas_Qry_MultiBomSViewMaster.Create(self);
Frm_Bas_Qry_MultiBomSViewMaster.InitForm(AdoQry_Tmp.Connection);
Frm_Bas_Qry_MultiBomSViewMaster.ExpandBom(AdoQry_Main.fieldbyname('ItemCode').asstring);
end;
procedure TFrm_Pm_Enter_SsPoInfo.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
if (AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger=2) or(AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger=4) then
AFont.Color:= clred;
end;
procedure TFrm_Pm_Enter_SsPoInfo.Button4Click(Sender: TObject);
var
BookmArk:string;
begin
inherited;
try
if AdoQry_Main.fieldbyname('PmType').asinteger=9 then
begin
Frm_Mrp_Enter_oldcommonAssignAlterNative:=TFrm_Mrp_Enter_oldcommonAssignAlterNative.Create(Application);
Frm_Mrp_Enter_oldcommonAssignAlterNative.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
Frm_Mrp_Enter_oldcommonAssignAlterNative.GetalterItem(dbconnect,AdoQry_Main.fieldbyname('ssid').asinteger);
Frm_Mrp_Enter_oldcommonAssignAlterNative.ShowModal;
try
BookmArk:=AdoQry_Main.BookmArk;
with AdoQry_Main do
begin
edit ;
fieldbyname('reMainQty').Asfloat:=fieldbyname('reMainQty').Asfloat- ite_ItemTotalAssignedqty;
post;
end;
AdoQry_tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text :=' update #ss Set reMainQty=reMainQty-'+floattostr(ite_ItemTotalAssignedqty)
+' ,ssreMainQty=ssreMainQty-'+floattostr(ite_ItemTotalAssignedqty)
+' where ssid='''+AdoQry_Main.fieldbyname('SsId').asstring+'''';
AdoQry_Tmp.ExecSQL;
GetData;
AdoQry_Main.BookmArk:=BookmArk;
except
end;
end;
finally
DBGridEh.SetFocus;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -