📄 pm_enter_sspoinfo2.pas
字号:
+' 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) '
+' Then '
+''''+'替代件待分配'+''''
+' Else '
+' Null '
+' end '
+'), ' }
+' duedate, '
+' ssqty, '
+' GrossRequireQty, '
+' PlanInvQty, '
+' ReMainQty, '
+' ssreMainqty=reMainqty,ssid from ss with(index(ss_idx_PmType )) '
+' where ssSysInfoflag=1 '
+' and (PmType=9) '
+' And ReMainQty>0 ';
ExecuteCmd(AdOCmd_Mrp,SQlText);
// +' union '
SQlText:='insert into #ss1 select ss.ItemCode,ssSysInfoflag, '
+' Orderno,Orderlineno,ssdate, '
+' PmType, '
+' sScheck, '
+' OrderLineStatus, '
+' DeptVendorCode, '
+' duedate, '
+' ssqty, '
+' GrossRequireQty, '
+' PlanInvQty, '
+' ReMainQty, '
+' ssreMainqty=0,ssid from ss with(index(ss_idx_PmType )) '
+' where ssSysInfoflag=3 '
+' and Orderlinestatus<>7 '
+' and exists(select pono from poline where Orderno=poline.pono) ';//with(index(RELATION_1999_FK))
ExecuteCmd(AdOCmd_Mrp,SQlText);
//+' union '
SqlText:='insert Into #ss1 select ss.ItemCode,ssSysInfoflag, '
+' Orderno,Orderlineno,ssdate, '
+' PmType, '
+' sScheck, '
+' OrderLineStatus, '
+' DeptVendorCode, '
+' duedate, '
+' ssqty, '
+' GrossRequireQty, '
+' PlanInvQty, '
+' ReMainQty, '
+' ssreMainqty=0,ssid from ss with(index(ss_idx_PmType )) '
+' where ssSysInfoflag=4 '
+' and exists(select pono from poline where Orderno=poline.pono) ';
ExecuteCmd(AdOCmd_Mrp,SQlText);
//+' union '
SqlText:='insert #ss1 select ss.ItemCode,ssSysInfoflag, '
+' Orderno,Orderlineno,ssdate, '
+' PmType, '
+' sScheck, '
+' OrderLineStatus, '
+' DeptVendorCode, '
+' duedate, '
+' ssqty=case when ss.reMainqty<poline.poqty then poline.poqty-ss.reMainqty '
//+' else ss.ssqty '
+' else 0 '
+ ' end, '
+' GrossRequireQty, '
+' PlanInvQty, '
+' ReMainQty, '
+' ssreMainqty=0,ssid '
+' from ss with(index(ss_idx_PmType )),poline with(index(poline_idx_Pono)) '
+' where ssSysInfoflag=2 '
+' and Orderlinestatus<>7 '
+' and exists(select pono from poline where Orderno=poline.pono) '//with(index(RELATION_1999_FK))
+' and ss.Orderno=poline.pono '
+' and ss.Orderlineno=poline.polineno ';
ExecuteCmd(AdOCmd_Mrp,SQlText);
SqlText:= ' Select '
+' SSId,#Ss1.ItemCode,SSSysInfoFlag,OrderNo,OrderLineNo,'
+' SSDate,#ss1.SSQty,convert(integer,PmType) as PmType,SScheck, convert(float,GrossRequireQty) as GrossRequireQty, convert(float,PlanInvQty) as PlanInvQty,'
+' OrderLineStatus, convert(varchAr,DeptVendorCode) 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.DeptVendorCode is Null) '
+' And (#Ss1.SsSysInfoFlag=1) '
+' and (#ss1.PmType<>9)'
+' Then '
+''''+'待分配'+''''
+' When '
+' #Ss1.SsSysInfoFlag=1 and (#ss1.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 '
+' into #ss From #SS1 '
+' Join Item On #Ss1.ItemCode=Item.ItemCode '
+' And (PmType=1 Or PmType=2 or PmType=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.DeptVendorCode=Vendor.VendorCode '
+' 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 (((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.DeptVendorCode is Null) '
+' And (#Ss1.SsSysInfoFlag=1)) and (#Ss1.SsQty<>0) or (#Ss1.SsSysInfoFlag=1 and (#ss1.PmType=9)) ';
ExecuteCmd(AdOCmd_Mrp,SQlText);
Initselect;
{
SelectFromSql:=' Select SS.*,Vendor.VendorCode,Vendor.VendorName,Item.MnldTime,Item.ItemName,Item.UomCode,Uom.UomName,Item.PmCode, '
+' Vendor.VendorCode+'''+' '+'''+Vendor.VendorName As VendorFlag,'
+' 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) Then '
+' (Select Top 1 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) '
+' 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) '
+' Join Uom On Item.UomCode=Uom.UomCode '
+' Join SysSsInfo On Ss.SSSysInfoFlag=SysSsInfo.SSCode '
+' Left Join Employee On Item.EmployeeCode=Employee.EmployeeCode '
+' Left Join Vendor On Ss.DeptVendorCode=Vendor.VendorCode ';
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)) '
+' And (((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))';
OrderByfields:='ItemCode ';
}
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select MrpParamValueN from MrpParam '
+' where MrpParamCode='''+'SSForwArdDay'+'''';
AdoQry_Tmp.Open;
Lbl_Condition.Caption:='系统建议下达(约定开工日-'+FormatDateTime('yyyy.mm.dd',Date())+')'
+'<=建议可见提前天数('+IntToStr(AdoQry_Tmp.fieldbyname('MrpParamValueN').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_SsPoInfo2.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Enter_SsPoInfo2:=Nil;
end;
procedure TFrm_Pm_Enter_SsPoInfo2.Act_NewExecute(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
falg:=1;
Frm_Pm_Enter_AutoPo:=TFrm_Pm_Enter_AutoPo.Create(Application);
Frm_Pm_Enter_AutoPo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Enter_AutoPo.SetFormParam(PcNo,IntToStr(PmCode),'','','','');
Frm_Pm_Enter_AutoPo.InitForm(DbConnect,'Add',AdoQry_Main);
Frm_Pm_Enter_AutoPo.ShowModal;
Frm_Pm_Enter_AutoPo.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;
AdoQry_Main.BookmArk:=BookMArk;
end;
procedure TFrm_Pm_Enter_SsPoInfo2.FormCreate(Sender: TObject);
begin
inherited;
ExtendCaption:=False;
TlBtn_Copy.Action:=Act_Auto;
PcNo:='';
PmCode:=0;
Selected:=0;
end;
procedure TFrm_Pm_Enter_SsPoInfo2.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_SsPoInfo2.AdoQry_MainBeforeInsert(
DataSet: TDataSet);
begin
inherited;
Abort;
end;
procedure TFrm_Pm_Enter_SsPoInfo2.Act_DeleteExecute(Sender: TObject);
begin
//inherited;
end;
procedure TFrm_Pm_Enter_SsPoInfo2.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 (PmCode=1) And (AdoQry_Main.fieldbyname('PmType').AsInteger<>PmCode) Then
begin
DispInfo('本条记录物料制构类型与选定的不一值!',3);
Abort;
end;
If AdoQry_Main.fieldbyname('ssReMainQty').AsFloat<=0 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_SsPoInfo2.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
inherited;
If AdoQry_Main.fieldbyname('SScheck').AsInteger=1 Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -