📄 mrp_qry_analyzercapacity_d.pas
字号:
unit Mrp_Qry_AnalyzerCapacity_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, DBCtrls;
Type
TFrm_Mrp_Qry_AnalyzerCapacity_D = Class(TFrm_Base_Entry_Head)
AdoQry_HeadWcCode: TStringField;
AdoQry_Headmono: TStringField;
AdoQry_HeadMoLineno: TIntegerField;
AdoQry_HeadMoLinedate: TDateTimeField;
AdoQry_Headmoqty: TFloatField;
AdoQry_Headmohours: TFloatField;
AdoQry_HeadMpsType: TStringField;
AdoQry_HeadWCName: TStringField;
AdoQry_HeadItemCode: TStringField;
AdoQry_HeadItemName: TStringField;
AdoQry_HeadOverCapacity: TFloatField;
AdoQry_HeadOverCapacityrate: TStringField;
AdoQry_Headwcflag: TStringField;
AdoQry_HeadItemflag: TStringField;
Label2: TLabel;
dbtxtmono: TDBText;
Label3: TLabel;
dbtxtOverCapacityrate: TDBText;
dbtxtMpsType: TDBText;
Label4: TLabel;
dbtxtItemflag: TDBText;
Label1: TLabel;
AdoQry_HeadCapacityhours: TFloatField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
{ Public declarations }
end;
var
Frm_Mrp_Qry_AnalyzerCapacity_D: TFrm_Mrp_Qry_AnalyzerCapacity_D;
implementation
uses Mrp_Qry_AnalyzerCapacity,Sys_Global;
{$R *.DFM}
{ TFrm_Mrp_Qry_AnalyzerCapacity_D }
procedure TFrm_Mrp_Qry_AnalyzerCapacity_D.InitForm(
AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext:string;
begin
inherited;
sqltext:='Select CAp.WcCode,'+
'cAp.mono,'+
'cAp.MoLineno,'+
'MoLinedate=cAp.modate,'+
'cAp.moqty,'+
'cAp.mohours,'+
'it1.Capacityhours,'+
'cAp.MpsType,'+
'It1.ItemName As WCName,'+
'wcflag=cAp.wcCode+'' ''+it1.ItemName,'+
'Itemflag=cAp.ItemCode+'' ''+it2.ItemName,'+
'cAp.ItemCode,'+
'It2.ItemName,'+
'OverCapacity=cAp.mohours-it1.Capacityhours,'+
'OverCapacityrate=convert(varchAr,convert(decimal(12,2),case it1.Capacityhours'+
' when 0 then 100'+
' else (cAp.mohours-it1.Capacityhours)*100/it1.Capacityhours'+
' end ))+''%'''+
' into #tmp2 '+
' From Capacity CAp(nolock)'+
' left outer join Item it1(nolock) on cAp.wcCode=it1.ItemCode'+
' left outer join MoLine mol on cAp.mono=mol.mono and cAp.MoLineno=mol.MoLineno'+
' left outer join Item it2 on cAp.ItemCode=it2.ItemCode'+
' where cAp.wcCode='''+wcCodecondition+''''+
' and (cAp.MpsType='''+MpsTypecondition+''''+' or '''+MpsTypecondition+''''+'=''全部'')';
if dateTypecondition='日' then
begin
sqltext:=sqltext+' and cAp.modate='''+Frm_Mrp_Qry_AnalyzerCapacity.AdoQry_Head.fieldbyname('FinishMonth').asstring+'''';
end
else
if dateTypecondition='周' then
begin
sqltext:=sqltext+' and cAp.modate between '''+stArtdate+''''+' and ''2999.12.31''';
sqltext:=sqltext+' and convert(varchAr,datepArt(yy,cAp.modate))+''年''+convert(varchAr,datepArt(mm,cAp.modate))+''月第''+convert(varchAr,datepArt(wk,cAp.modate)-datepArt(wk,convert(varchAr,datepArt(yy,cAp.modate))+''.''';
sqltext:=sqltext+'+convert(varchAr,datepArt(mm,cAp.modate))+''.01'')+1)+''周''=';
sqltext:=sqltext+quotedstr(Frm_Mrp_Qry_AnalyzerCapacity.AdoQry_Head.fieldbyname('FinishMonth').asstring);
end
else
if dateTypecondition='月' then
begin
sqltext:=sqltext+' and cAp.modate between '''+stArtdate+''''+' and ''2999.12.31''';
sqltext:=sqltext+' and convert(varchAr,datepArt(yy,cAp.modate))+''.''+convert(varchAr,datepArt(mm,cAp.modate))='''+Frm_Mrp_Qry_AnalyzerCapacity.AdoQry_Head.fieldbyname('FinishMonth').asstring+'''';
end;
selectfromsql:='select * from #tmp2';
with AdoQry_Head do
begin
Close;
sql.clear;
sql.Add(sqltext);
Prepared;
try
execsql;
except
end;
Close;
sql.clear;
sql.Add('select * from #tmp2');
open;
if recordCount=0 then
begin
DispInfo('无当前工作中心当前时间段的能力需求相关数据!',3);
self.Close;
end;
end;
lbl_Condition.Caption:=Frm_Mrp_Qry_AnalyzerCapacity.Lbl_Condition.Caption;
end;
procedure TFrm_Mrp_Qry_AnalyzerCapacity_D.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('drop table #tmp2');
try
execsql;
except
end;
end;
inherited;
end;
procedure TFrm_Mrp_Qry_AnalyzerCapacity_D.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Mrp_Qry_AnalyzerCapacity_D:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -