⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pm_enter_newsspoinfo2.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
          +' 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,poline           '
           +'  where (ordinal=2 )    '
            +'  and Orderlinestatus<>7   '
            +'  and Orderqty>onhand      '
            +'  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=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,#ss1.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,'
                +' OpCurrentInv.OpInv, '
                +' 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) '
                +' 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 '
                +' Left Join OpCurrentInv on #ss1.DeptVendorCode1=OpCurrentInv.OpInv '
//  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))'
                     +'  update #Ss                         '
                     +'    set PcNo=IsNull(PcLine.PcNo,''待分配'')                                                   '
                     +' from #Ss,PcLine,pc,VendorItemAssign                                                                         '
                     +' where #Ss.pcNo=''待分配''                                                                    '
                     +' And #Ss.SsDate>=PcLine.PcStArtDate And #Ss.SsDate<=PcLine.PcendDate              '
                     +'                 And ((#Ss.SsQty>=PcLine.PcStArtQty And #Ss.SsQty<PcLine.PcendQty) Or  '
                     +'                 (PcLine.PcStArtQty=0 And PcLine.PcendQty=0))   '
                     +' and #ss.ItemCode=PcLIne.ItemCode    '
                     +' and PcLine.PcNo=Pc.PcNo '
                     +' and Pc.VendorCode=VendorItemAssign.VendorCode '
                     +' and VendorItemAssign.AssignRate=100.00  '
                     +' delete from #SS '
                     +' where pcNo<>''待分配''' ;
  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_NewSsPoInfo2.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Pm_Enter_NewSsPoInfo2:=Nil;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo2.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 {如果选定了记录则弹出采购订单准备窗体}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -