📄 pm_enter_newsspoinfo3.pas
字号:
+' When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Null) Then '
+' (Select Top 1 PcLine.PcNo From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1)) '
+' When ((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate >=PcStArtDate And MrpResult.ReleaseDate< PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand< PcendQty ) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (MrpResult.DeptVendorCode is Null) '
+' And (MrpResult.ordinal=3) '
+' Then '
+''''+'待分配'+''''
+' Else '
+' Null '
+' end '
+'), '
+' ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=1,Poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=reMainqty '
+' into #ss1 from MrpResult '
+' left outer join poline on MrpResult.Orderno=Poline.Pono '
+' and MrpResult.Orderlineno=Poline.Polineno '
+' where (ordinal=3 ) '
+' and ((PmCode=1) or (PmCode=2) or (PmCode=3)) '
+' union '
+' select MrpResult.*, '
+' DeptVendorCode1=(select VendorCode from pc with(index(Pk_Pc)) where pcno= Case When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Not Null) Then '
+' (Select Top 1 PcLine.PcNo From PcLine with(index(Pk_PcLine)),Pc with(index(Pk_Pc)) '
+' Where PcLine.PcNo=Pc.PcNo '
+' And MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1) And Pc.VendorCode=MrpResult.DeptVendorCode) '
+' When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Null) Then '
+' (Select top 1 PcLine.PcNo From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1)) '
+' When ((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate >=PcStArtDate And MrpResult.ReleaseDate< PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand< PcendQty ) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (MrpResult.DeptVendorCode is Null) '
+' And (MrpResult.ordinal=3) '
+' Then '
+''''+'替代件待分配'+''''
+' Else '
+' Null '
+' end '
+'), '
+' ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=1,Poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=reMainqty '
+' from MrpResult '
+' left outer join poline on MrpResult.Orderno=Poline.Pono '
+' and MrpResult.Orderlineno=Poline.Polineno '
+' where (ordinal=3 ) '
+' and (PmCode=9) '
+' And ReMainQty>0 '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=3,poline.poqty,ssqty=MrpResult.Orderqty,Sysqty=MrpResult.Orderqty,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' And OrderLineStatus=6 And RealOrderQty<=0 '
+' and exists(select pono from poline where Orderno=poline.pono and Orderlineno=poline.polineno and poline.polinestatus<>7) '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=4,poline.poqty,ssqty=MrpResult.Orderqty,Sysqty=MrpResult.Orderqty,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' and Orderlinestatus=5 '
+' and onhand>0 '
+' and (releasedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate()) or duedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate())) '
+' and exists(select pono from poline where Orderno=poline.pono and Orderlineno=poline.polineno and poline.polinestatus<>7) '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=6,poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' And OrderLineStatus<>7 '
+' And CanUseOnHand=1 '
+' union '
+' select MrpResult.*, DeptVendorCode1=DeptVendorCode, '
+' ssid=MrpResultid,'
+' ssdate=releasedate, '
+' ssSysInfoflag=2, '
+' poline.poqty, '
+' ssqty=Orderqty-onhand, '
+' Sysqty=Orderqty-onhand, '
+' ssreMainqty=0 '
+' from MrpResult With(Index(Ordinal)),poline '
+' where (ordinal=2 ) '
+' and Orderlinestatus<>7 '
+' and Orderqty>onhand '
+' And MrpResult.ItemCode Not In (Select ItemCode From MrpResult With(Index(Ordinal)) Where Ordinal=4) '
+' and exists(select pono from poline where Orderno=poline.pono) '
+' and MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' union '
+' select MrpResult.*, DeptVendorCode1=DeptVendorCode, '
+' ssid=MrpResultid,'
+' ssdate=releasedate, '
+' ssSysInfoflag=5, '
+' poline.poqty, '
+' ssqty=Orderqty-onhand, '
+' Sysqty=Orderqty-onhand, '
+' ssreMainqty=0 '
+' from MrpResult With(Index(Ordinal)),poline '
+' where (ordinal=2 ) '
+' and Orderlinestatus<>7 '
+' and OrderQty>OnHand '
+' And MrpResult.ItemCode In (Select ItemCode From MrpResult With(Index(Ordinal)) Where Ordinal=4) '
+' and exists(select pono from poline where Orderno=poline.pono) '
+' and MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno ';
ExecuteCmd(AdOCmd_Mrp,SQlText);
SqlText:=' Select '
+' SSId,#Ss1.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,realreleasedate,'
+' SSDate,SSQty,convert(integer,#Ss1.PmCode) as PmType,SScheck, convert(float,GrossQty) as GrossRequireQty,' //convert(float,PlanInvQty) as PlanInvQty,'
+' OrderLineStatus, convert(varchAr,DeptVendorCode1) as DeptVendorCode,duedate,ReMainQty,'
+' ssReMainQty =case when (ssReMainQty=0) then null '
+' else'
+' ssReMainQty '
+' end ,'
+' Vendor.VendorCode,Vendor.VendorName,Item.MnldTime,Item.ItemName,Item.UomCode,Uom.UomName,Item.PmCode,Item.Qclt, '
+' Vendor.VendorCode+'''+' '+'''+Vendor.VendorName As VendorFlag,'
+' Case When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where #Ss1.ItemCode=PcLine.ItemCode '
+' And #Ss1.SsDate>=PcStArtDate And #Ss1.SsDate<=PcendDate '
+' And ((#Ss1.SsQty>=PcStArtQty And #Ss1.SsQty<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)=1) And (#Ss1.SsSysInfoFlag=1) Then '
+' (Select Top 1 PcLine.PcNo From PcLine '
+' Where #Ss1.ItemCode=PcLine.ItemCode '
+' And #Ss1.SsDate>=PcStArtDate And #Ss1.SsDate<=PcendDate '
+' And ((#Ss1.SsQty>=PcStArtQty And #Ss1.SsQty<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1) '
+' When ((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where #Ss1.ItemCode=PcLine.ItemCode '
+' And #Ss1.SsDate >=PcStArtDate And #Ss1.SsDate<=PcendDate '
+' And ((#Ss1.SsQty>=PcStArtQty And #Ss1.SsQty<PcendQty ) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (#Ss1.DeptVendorCode1 is Null) '
+' And (#Ss1.SsSysInfoFlag=1) '
+' and (#ss1.PmCode<>9)'
+' Then '
+''''+'待分配'+''''
+' When '
+' #Ss1.SsSysInfoFlag=1 and (#ss1.PmCode=9) Then'
+''''+'替代件待分配'+''''
+' Else '
+' Null '
+' end PcNo,'
+' ConVert(varchAr(20),SysSsInfo.SSCode)+'''+' '+'''+SysSsInfo.SsName As SsName, '
+' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag, '
+' Item.EmployeeCode,Employee.EmployeeName, '
+' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag '
+' into #ss From #SS1 '
+' Join Item On #SS1.ItemCode=Item.ItemCode '
+' And (#Ss1.PmCode=1 Or #Ss1.PmCode=2 Or #Ss1.PmCode=9) '
+' And Item.EmployeeCode='''+UserCode+''''
+' Join Uom On Item.UomCode=Uom.UomCode '
+' Join SysSsInfo On #Ss1.SSSysInfoFlag=SysSsInfo.SSCode '
+' Left Join Employee On Item.EmployeeCode=Employee.EmployeeCode '
+' Left Join Vendor On #Ss1.DeptVendorCode1=Vendor.VendorCode '
// ConditionUserDefine:=
+' where (((#Ss1.SsSysInfoFlag=1 '
+' And Item.LongPurchLT=0 And #Ss1.DueDate-(select PmParamValueN from PmParam '
+' where PmParamCode='''+'SSForwArdDay'+''')<='''+DateTimeToStr(Date())+''')'
+' Or (#Ss1.SsSysInfoFlag=1 And Item.LongPurchLT=1) Or (#Ss1.SsSysInfoFlag<>1)) '
+' And (((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where #Ss1.ItemCode=PcLine.ItemCode '
+' And (#Ss1.SsDate >=PcStArtDate And #Ss1.SsDate<=PcendDate) '
+' And ((#Ss1.SsQty>=PcStArtQty And #Ss1.SsQty< PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (#Ss1.DeptVendorCode1 is Null) '
+' And (#Ss1.SsSysInfoFlag=1)) and (#Ss1.SsQty<>0)) or ((#Ss1.SsSysInfoFlag=1) and (#ss1.PmCode=9))';
ExecuteCmd(AdOCmd_Mrp,SQlText);
Initselect;
if ShowAnimate<>nil then ShowAnimate.Free;
if ShowPanel<>nil then ShowPanel.Free;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select PmParamValueN from PmParam '
+' where PmParamCode='''+'SSForwArdDay'+'''';
AdoQry_Tmp.Open;
Lbl_Condition.Caption:='系统建议下达(约定开工日-'+FormatDateTime('yyyy.mm.dd',Date())+')'
+'<=建议可见提前天数('+IntToStr(AdoQry_Tmp.fieldbyname('PmParamValueN').AsInteger)+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select MrpParamValueC from MrpParam '
+' where MrpParamCode='''+'RunMrpDate'+'''';
AdoQry_Tmp.Open;
lab_RunMrpDate.Caption :=AdoQry_Tmp.fieldbyname('MrpParamValueC').AsString;
Application.ProcessMessages;
Checked:=False;
end;
procedure TFrm_Pm_Enter_NewSsPoInfo3.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Enter_NewSsPoInfo3:=Nil;
end;
procedure TFrm_Pm_Enter_NewSsPoInfo3.Act_NewExecute(Sender: TObject);
var
I:Boolean;
BookMArk:String;
begin
inherited;
frentform:=1;
If AdoQry_Main.RecordCount=0 Then
begin
Abort;
end;
// I:=False;
if AdoQry_Main.State=dsedit then AdoQry_Main.Post;
BookMArk:=AdoQry_Main.BookmArk;
{ AdoQry_Main.First;
While Not AdoQry_Main.Eof do
begin
If AdoQry_Main.fieldbyname('sScheck').AsInteger>0 Then
begin
I:=True;
BookMArk:=AdoQry_Main.BookmArk;
Break;
end;
AdoQry_Main.Next;
end;}
Executesql(AdoQry_tmp,'select * from #ss where sScheck=1',0);
if AdoQry_tmp.RecordCount>0 then {如果选定了记录则弹出采购订单准备窗体}
begin
falg:=1;
Frm_Pm_Enter_NewAutoPo:=TFrm_Pm_Enter_NewAutoPo.Create(Application);
Frm_Pm_Enter_NewAutoPo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Enter_NewAutoPo.SetFormParam(PcNo,IntToStr(PmCode),'','','','');
Frm_Pm_Enter_NewAutoPo.InitForm(DbConnect,'Add',AdoQry_Main);
Frm_Pm_Enter_NewAutoPo.ShowModal;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -