📄 mrp_enter_informalmrpinfo.pas
字号:
unit Mrp_Enter_InformalMrpInfo;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;
Type
TFrm_Mrp_Enter_InformalMrpInfo = Class(TFrm_Base_Qry)
AdoQry_MainSSId: TAutoIncField;
AdoQry_MainItemCode: TStringField;
AdoQry_MaInOrderNo: TStringField;
AdoQry_MaInOrderLineNo: TIntegerField;
AdoQry_MainSSDate: TDateTimeField;
AdoQry_MainSSQty: TFloatField;
AdoQry_MainPmType: TIntegerField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomCode: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainDeptName: TStringField;
AdoQry_MainDeptFlag: TStringField;
AdoQry_MainItemFlag: TStringField;
AdoQry_MaInOrderLineStatus: TIntegerField;
AdoQry_MainDeptVendorCode: TStringField;
Label2: TLabel;
DBText2: TDBText;
Label3: TLabel;
DBText3: TDBText;
AdoQry_MainSSSysInfoFlag: TIntegerField;
AdoQry_MainSsName: TStringField;
Label1: TLabel;
DBText1: TDBText;
DBText4: TDBText;
Label4: TLabel;
AdoQry_MainEmployeeCode: TStringField;
AdoQry_MainEmployeeName: TStringField;
AdoQry_MainEmployeeFlag: TStringField;
AdoQry_MainDueDate: TDateTimeField;
AdoQry_Mainssflag: TStringField;
Label5: TLabel;
lbl_RunMrpdate: TLabel;
AdoQry_MaintMpssreMainqty: TFloatField;
AdoQry_MainSysqty: TFloatField;
btn_Item: TButton;
btn_ite_Item: TButton;
btn_Order: TButton;
AdoQry_MainPmCode: TIntegerField;
Label6: TLabel;
Label7: TLabel;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn_ItemClick(Sender: TObject);
procedure btn_ite_ItemClick(Sender: TObject);
procedure btn_OrderClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DataSourceDataChange(Sender: TObject; Field: TField);
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
private
function ismorethanzero(fieldName:string;tableName:string;conditionfield:string):boolean;
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
function getMrpdate:string;
{ Public declarations }
end;
var
Frm_Mrp_Enter_InformalMrpInfo: TFrm_Mrp_Enter_InformalMrpInfo;
ItemCode:string;
implementation
uses Sys_Global, Mrp_Qry_UpRightMrp_D_Item, Mrp_Qry_InformalTotalMrp_Item,
Mrp_Qry_InformalTotalMrp_Po, Mrp_Qry_InformalTotalMrp_Mo;
{$R *.DFM}
procedure TFrm_Mrp_Enter_InformalMrpInfo.InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);
var sqltext:string;
begin
Application.ProcessMessages;
Inherited;
lbl_RunMrpdate.Caption:=getMrpdate;
sqltext:='select *,Sysqty=ssqty,ssreMainqty=reMainqty into #tmpInformalssInfo from Informalss '
+' where ssSysInfoflag=1 '
+' and PmType=0 '
+' union '
+' select *,Sysqty=ssqty,ssreMainqty=0 from Informalss '
+' where ssSysInfoflag=3 '
+' and Orderlinestatus<>7 '
+' and exists(select mono from MoLine where Orderno=MoLine.mono) '
+' union '
+' select Informalss.*,Sysqty=Informalss.ssqty,ssreMainqty=0 from Informalss '
+' where ssSysInfoflag=4 '
// +' and Orderlinestatus<>7 '
+' and exists(select mono from MoLine where Orderno=MoLine.mono and Orderlineno=MoLine.MoLineno and MoLine.MoLinestatus<>7) '
+' union '
+' select Informalss.*, '
+' ssqty=case when Informalss.reMainqty<MoLine.moqty then MoLine.moqty-Informalss.reMainqty '
+' else Informalss.ssqty '
+ ' end, '
+' ssreMainqty=0 '
+' from Informalss,MoLine '
+' where ssSysInfoflag=2 '
+' and Orderlinestatus<>7 '
+' and exists(select mono from MoLine where Orderno=MoLine.mono) '
+' and Informalss.Orderno=MoLine.mono '
+' and Informalss.Orderlineno=MoLine.MoLineno ';
Executesql(AdoQry_Main,sqltext,1);
sqltext:='select #tmpInformalssInfo.*,tMpssreMainqty=case #tmpInformalssInfo.ssreMainqty when 0 then null else #tmpInformalssInfo.ssreMainqty end,Item.mnldtime,Item.ItemName,Uom.UomCode,Uom.UomName,Dept.DeptCode,Dept.DeptName,'
+' Employee.EmployeeCode,Employee.EmployeeName,'
+' ssflag=convert(varchAr,#tmpInformalssInfo.ssSysInfoflag)+'' ''+SysssInfo.ssName,'
+' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag,'
+' Dept.DeptCode+'''+' '+'''+Dept.DeptName As DeptFlag, '
+' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag,'
+' Item.PmCode,'
+' ConVert(varchAr,SysSsInfo.SSCode)+'''+' '+'''+SysSsInfo.SsName As SsName'
+' into #tmpInformalssInfoResult '
+' From #tmpInformalssInfo '
+' Join Item On #tmpInformalssInfo.ItemCode=Item.ItemCode '
+' And PmType=0 '
+' Left Join Dept On isnull(#tmpInformalssInfo.DeptVendorCode,Item.DeptCode)=Dept.DeptCode'
// +' Left Join Dept On (Case When #tmpInformalssInfo.SsSysInfoFlag<>1 Then #tmpInformalssInfo.DeptVendorCode Else Item.DeptCode end)=Dept.DeptCode'
+' Left Join Employee On Item.Pla_EmployeeCode=Employee.EmployeeCode'
+' left Join Uom On Item.UomCode=Uom.UomCode'
+' Join SysSsInfo On #tmpInformalssInfo.SSSysInfoFlag=SysSsInfo.SSCode'
+' Order by #tmpInformalssInfo.ItemCode,ssdate';
Executesql(AdoQry_Main,sqltext,1);
Executesql(AdoQry_Main,'select * from #tmpInformalssInfoResult',0);
selectfromsql:='select * from #tmpInformalssInfoResult';
//------------------------------------------------------------------------
{SelectFromSql:=' Select InformalSs.*,Item.ItemName,Item.UomCode,Uom.UomName,Dept.DeptCode,Dept.DeptName,'
+' ConVert(varchAr(10),SysSsInfo.SSCode)+'''+' '+'''+SysSsInfo.SsName As Ssflag,'
+' SysssInfo.ssName,'
+' Informalss.DeptVendorCode+'''+' '+'''+DeptName As DeptFlag, '
+' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag, '
+' Employee.EmployeeCode,Employee.EmployeeName,'
+' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag '
+' From Informalss '
+' Join Item On Item.ItemCode= Informalss.ItemCode '
+' And InformalSs.PmType=0 '
+' Join Uom On Item.UomCode=Uom.UomCode '
+' Left Join Dept On (Case When Informalss.SsSysInfoFlag<>1 Then Informalss.DeptVendorCode Else Item.DeptCode end)=Dept.DeptCode '
+' Left Join Employee On Item.Pla_EmployeeCode=Employee.EmployeeCode '
+' Join SysSsInfo On InformalSs.SSSysInfoFlag=SysSsInfo.SSCode ';
OrderByFields:='SSDate,EmployeeCode ';
GetData; }
Application.ProcessMessages;
end;
procedure TFrm_Mrp_Enter_InformalMrpInfo.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Mrp_Enter_InformalMrpInfo:=Nil;
end;
function TFrm_Mrp_Enter_InformalMrpInfo.getMrpdate: string;
var AdoQry:TAdoQuery;
begin
AdoQry:=TAdoQuery.Create(self);
try
with AdoQry do
begin
Close;
Connection:=dbconnect;
sql.clear;
sql.Text:=' Select MrpParamValueC '
+' From MrpParam '
+' Where MrpParamCode=''InformalRunMrpDate'' ';
Prepared;
try
open;
Result:=fieldbyname('MrpParamValuec').asstring;
except
Result:='';
end;
end;
finally
AdoQry.Free;
end;
end;
procedure TFrm_Mrp_Enter_InformalMrpInfo.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
Executesql(AdoQry_tmp,'drop table #tmpInformalssInfo,#tmpInformalssInfoResult',1);
end;
procedure TFrm_Mrp_Enter_InformalMrpInfo.btn_ItemClick(Sender: TObject);
begin
inherited;
if AdoQry_Main.RecordCount=0 then
begin
activecontrol:=dbgrideh;
exit;
end;
Qry_Item(dbconnect,AdoQry_Main.fieldbyname('ItemCode').asstring);
activecontrol:=dbgrideh;
{ try
Frm_Mrp_Qry_UpRightMrp_D_Item:=TFrm_Mrp_Qry_UpRightMrp_D_Item.Create(Application);
with Frm_Mrp_Qry_UpRightMrp_D_Item do
begin
with AdoQry_tmp do
begin
Connection:=dbconnect;
Close;
sql.clear;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -