📄 mrp_qry_graphanalyzercapacity_d.pas
字号:
unit Mrp_Qry_GraphAnalyzerCapacity_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls;
Type
TFrm_Mrp_Qry_GraphAnalyzerCapacity_D = Class(TFrm_Base_Qry)
AdoQry_MainWcCode: TStringField;
AdoQry_Mainmono: TStringField;
AdoQry_MainMoLineno: TIntegerField;
AdoQry_Mainmoqty: TFloatField;
AdoQry_Mainmohours: TFloatField;
AdoQry_MainMpsType: TStringField;
AdoQry_MainWCName: TStringField;
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainOverCapacity: TFloatField;
AdoQry_MainOverCapacityrate: TStringField;
AdoQry_Mainwcflag: TStringField;
AdoQry_MainItemflag: TStringField;
Label2: TLabel;
Label1: TLabel;
dbtxtItemflag: TDBText;
dbtxtmono: TDBText;
Label3: TLabel;
dbtxtOverCapacityrate: TDBText;
dbtxtMpsType: TDBText;
Label4: TLabel;
AdoQry_MainCapacityhours: TFloatField;
AdoQry_Mainmodate: TDateTimeField;
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_GraphAnalyzerCapacity_D: TFrm_Mrp_Qry_GraphAnalyzerCapacity_D;
implementation
uses Mrp_Qry_GraphAnalyzerCapacity,Sys_Global;
{$R *.DFM}
{ TFrm_Mrp_Qry_GraphAnalyzerCapacity_D }
procedure TFrm_Mrp_Qry_GraphAnalyzerCapacity_D.InitForm(
AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext:string;
begin
inherited;
sqltext:='Select CAp.WcCode,'+
'cAp.mono,'+
'cAp.MoLineno,'+
'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 (case it1.Capacityhours when 0 then 100 else (cAp.mohours-it1.Capacityhours)*100/it1.Capacityhours end)>0'+
' and cAp.wcCode='''+wcCodecondition+''''+
' and ((cAp.MpsType='''+MpsTypecondition+''''+')'+' or ('''+MpsTypecondition+''''+'=''全部''))';
if dateTypecondition='日' then
begin
sqltext:=sqltext+' and ((cAp.modate='''+timesection+''''+') or ('''+timesection+''''+'=''9999''))';
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(timesection)+' or '+quotedstr(timesection)+'=''9999'')';
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))='''+timesection+''''+') or ('+timesection+'=''9999''))';
end;
selectfromsql:='select * from #tmp2';
with AdoQry_Main 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_GraphAnalyzerCapacity.Lbl_Condition.Caption;
end;
procedure TFrm_Mrp_Qry_GraphAnalyzerCapacity_D.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('drop table #tmp2');
try
execsql;
except
end;
end;
end;
procedure TFrm_Mrp_Qry_GraphAnalyzerCapacity_D.FormDestroy(
Sender: TObject);
begin
inherited;
Frm_Mrp_Qry_GraphAnalyzerCapacity_D:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -