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

📄 pm_enter_sspoinfo4.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  begin
   DispInfo('不能一次选中两个不相同可用采购合同号!',3);
   Abort;
  end;
end;

procedure TFrm_Pm_Enter_SsPoInfo4.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
  inherited;
  If AdoQry_Main.fieldbyname('SScheck').AsInteger=1 Then
  begin
    Selected:=Selected+1;
    PcNo:=AdoQry_Main.fieldbyname('PcNo').AsString;
    PmCode:=AdoQry_Main.fieldbyname('PmType').AsInteger;
  end
  Else
  begin
    if PcNo<>'' then
    Selected:=Selected-1;
    If Selected=0 Then
    begin
       PcNo:='';
       PmCode:=0;
    end;
  end;

end;

procedure TFrm_Pm_Enter_SsPoInfo4.DBGridEhTitleClick(Column: TColumnEh);
var
  BookMArk:String;
begin
  inherited;
  If Trim(Column.Title.Caption)<>'标记' Then
    Abort;
  If AdoQry_Main.RecordCount=0 Then
    Abort;
  BookMArk:=AdoQry_Main.BookmArk;
  If Not Checked Then
  begin
    AdoQry_Main.First;
    While Not AdoQry_Main.Eof Do
    begin
      If (Trim(AdoQry_Main.fieldbyname('PcNo').AsString)<>'')
        And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
      begin
        AdoQry_Main.Edit;
        AdoQry_Main.fieldbyname('SScheck').AsInteger:=1;
        AdoQry_Main.Post;
      end;
      AdoQry_Main.Next;
    end;
  end
  Else
  begin
    AdoQry_Main.First;
    While Not AdoQry_Main.Eof Do
    begin
      If (Trim(AdoQry_Main.fieldbyname('PcNo').AsString)<>'')
        And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
      begin
        AdoQry_Main.Edit;
        AdoQry_Main.fieldbyname('SScheck').AsInteger:=0;
        AdoQry_Main.Post;
      end;
      AdoQry_Main.Next;
    end;
  end;
  AdoQry_Main.BookmArk:=BookMArk;
  Checked:=Not Checked;
end;

procedure TFrm_Pm_Enter_SsPoInfo4.Act_LookExecute(Sender: TObject);
begin
  inherited;
{
 If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
 if  Frm_Pm_Enter_PoSsParent=nil then
 begin
  Frm_Pm_Enter_PoSsParent:=TFrm_Pm_Enter_PoSsParent.Create(Self);
  Frm_Pm_Enter_PoSsParent.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
  Frm_Pm_Enter_PoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
  tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
  Frm_Pm_Enter_PoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
  Frm_Pm_Enter_PoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('ssdate').asdatetime);
  Frm_Pm_Enter_PoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
  Frm_Pm_Enter_PoSsParent.InitForm(dbconnect,True);
 end
 else  Frm_Pm_Enter_PoSsParent.Show;
 }
  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_SsPoInfo4.Initselect;
begin
 SelectFromSql:=' Select poline.poqty,poline.poinqty,'
                +' StArtSsId as SSId,endSsid,#Ss12.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,'
                +' SSDate,#Ss12.SSQty,convert(integer,PmType) as PmType,SScheck, convert(float,GrossRequireQty) as GrossRequireQty, convert(float,PlanInvQty) as PlanInvQty,'
                +' OrderLineStatus, convert(varchAr,DeptVendorCode) as DeptVendorCode,Vendor.VendorName,duedate,ReMainQty,'
                +' ssReMainQty =case   when (ssReMainQty=0) then null '
                +' else'
                +'   ssReMainQty '
                +' end ,'
                +' Item.MnldTime,Item.ItemName,Item.UomCode,Uom.UomName,Item.PmCode,Item.Qclt,'
                +' Case When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
                +' Where #Ss12.ItemCode=PcLine.ItemCode '
                +' And #Ss12.SsDate>=PcStArtDate And #Ss12.SsDate<=PcendDate '
                +' And ((#Ss12.SsQty>=PcStArtQty And #Ss12.SsQty<PcendQty) Or '
                +' (PcStArtQty=0 And PcendQty=0))'
                +' And PcLine.PcLineStatus=1)>=1) And (#Ss12.SsSysInfoFlag=1) And (#Ss12.DeptVendorCode is Not Null) Then '
                +' (Select Top 1 PcLine.PcNo From PcLine,Pc '
                +' Where PcLine.PcNo=Pc.PcNo '
                +' And #Ss12.ItemCode=PcLine.ItemCode '
                +' And #Ss12.SsDate>=PcStArtDate And #Ss12.SsDate<=PcendDate '
                +' And ((#Ss12.SsQty>=PcStArtQty And #Ss12.SsQty<PcendQty) '
                +' Or (PcStArtQty=0 And PcendQty=0))'
                +' And (PcLine.PcLineStatus=1) And Pc.VendorCode=#Ss12.DeptVendorCode) '

                +' When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
                +' Where #Ss12.ItemCode=PcLine.ItemCode '
                +' And #Ss12.SsDate>=PcStArtDate And #Ss12.SsDate<=PcendDate '
                +' And ((#Ss12.SsQty>=PcStArtQty And #Ss12.SsQty<PcendQty) Or '
                +' (PcStArtQty=0 And PcendQty=0))'
                +' And PcLine.PcLineStatus=1)=1) And (#Ss12.SsSysInfoFlag=1) And (#Ss12.DeptVendorCode is Null) Then '
                +' (Select PcLine.PcNo From PcLine '
                +' Where #Ss12.ItemCode=PcLine.ItemCode '
                +' And #Ss12.SsDate>=PcStArtDate And #Ss12.SsDate<=PcendDate '
                +' And ((#Ss12.SsQty>=PcStArtQty And #Ss12.SsQty<PcendQty) '
                +' Or (PcStArtQty=0 And PcendQty=0))'
                +' And (PcLine.PcLineStatus=1)) '

                +' When  ((Select Count(PcLine.PcNo) As ICount From PcLine '
                +' Where #Ss12.ItemCode=PcLine.ItemCode '
                +' And #Ss12.SsDate >=PcStArtDate And #Ss12.SsDate< PcendDate '
                +' And ((#Ss12.SsQty>=PcStArtQty And #Ss12.SsQty< PcendQty ) Or '
                +' (PcStArtQty=0 And PcendQty=0))'
                +' And PcLine.PcLineStatus=1)>1) '
                +' And (#Ss12.DeptVendorCode is Null) '
                +' And (#Ss12.SsSysInfoFlag=1) '
                +' 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 '
                +' From #Ss12 '
                +' Join Item On #Ss12.ItemCode=Item.ItemCode '
                +' And (PmType=1 Or PmType=2) '
                +' Join Uom On Item.UomCode=Uom.UomCode '
                +' left Join SysSsInfo On #Ss12.SSSysInfoFlag=SysSsInfo.SSCode '
                +' left Join Employee On Item.EmployeeCode=Employee.EmployeeCode '
                +' Left Join Vendor on #Ss12.DeptVendorCode=Vendor.VendorCode'
                +' left join poline with(index(pk_Poline)) on (#Ss12.Orderno=Poline.pono) and (#Ss12.Orderlineno=poline.polineno)';
  ConditionUserDefine:=' ((#Ss12.SsSysInfoFlag=1 '
                      +' And Item.LongPurchLT=0 And #Ss12.DueDate-(select MrpParamValueN from MrpParam '
                      +' where MrpParamCode='''+'SSForwArdDay'+''')<='''+DateTimeToStr(Date())+''')'
                      +' Or (#Ss12.SsSysInfoFlag=1 And Item.LongPurchLT=1)Or (#Ss12.SsSysInfoFlag<>1 )) ';
  OrderByfields:=' ItemCode,ssdate ';
  GetData;
end;

function TFrm_Pm_Enter_SsPoInfo4.getQclt(ItemCode: string): string;
begin
  try
   Executesql(AdoQry_tmp,'select Qclt from Item where ItemCode='+quotedstr(ItemCode),0);
   Result:=inttostr(AdoQry_tmp.fieldbyname('Qclt').asinteger);
  except
   Result:='9999999';
  end;
end;

procedure TFrm_Pm_Enter_SsPoInfo4.btn_ItemClick(Sender: TObject);
begin
  inherited;
  Qry_Item(Dbconnect,AdoQry_Main.fieldbyname('ItemCode').AsString);
  DBGridEh.SetFocus;   
end;

procedure TFrm_Pm_Enter_SsPoInfo4.btn_VendorClick(Sender: TObject);
begin
  inherited;
  Qry_Vendor(Dbconnect,AdoQry_Main.fieldbyname('DeptVendorCode').AsString);
  DBGridEh.SetFocus;
end;

procedure TFrm_Pm_Enter_SsPoInfo4.btn_ite_ItemClick(Sender: TObject);
begin
  inherited;
  try
    if  Frm_Mrp_Qry_InformalTotalMrp_Item=nil then
      begin
        Frm_Mrp_Qry_InformalTotalMrp_Item:=TFrm_Mrp_Qry_InformalTotalMrp_Item.Create(Self);
        Frm_Mrp_Qry_InformalTotalMrp_Item.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
        Frm_Mrp_Qry_InformalTotalMrp_Item.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
        Frm_Mrp_Qry_InformalTotalMrp_Item.InitForm(dbconnect,True);
      end
      else  Frm_Mrp_Qry_InformalTotalMrp_Item.Show;
  finally
    activecontrol:=dbgrideh;
  end;
end;

function TFrm_Pm_Enter_SsPoInfo4.ismorethanzero(fieldName, tableName,
  conditionfield: string): boolean;
var AdoQry:TAdoQuery;
begin
  Result:=False;
  AdoQry:=TAdoQuery.Create(Application);
  AdoQry.EnableBCD := False;
  try
    with AdoQry do
     begin
       Close;
       Connection:=dbconnect;
       sql.clear;
       sql.Add('select sum('+fieldName+') as SumQty from '+tableName+' where '+conditionfield+'='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring));
       open;
       if fieldbyname('SumQty').asfloat>0 then
         Result:=True
       else Result:=False;
     end;
  finally
   AdoQry.Free;
  end;
end;

procedure TFrm_Pm_Enter_SsPoInfo4.GetData;
begin
//  inherited;
  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_SsPoInfo4.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_SsPoInfo4.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;

end.

⌨️ 快捷键说明

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