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

📄 pm_enter_newsspoinfo4.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    DispInfo('本条记录物料制构类型与选定的不一值!',3);
    Abort;
  end;
  If (Length(PcNo)>0) And (AdoQry_Main.fieldbyname('PcNo').AsString<>PcNo) Then
  begin
   DispInfo('不能一次选中两个不相同可用采购价格单号!',3);
   Abort;
  end;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo4.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_NewSsPoInfo4.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_NewSsPoInfo4.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_NewSsPoInfo4.Initselect;
begin
 SelectFromSql:=' Select poline.poqty,poline.poinqty,'
                +' StArtSsId as SSId,endSsid,#Ss12.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,'
                +' SSDate,#Ss12.SSQty,convert(integer,#Ss12.PmCode) as PmType,SScheck, convert(float,GrossQty) 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 top 1 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 (#Ss12.PmCode=1 Or #Ss12.PmCode=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 PmParamValueN from PmParam '
                      +' where PmParamCode='''+'SSForwArdDay'+''')<='''+DateTimeToStr(Date())+''')'
                      +' Or (#Ss12.SsSysInfoFlag=1 And Item.LongPurchLT=1)Or (#Ss12.SsSysInfoFlag<>1 )) ';
  OrderByfields:=' ItemCode,ssdate ';
  GetData;
end;

function TFrm_Pm_Enter_NewSsPoInfo4.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_NewSsPoInfo4.btn_ItemClick(Sender: TObject);
begin
  inherited;
  Qry_Item(Dbconnect,AdoQry_Main.fieldbyname('ItemCode').AsString);
  DBGridEh.SetFocus;   
end;

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

procedure TFrm_Pm_Enter_NewSsPoInfo4.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_NewSsPoInfo4.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_NewSsPoInfo4.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_NewSsPoInfo4.btn_uPMrpClick(Sender: TObject);
var AdoQry:TAdoQuery;
    sqltext:string;
begin
  inherited;
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;

  try
    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, '+
               ' Item.CurrentonhandInv as CurrentonhandInv, '+
               ' Assignedqty=isnull(0,0), '+
               ' Item.CurrentonCheckInv as oncheckqty '+
               //' Item.CurrentonhandInv '+
               //' into #tmpItemResult'+
               ' From Item '+
               ' Join MrpResult On Item.ItemCode=MrpResult.ItemCode and MrpResult.ordinal=1'+
               '      and MrpResult.ItemCode='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)+
               //' 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_NewUpRightMrp_D=nil then
   begin
    Frm_Mrp_Qry_NewUpRightMrp_D:=TFrm_Mrp_Qry_NewUpRightMrp_D.Create(Self);
    Frm_Mrp_Qry_NewUpRightMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemName:=AdoQry.fieldbyname('ItemName').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.Uom:=AdoQry.fieldbyname('UomName').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.ldtime:=floattostr(AdoQry.fieldbyname('ldtime').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.Preparelt:=floattostr(AdoQry.fieldbyname('Preparelt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.runlt:=floattostr(AdoQry.fieldbyname('runlt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.Qclt:=floattostr(AdoQry.fieldbyname('Qclt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.PmBatch:=floattostr(AdoQry.fieldbyname('PmBatch').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemPmCode:=AdoQry.fieldbyname('PmCode').asinteger;
    Frm_Mrp_Qry_NewUpRightMrp_D.CurrentInv:=floattostr(AdoQry.fieldbyname('CurrentonhandInv').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.RunMrp:=0;
    Frm_Mrp_Qry_NewUpRightMrp_D.Assignedqty:=floattostr(AdoQry.fieldbyname('Assignedqty').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.oncheckqty:=floattostr(AdoQry.fieldbyname('oncheckqty').asfloat);
   if AdoQry.fieldbyname('PmCode').asinteger=0 then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='0 制造';
   if AdoQry.fieldbyname('PmCode').asinteger=1 then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='1 采购';
   if AdoQry.fieldbyname('PmCode').asinteger=2     then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='2 委外加工';
   if AdoQry.fieldbyname('PmCode').asinteger=3     then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='3 既制造又委外';
   Frm_Mrp_Qry_NewUpRightMrp_D.minqty:=floattostr(AdoQry.fieldbyname('minqty').asfloat);
   if AdoQry.fieldbyname('Batchstrat').asinteger=0  then
    Frm_Mrp_Qry_NewUpRightMrp_D.Batchstrat:='直接批量法';
   if AdoQry.fieldbyname('Batchstrat').asinteger=1   then
    Frm_Mrp_Qry_NewUpRightMrp_D.Batchstrat:='固定批量法';
    try
     AdoQry.Free;
    except
    end;
    Frm_Mrp_Qry_NewUpRightMrp_D.InitForm(AdoQry_Main.Connection,True);
   end
   else Frm_Mrp_Qry_NewUpRightMrp_D.Show;
  finally
    activecontrol:=dbgrideh;
  end;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo4.btn_OblongMrpClick(Sender: TObject);
begin
  if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger=2 then
     begin
     activecontrol:=dbgrideh;
     exit;
     end;
 // inherited;
  try
  if Frm_Mrp_Qry_NewOblongMrp_D=nil then
   begin
    Frm_Mrp_Qry_NewOblongMrp_D:=TFrm_Mrp_Qry_NewOblongMrp_D.Create(Self);
    Frm_Mrp_Qry_NewOblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
    Frm_Mrp_Qry_NewOblongMrp_D.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
    Frm_Mrp_Qry_NewOblongMrp_D.mRunMrp:=0;
    Frm_Mrp_Qry_NewOblongMrp_D.InitForm(dbconnect,True);
   end
   else Frm_Mrp_Qry_NewOblongMrp_D.Show;
  finally
   activecontrol:=dbgrideh;
  end;   
end;

procedure TFrm_Pm_Enter_NewSsPoInfo4.FormKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key = vk_Space then 
  begin
    AdoQry_Main.Edit;
    AdoQry_Main.fieldbyname('sScheck').AsInteger:=iifinteger(AdoQry_Main.fieldbyname('sScheck').AsInteger=0,1,0);
    AdoQry_Main.Post;
  end;  

end;

end.

⌨️ 快捷键说明

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