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

📄 pm_enter_sspoinfo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  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_SsPoInfo.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_SsPoInfo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text := 'Drop Table #ss1,#ss ';
  AdoQry_Tmp.ExecSQL;
  frentform:=0;
end;

procedure TFrm_Pm_Enter_SsPoInfo.Initselect;
begin
 SelectFromSql:='select * from #ss' ;
 {' Select poline.poqty,poline.poinqty,'
                +' SSId,#Ss.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,'
                +' SSDate,#Ss.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 #Ss.ItemCode=PcLine.ItemCode '
                +' And #Ss.SsDate>=PcStArtDate And #Ss.SsDate<=PcendDate '
                +' And ((#Ss.SsQty>=PcStArtQty And #Ss.SsQty<PcendQty) Or '
                +' (PcStArtQty=0 And PcendQty=0))'
                +' And PcLine.PcLineStatus=1)>=1) And (#Ss.SsSysInfoFlag=1) And (#Ss.DeptVendorCode is Not Null) Then '
                +' (Select Top 1 PcLine.PcNo From PcLine,Pc '
                +' Where PcLine.PcNo=Pc.PcNo '
                +' And #Ss.ItemCode=PcLine.ItemCode '
                +' And #Ss.SsDate>=PcStArtDate And #Ss.SsDate<=PcendDate '
                +' And ((#Ss.SsQty>=PcStArtQty And #Ss.SsQty<PcendQty) '
                +' Or (PcStArtQty=0 And PcendQty=0))'
                +' And (PcLine.PcLineStatus=1) And Pc.VendorCode=#Ss.DeptVendorCode) '

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

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

function TFrm_Pm_Enter_SsPoInfo.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_SsPoInfo.Act_CopyExecute(Sender: TObject);
var
  I:Boolean;
  BookMArk:String;
begin
  inherited;
  frentform:=1;
  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('sScheck').AsInteger>0 Then
    begin
     I:=True;
     BookMArk:=AdoQry_Main.BookmArk ;
     Break;
    end;
    AdoQry_Main.Next;
  end;
  If I=True Then
  begin
    Frm_Pm_Enter_AutoPo1:=TFrm_Pm_Enter_AutoPo1.Create(Application);
    Frm_Pm_Enter_AutoPo1.InitForm(DbConnect,'Add',AdoQry_Main);
    Frm_Pm_Enter_AutoPo1.SetFormParam(PcNo,IntToStr(PmCode),'','','','');
    Frm_Pm_Enter_AutoPo1.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
    Frm_Pm_Enter_AutoPo1.ShowModal;
    Frm_Pm_Enter_AutoPo1.Free;
  end
  Else
  begin
    AdoQry_Main.BookmArk:=BookMArk;
    DispInfo('没有选定记录,不能执行新增操作!',3);
    Abort;
  end;
//  BookMArk:=AdoQry_Main.BookmArk ;
  AdoQry_Main.First;
  While Not AdoQry_Main.Eof Do
  begin
    If AdoQry_Main.fieldbyname('SScheck').AsInteger=1 Then
    begin
      PcNo:=AdoQry_Main.fieldbyname('PcNo').AsString;
      PmCode:=AdoQry_Main.fieldbyname('PmType').AsInteger;
      Break;
    end
    Else
      AdoQry_Main.Next;
  end;
  If AdoQry_Main.Eof Then
  begin
    PcNo:='';
    PmCode:=0;
  end;
  AdoQry_Main.BookmArk:=BookMArk;
end;

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

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

procedure TFrm_Pm_Enter_SsPoInfo.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;

procedure TFrm_Pm_Enter_SsPoInfo.btn_OrderClick(Sender: TObject);
begin
  inherited;
  try
  ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
  if ((AdoQry_Main.fieldbyname('PmCode').asinteger=1) or (AdoQry_Main.fieldbyname('PmCode').asinteger=2)) then
   begin
//    if AdoQry_Main.fieldbyname('Orderpreqty').asfloat+AdoQry_Main.fieldbyname('Orderxdqty').asfloat=0 then
 //     exit;
    if Frm_Mrp_Qry_InformalTotalMrp_Po=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Po:=TFrm_Mrp_Qry_InformalTotalMrp_Po.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Po.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Po.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Po.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Po.Show;
    exit;
   end;
  if AdoQry_Main.fieldbyname('PmCode').asinteger=0 then
  begin
//   if AdoQry_Main.fieldbyname('Orderpreqty').asfloat+AdoQry_Main.fieldbyname('Orderxdqty').asfloat=0 then
 //    exit;
   if Frm_Mrp_Qry_InformalTotalMrp_Mo=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Mo:=TFrm_Mrp_Qry_InformalTotalMrp_Mo.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Mo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Mo.Show;
   exit;
  end;
  if AdoQry_Main.fieldbyname('PmCode').asinteger=3 then
  begin
    if ismorethanzero('moqty','MoLine','ItemCode')=True then
    if Frm_Mrp_Qry_InformalTotalMrp_Mo=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Mo:=TFrm_Mrp_Qry_InformalTotalMrp_Mo.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Mo.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Mo.Show;
   if ismorethanzero('poqty','poline','ItemCode')=True then
       if Frm_Mrp_Qry_InformalTotalMrp_Po=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Po:=TFrm_Mrp_Qry_InformalTotalMrp_Po.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Po.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Po.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Po.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Po.Show;

 end;
 finally
 activecontrol:=dbgrideh;
 end;

end;

function TFrm_Pm_Enter_SsPoInfo.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

⌨️ 快捷键说明

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