我做了一个报表向导的窗口,打开不同的报表窗口。当打开一个报表(预览状态)关闭后,再关闭报表向导窗口时,就报错:“对象必须在环境释放之前释放”!下面是报表向导窗口的代码,请问到底是哪个对象没有释放掉啊????
unit BBXDCT;
interface
uses
Business.System, Business.Forms, Business.System.SysUtils, GGHS, Business.Data, Business.Model;
type
TBBXDCT = class(TForm)
Shape1: TShape;
GroupBox2: TGroupBox;
dtpTJSJ: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
btnNext: TButton;
btnCancel: TButton;
InfoBroker1: TInfoBroker;
DataSetBroker1: TDataSetBroker;
DataSetBroker2: TDataSetBroker;
DataSetBroker3: TDataSetBroker;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
DataSetBroker4: TDataSetBroker;
DataSetBroker5: TDataSetBroker;
procedure btnNextClick(Sender: TObject);
procedure btnExportClick(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
implementation
procedure TBBXDCT.btnNextClick(Sender: TObject);
var a: TBBSJCKFZYGJBCT;
var aa: TGBFSPTJHZCT;
var aaa: TSPFGBTJHZCT;
var ab: TMYFSHZB;
var abb: TMYFSFSPTJHZB;
var y: string;
var m: string;
var d: string;
var i: Integer;
var strSql: string;
begin
DateTimeToString(y, 'yyyy', dtpTJSJ.Date);
DateTimeToString(m, 'm', dtpTJSJ.Date);
DateTimeToString(d, 'd', dtpTJSJ.Date);
if(RadioButton1.Checked) then
begin
strSql := 'select a.国家地区,a.地区,a.累计金额, '
+'Round(a.累计金额/(select sum(FP.USD) from FP where Year(FP.IDate)='+y+' and Month(FP.IDate)<='+m+')*1000000,2) as 占总额, '
+'ISNULL(b.上年同期,0) as 上年同期, '
+'case when IsNull(b.上年同期,0)=0 then null else '
+'Round((a.累计金额-b.上年同期)/b.上年同期,2) end as 同比增长 '
+'from ( '
+'select COUNTRYCODE.NAME AS 国家地区,(select a.Name from CountryCode a where code=substring(COUNTRYCODE.code,1,3)) AS 地区, '
+'sum(FP.USD)/10000 as 累计金额 '
+'FROM FP, COUNTRYCODE '
+'WHERE '
+'FP.CountryId = COUNTRYCODE.CODE and COUNTRYCODE.CODELEVEL = 3 '
+'and COUNTRYCODE.OVERSEAS = 1 and FP.INVICETYPE <> ''投标业务'' and FP.INVICETYPE <> ''国内贸易'' '
+'and FP.INVICETYPE <> ''招标业务'' and FP.EMPLOYEEID is not null and FP.EMPLOYEEID <> '''' '
+'and (Year(FP.IDate)='+y+' and Month(FP.IDate)<='+m+' ) '
+'GROUP BY COUNTRYCODE.NAME,COUNTRYCODE.AREA,COUNTRYCODE.CODE,YEAR(FP.IDATE) '
+') a '
+'left join '
+'( '
+'select COUNTRYCODE.NAME AS 国家地区,(select a.Name from CountryCode a where code=substring(COUNTRYCODE.code,1,3)) AS 地区, '
+'sum(FP.USD)/10000 as 上年同期 '
+'FROM FP, COUNTRYCODE '
+'WHERE '
+'FP.CountryId = COUNTRYCODE.CODE and COUNTRYCODE.CODELEVEL = 3 '
+'and COUNTRYCODE.OVERSEAS = 1 and FP.INVICETYPE <> ''投标业务'' and FP.INVICETYPE <> ''国内贸易'' '
+'and FP.INVICETYPE <> ''招标业务'' and FP.EMPLOYEEID is not null and FP.EMPLOYEEID <> '''' '
+'and (Year(FP.IDATE)= '+IntToStr(StrToInt(y)-1)+' and Month(FP.IDate)<='+m+' ) '
//and ()
+'GROUP BY COUNTRYCODE.NAME,COUNTRYCODE.AREA,COUNTRYCODE.CODE,YEAR(FP.IDATE) '
+') b '
+'on a.国家地区=b.国家地区 '
+'order by a.地区,a.国家地区 ASC ';
TSQLDataSet(DataSetBroker1.DataSet).Close;
TSQLDataSet(DataSetBroker1.DataSet).SQL.Text := strSql;
TSQLDataSet(DataSetBroker1.DataSet).Open;
a := TBBSJCKFZYGJBCT.Create(Context);
a.Show;
end
else if(RadioButton2.Checked) then
begin
strSql := 'select ltrim(HT.CountryID) as 贸易国码, ltrim(CountryCode.Name) as 贸易国别,ltrim(HT.CIQId) as 海关代码, ltrim(GOODSCODE.NAME) as 商品名称 ,sum(HT.USD)/10000 as 累计金额 '
+' from HT,GOODSCODE,CountryCode '
+' where HT.INPUTDATE<='''+y+'-'+m+'-'+d+''' and HT.CIQId=GOODSCODE.CODE and CountryCode.Code=HT.CountryId '
+' group by HT.COUNTRYID,CountryCode.Name,HT.CIQId,GOODSCODE.NAME';
TSQLDataSet(DataSetBroker2.DataSet).Close;
TSQLDataSet(DataSetBroker2.DataSet).SQL.Text := strSql;
TSQLDataSet(DataSetBroker2.DataSet).Open;
aa := TGBFSPTJHZCT.Create(Context);
aa.Show;
end
else if(RadioButton3.Checked) then
begin
strSql := 'select lTrim(HT.CountryID) as 贸易国码,lTrim(CountryCode.Name) as 贸易国别,lTrim(HT.CIQId) as 海关代码,'
+' lTrim(GOODSCODE.NAME) as 商品名称 ,sum(HT.USD)/10000 as 累计金额 '
+' from HT,GOODSCODE,CountryCode '
+' where HT.INPUTDATE<='''+y+'-'+m+'-'+d+''' and HT.CIQId=GOODSCODE.CODE and CountryCode.Code=HT.CountryId '
+' group by HT.CIQId,GOODSCODE.NAME, HT.CountryID,CountryCode.Name';
TSQLDataSet(DataSetBroker3.DataSet).Close;
TSQLDataSet(DataSetBroker3.DataSet).SQL.Text := strSql;
TSQLDataSet(DataSetBroker3.DataSet).Open;
aaa := TSPFGBTJHZCT.Create(Context);
aaa.Show;
end
else if(RadioButton4.Checked) then
begin
strSql := 'select lTrim(a.贸易方式) as 贸易方式,lTrim(a.累计金额) as 累计金额,ISNULL(b.上年同期,0) as 上年同期, Round(a.累计金额*1000000/(select sum(USD) from HT'
+' where Year(InputDate)='+y+'),2) as 占总额 '
+' from (select TradeKindID as 贸易方式,sum(USD)/10000 as 累计金额 from HT where year(InputDate)='+y+' and month(InputDate)<'+m+' group by TradeKindID) a left join '
+' (select TradeKindID as 贸易方式, sum(USD)/10000 as 上年同期 from HT where year(InputDate)='+IntToStr(StrToInt(y)-1)+' and month(InputDate)<'+m+' group by '
+' TradeKindID) b '
+' on a.贸易方式=b.贸易方式';
TSQLDataSet(DataSetBroker4.DataSet).Close;
TSQLDataSet(DataSetBroker4.DataSet).SQL.Text := strSql;
TSQLDataSet(DataSetBroker4.DataSet).Open;
ab := TMYFSHZB.Create(Context);
ab.Show;
end
else if(RadioButton5.Checked) then
begin
strSql := 'select lTrim(HT.TradeKindId) as 贸易方式,lTrim(HT.CIQId) as 海关代码,lTrim(GoodsCode.Name) as 商品名称,sum(HT.USD)/10000 as 累计金额 '
+' from HT,GoodsCode '
+' where year(HT.InputDate)='+y+' and month(HT.InputDate)<'+m+' and HT.CIQId=GoodsCode.Code '
+' group by HT.TradeKindId,HT.CIQId,GoodsCode.Name';
TSQLDataSet(DataSetBroker5.DataSet).Close;
TSQLDataSet(DataSetBroker5.DataSet).SQL.Text := strSql;
TSQLDataSet(DataSetBroker5.DataSet).Open;
abb := TMYFSFSPTJHZB.Create(Context);
abb.Show;
end;
end;
end. |