📄 pm_qry_normalsspoinfo.pas
字号:
+' 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) '
+' 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 ';
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)) ';
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;
Checked:=False;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Qry_NormalSsPoInfo:=Nil;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.FormCreate(Sender: TObject);
begin
inherited;
ExtendCaption:=False;
PcNo:='';
PmCode:=0;
Selected:=0;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.AdoQry_MainBeforeInsert(
DataSet: TDataSet);
begin
inherited;
Abort;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.AdoQry_MainBeforeEdit(DataSet: TDataSet);
begin
inherited;
{ I:=0;
BookmArk:=AdoQry_Main.BookmArk;
AdoQry_Main.First;
while not AdoQry_Main.Eof do
begin
if AdoQry_Main.fieldbyname('SScheck').asinteger = 1 then
begin
I:=1;
exit;
end;
AdoQry_Main.next;
end;
if I=0 then
pcno:='';
AdoQry_Main.BookmArk:= BookmArk;}
IF (AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger<>1) Then //(Flag=1) And
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_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.Initselect;
begin
SelectFromSql:='Select * from #ss';
OrderByfields:=' ItemCode,ssdate ';
GetData;
end;
function TFrm_Pm_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.btn_ItemClick(Sender: TObject);
begin
inherited;
Qry_Item(Dbconnect,AdoQry_Main.fieldbyname('ItemCode').AsString);
DBGridEh.SetFocus;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.btn_VendorClick(Sender: TObject);
begin
inherited;
Qry_Vendor(Dbconnect,AdoQry_Main.fieldbyname('DeptVendorCode').AsString);
DBGridEh.SetFocus;
end;
procedure TFrm_Pm_Qry_NormalSsPoInfo.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_Qry_NormalSsPoInfo.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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -