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

📄 pm_enter_newsspoinfo1.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
           +'  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 CanUseOnHand,poline.poqty,realreleasedate,'
                +' SSId,#Ss1.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,'
                +' 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,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 #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) And (#Ss1.DeptVendorCode1 is Not Null) Then '
                +' (Select Top 1 PcLine.PcNo From PcLine,Pc '
                +' Where PcLine.PcNo=Pc.PcNo '
                +' And #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) And Pc.VendorCode=#Ss1.DeptVendorCode1) '

                +' 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) And (#Ss1.DeptVendorCode1 is Null) 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) '
                +' 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 poline with(index(pk_Poline)) on (#ss1.Orderno=Poline.pono) and (#ss1.Orderlineno=poline.polineno)'
    //ConditionUserDefine:=
                +' where ((#Ss1.SsSysInfoFlag=1 '
                      +' And Item.LongPurchLT=0 And #Ss1.DueDate-(select MrpParamValueN from MrpParam '
                      +' where MrpParamCode='''+'SSForwArdDay'+''')<='''+DateTimeToStr(Date())+''')'
                      +' Or (#Ss1.SsSysInfoFlag=1 And Item.LongPurchLT=1) Or (#Ss1.SsSysInfoFlag<>1)) and (Item.EmployeeCode='''+userCode+''') and (#Ss1.SsQty<>0)';
} sqltext:='exec sp_PmInfo '''+userCode+''',1';
  ExecuteCmd(AdOCmd_Mrp,SQlText);
  sqltext:='select * into #ss from SSPurchaseInfoResult1'  ;
  Executesql(AdoQry_tmp,sqltext,1);
 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;
  Checked:=False;
end;


procedure TFrm_Pm_Enter_NewSsPoInfo1.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Pm_Enter_NewSsPoInfo1:=Nil;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.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;}
//  If I=True Then
  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;
    Frm_Pm_Enter_NewAutoPo.Free;
  end
  Else
  begin
    AdoQry_Main.BookmArk:=BookMArk;
    DispInfo('没有选定记录,不能执行新增操作!',3);
    Abort;
  end;
{  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;}
  PcNo:='';
  PmCode:=0;
  if AdoQry_Main.Locate('sScheck',1,[locaseinsensitive]) then
    begin
      PcNo:=AdoQry_Main.fieldbyname('PcNo').AsString;
      PmCode:=AdoQry_Main.fieldbyname('PmType').AsInteger;
    end;
  
  AdoQry_Main.BookmArk:=BookMArk;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.FormCreate(Sender: TObject);
begin
  inherited;
  ExtendCaption:=False;
  PcNo:='';
  PmCode:=0;
  Selected:=0;
    ToolButton6.Action := Act_Sum ;
  ToolButton6.Visible := True;
  ToolButton6.Enabled := True;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.Act_CheckExecute(Sender: TObject);
begin
  inherited;
  If AdoQry_Main.RecordCount=0 Then
    Abort;
  AdoQry_Main.First;
  While Not AdoQry_Main.Eof Do
  begin
    AdoQry_Main.Edit;
    AdoQry_Main.fieldbyname('SScheck').AsInteger:=1;
    AdoQry_Main.Post;
    Selected:=Selected+1;
    AdoQry_Main.Next;
  end;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.AdoQry_MainBeforeInsert(
  DataSet: TDataSet);
begin
  inherited;
  Abort;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.Act_DeleteExecute(Sender: TObject);
begin
  //inherited;

end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.AdoQry_MainBeforeEdit(DataSet: TDataSet);
begin
  inherited;
  IF (AdoQry_Main.fieldbyname('pcno').AsString='替代件待分配')  and (ActiveControl.Name='DBGridEh')  Then    //(Flag=1) And
  begin
    DispInfo('本条建议不能下单,请按 "替代件建议分配"按钮!',3);
    Abort;
  end;
  IF (Flag=1) And (AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger<>1) Then
  begin
    DispInfo('本条建议不为"建议下达",不能执行选定操作!',3);
    Abort;
 end;
 If Trim(AdoQry_Main.fieldbyname('PcNo').AsString)='' Then
 begin
   DispInfo('不能对一条没有可用采购价格单号的记录进行操作!',3);
   Abort;
 end;
 If AdoQry_Main.fieldbyname('ssReMainQty').AsFloat<=0 Then
 begin
    DispInfo('本条建议"系统建议余量"已分配完毕,不能执行选定操作!',3);
    Abort;
  end;
 If (PmCode=1) And (AdoQry_Main.fieldbyname('PmType').AsInteger<>PmCode) Then
 begin
   DispInfo('本条记录物料制构类型与选定的不一值!',3);
   Abort;
 end;
 If (PmCode In [2,3]) And (AdoQry_Main.fieldbyname('PmType').AsInteger=1) Then
 begin
   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_NewSsPoInfo1.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
  inherited;
  Executesql(AdoQry_tmp,'update #ss set sScheck='+AdoQry_Main.fieldbyname('sScheck').asstring+' where ssid='+AdoQry_Main.fieldbyname('ssid').asstring,1);
  If AdoQry_Main.fieldbyname('SScheck').AsInteger=1 Then
  begin
    PcNo:=AdoQry_Main.fieldbyname('PcNo').AsString;
    PmCode:=AdoQry_Main.fieldbyname('PmType').AsInteger;
    Selected:=Selected+1;
  end
  Else
  begin
    Selected:=Selected-1;
    If Selected=0 Then
    begin
      PcNo:='';
      PmCode:=0;
    end;
  end;
end;

procedure TFrm_Pm_Enter_NewSsPoInfo1.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_NewSsPoInfo1.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);
  tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
  Frm_Pm_Enter_PoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
  Frm_Pm_Enter_PoSsParent.ItemCode:=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

⌨️ 快捷键说明

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