📄 pm_enter_newsspoinfo1.pas
字号:
unit Pm_Enter_NewSsPoInfo1;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;
Type
TFrm_Pm_Enter_NewSsPoInfo1 = Class(TFrm_Base_Outer)
AdoQry_MainSSId: TAutoIncField;
AdoQry_MainItemCode: TStringField;
AdoQry_MainSSSysInfoFlag: TIntegerField;
AdoQry_MaInOrderNo: TStringField;
AdoQry_MaInOrderLineNo: TIntegerField;
AdoQry_MainSSDate: TDateTimeField;
AdoQry_MainPmType: TIntegerField;
AdoQry_MainSScheck: TIntegerField;
AdoQry_MainGrossRequireQty: TFloatField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomCode: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MaInOrderLineStatus: TIntegerField;
AdoQry_MainItemflag: TStringField;
AdoQry_MainSsName: TStringField;
DBText2: TDBText;
Label2: TLabel;
Label3: TLabel;
DBText3: TDBText;
AdoQry_MainDeptVendorCode: TStringField;
AdoQry_Loop: TAdoQuery;
AdoQry_MainPcNo: TStringField;
AdoQry_MainPmCode: TIntegerField;
AdoQry_MainEmployeeCode: TStringField;
AdoQry_MainEmployeeName: TStringField;
AdoQry_MainEmployeeFlag: TStringField;
AdoQry_MainDueDate: TDateTimeField;
AdoQry_MainReMainQty: TFloatField;
Lab_RunMrpDate: TLabel;
Label6: TLabel;
AdoQry_MainQclt: TIntegerField;
AdoQry_MainReMainQty2: TFloatField;
btn_Item: TButton;
btn_Vendor: TButton;
btn_ite_Item: TButton;
btn_Order: TButton;
AdoQry_MainSSQty2: TFloatField;
btn_OblongMrp: TButton;
btn_uPMrp: TButton;
AdoQry_MainpoQty: TFloatField;
Button1: TButton;
Button2: TButton;
AdoQry_MainDeptVendorCode2: TStringField;
Label7: TLabel;
Label4: TLabel;
DBText4: TDBText;
Label5: TLabel;
DBText5: TDBText;
Label1: TLabel;
DBText1: TDBText;
Button3: TButton;
Button4: TButton;
AdoQry_MainSSQty: TFloatField;
AdoQry_MainDueDate2: TDateTimeField;
Button5: TButton;
AdoQry_MainOpInv: TFloatField;
procedure FormDestroy(Sender: TObject);
procedure Act_NewExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Act_CheckExecute(Sender: TObject);
procedure AdoQry_MainBeforeInsert(DataSet: TDataSet);
procedure Act_DeleteExecute(Sender: TObject);
procedure AdoQry_MainBeforeEdit(DataSet: TDataSet);
procedure AdoQry_MainAfterPost(DataSet: TDataSet);
procedure DBGridEhTitleClick(Column: TColumnEh);
procedure Act_LookExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Act_CopyExecute(Sender: TObject);
procedure btn_ItemClick(Sender: TObject);
procedure btn_VendorClick(Sender: TObject);
procedure btn_ite_ItemClick(Sender: TObject);
procedure btn_OrderClick(Sender: TObject);
procedure btn_uPMrpClick(Sender: TObject);
procedure btn_OblongMrpClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Act_SumExecute(Sender: TObject);
procedure DataSourceDataChange(Sender: TObject; Field: TField);
procedure Button3Click(Sender: TObject);
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
Flag:Integer;
Checked:Boolean;
PcNo:String;
PmCode:Integer;
Selected:Integer;//选定条数
function ismorethanzero(fieldName:string;tableName:string;conditionfield:string):boolean;
{ Private declarations }
public
pono,polineno:string;
frentform,falg:integer;
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
procedure Initselect;
function getQclt(ItemCode:string):string;{ Public declarations }
procedure UpDatePoline(PoNo:string;PoLineNo:integer;polinedate,postArtworkdate:string;poqty,ponoFinishqty:double;isupdate:boolean);
function getstatus(pono:string;polineno:integer):integer;
{ Public declarations }
end;
var
Frm_Pm_Enter_NewSsPoInfo1: TFrm_Pm_Enter_NewSsPoInfo1;
implementation
uses Sys_Global, Mrp_Global, Public_Show, Pm_Enter_PoSsParent,Mrp_Qry_UpRightMrp_D_Item,
Mrp_Qry_InformalTotalMrp_vd, Mrp_Qry_InformalTotalMrp_Item,
Mrp_Qry_InformalTotalMrp_Po, Mrp_Qry_InformalTotalMrp_Mo,
Mrp_Qry_UpRightMrp_D, Mrp_Qry_OblongMrp_D, Mrp_Enter_MoSsParent,
Pm_Enter_ClosePo1,Bas_Qry_MultiBomSViewMaster, Pm_Enter_NewAutoPo, Pm_Enter_NewAutoPo1,
Pm_Enter_NewSsPoInfo4_C, Pm_Enter_NewSsPoInfo4, Mrp_Qry_NewUpRightMrp_D,
Mrp_Qry_NewOblongMrp_D, Mrp_Enter_CommonAssignAlterNative,
Mrp_Enter_NewMoSsParent, Pm_Enter_EditPassPo1, Pm_Enter_PassPo_D,
Mrp_Enter_CommonAssignAlterNative1;
{$R *.DFM}
function TFrm_Pm_Enter_NewSsPoInfo1.getstatus(pono: string;
polineno: integer): integer;
begin
Result:=999;
Executesql(AdoQry_tmp,'select polinestatus from poline where pono='+quotedstr(pono)+' and polineno='+inttostr(polineno),0);
Result:=AdoQry_tmp.fieldbyname('polinestatus').asinteger;
end;
procedure TFrm_Pm_Enter_NewSsPoInfo1.UpDatePoline(PoNo:string;PoLineNo:integer;polinedate,postArtworkdate:string;poqty,ponoFinishqty:double;isupdate:boolean);
var AdoQry:TAdoQuery;
sqltext:string;
begin
AdoQry:=TAdoQuery.Create(self);
AdoQry.Connection:=dbconnect;
if getstatus(pono,polineno)=5 then
begin
sqltext:='update Poline '
+' set POLineDATE= '+quotedstr(polinedate)+','
+' PoStArtWorkDate='+quotedstr(postArtworkdate)+','
+' POnoFinishQty= '+floattostr(POnoFinishQty)+','
+' PoQty='+floattostr(PoQty)
+' where Pono='+quotedstr(Pono)
+' and Polineno='+inttostr(Polineno);
end
else begin
sqltext:='update Poline '
+' set POLineDATE= '+quotedstr(POLineDATE)+','
+' PoStArtWorkDate='+quotedstr(PoStArtWorkDate)
+iifstring(isupdate,',polinestatus=5,poqty='+floattostr(poqty)+',ponoFinishqty='+floattostr(ponoFinishqty),' ')
+' where Pono='+quotedstr(Pono)
+' and Polineno='+inttostr(Polineno);
end;
try
Executesql(AdoQry,sqltext,1);
finally
AdoQry.Free;
end;
end;
procedure TFrm_Pm_Enter_NewSsPoInfo1.InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);
var
SqlText:string;
AdOCmd_Mrp:TAdOCommand;
begin
Application.ProcessMessages;
inherited;
CreatePanel(1,DBGridEh);
AdOCmd_Mrp:=TAdOCommand.Create(Nil);
AdOCmd_Mrp.CommandTimeout:=0;
AdOCmd_Mrp.Connection:=DBConnect;
{ SqlText:=' select MrpResult.*, '
+' DeptVendorCode1=(select VendorCode from pc with(index(Pk_Pc)) where pcno= Case When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Not Null) Then '
+' (Select Top 1 PcLine.PcNo From PcLine with(index(Pk_PcLine)),Pc with(index(Pk_Pc)) '
+' Where PcLine.PcNo=Pc.PcNo '
+' And MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1) And Pc.VendorCode=MrpResult.DeptVendorCode) '
+' When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Null) Then '
+' (Select Top 1 PcLine.PcNo From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1)) '
+' When ((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate >=PcStArtDate And MrpResult.ReleaseDate< PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand< PcendQty ) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (MrpResult.DeptVendorCode is Null) '
+' And (MrpResult.ordinal=3) '
+' Then '
+''''+'待分配'+''''
+' Else '
+' Null '
+' end '
+'), '
+' ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=1,Poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=reMainqty '
+' into #ss1 from MrpResult '
+' left outer join poline on MrpResult.Orderno=Poline.Pono '
+' and MrpResult.Orderlineno=Poline.Polineno '
+' where (ordinal=3 ) '
+' and ((PmCode=1) or (PmCode=2) or (PmCode=3)) '
+' union '
+' select MrpResult.*, '
+' DeptVendorCode1=(select VendorCode from pc with(index(Pk_Pc)) where pcno= Case When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Not Null) Then '
+' (Select Top 1 PcLine.PcNo From PcLine with(index(Pk_PcLine)),Pc with(index(Pk_Pc)) '
+' Where PcLine.PcNo=Pc.PcNo '
+' And MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1) And Pc.VendorCode=MrpResult.DeptVendorCode) '
+' When ((Select Count(distinct PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)=1) And (MrpResult.Ordinal=3) And (MrpResult.DeptVendorCode is Null) Then '
+' (Select top 1 PcLine.PcNo From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate>=PcStArtDate And MrpResult.ReleaseDate<=PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand<PcendQty) '
+' Or (PcStArtQty=0 And PcendQty=0))'
+' And (PcLine.PcLineStatus=1)) '
+' When ((Select Count(PcLine.PcNo) As ICount From PcLine '
+' Where MrpResult.ItemCode=PcLine.ItemCode '
+' And MrpResult.ReleaseDate >=PcStArtDate And MrpResult.ReleaseDate< PcendDate '
+' And ((MrpResult.OnHand>=PcStArtQty And MrpResult.OnHand< PcendQty ) Or '
+' (PcStArtQty=0 And PcendQty=0))'
+' And PcLine.PcLineStatus=1)>1) '
+' And (MrpResult.DeptVendorCode is Null) '
+' And (MrpResult.ordinal=3) '
+' Then '
+''''+'替代件待分配'+''''
+' Else '
+' Null '
+' end '
+'), '
+' ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=1,Poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=reMainqty '
+' from MrpResult '
+' left outer join poline on MrpResult.Orderno=Poline.Pono '
+' and MrpResult.Orderlineno=Poline.Polineno '
+' where (ordinal=3 ) '
+' and (PmCode=9) '
+' And ReMainQty>0 '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=3,poline.poqty,ssqty=MrpResult.Orderqty,Sysqty=MrpResult.Orderqty,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' And OrderLineStatus=6 And RealOrderQty<=0 '
+' and exists(select pono from poline where Orderno=poline.pono and Orderlineno=poline.polineno and poline.polinestatus<>7) '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=4,poline.poqty,ssqty=MrpResult.Orderqty,Sysqty=MrpResult.Orderqty,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' and Orderlinestatus=5 '
+' and onhand>0 '
+' and (releasedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate()) or duedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate())) '
+' and exists(select pono from poline where Orderno=poline.pono and Orderlineno=poline.polineno and poline.polinestatus<>7) '
+' union '
+' select MrpResult.*,DeptVendorCode1=DeptVendorCode,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=6,poline.poqty,ssqty=MrpResult.onhand,Sysqty=MrpResult.onhand,ssreMainqty=0 from MrpResult '
+' join poline on MrpResult.Orderno=poline.pono '
+' and MrpResult.Orderlineno=poline.polineno '
+' where ordinal=2 '
+' And OrderLineStatus<>7 '
+' And CanUseOnHand=1 '
+' union '
+' select MrpResult.*, DeptVendorCode1=DeptVendorCode, '
+' ssid=MrpResultid,'
+' ssdate=releasedate, '
+' ssSysInfoflag=2, '
+' poline.poqty, '
+' ssqty=Orderqty-onhand, '
+' Sysqty=Orderqty-onhand, '
+' ssreMainqty=0 '
+' from MrpResult With(Index(Ordinal)),poline '
+' where (ordinal=2 ) '
+' and Orderlinestatus<>7 '
+' and Orderqty>onhand '
+' And MrpResult.ItemCode Not 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 '
+' union '
+' select MrpResult.*, DeptVendorCode1=DeptVendorCode, '
+' ssid=MrpResultid,'
+' ssdate=releasedate, '
+' ssSysInfoflag=5, '
+' poline.poqty, '
+' ssqty=Orderqty-onhand, '
+' Sysqty=Orderqty-onhand, '
+' ssreMainqty=0 '
+' from MrpResult With(Index(Ordinal)),poline '
+' where (ordinal=2 ) '
+' and Orderlinestatus<>7 '
+' and Orderqty>onhand '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -