Crystal Reports 11 - 禁用参数对话框 [英] Crystal Reports 11 - Disable Parameters Dialog Box

查看:48
本文介绍了Crystal Reports 11 - 禁用参数对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何在Crystal Reports XI中禁用参数对话框。


我正在使用C#和Visual Studio.NET 2003。


我将参数传递给应用程序中的字段,但无论我做什么,讨厌的对话框都会弹出。


任何提示?

解决方案

我在过去的4个小时里一直与之斗争。


好的,这是交易。我使用使用Crystal 9.x创建的嵌入式报表,使用C#(2003)编写了一个运行良好的应用程序。安装Crystal XI之后,现在它就像你看到的那样弹出对话框。


花了两个部分我的应用程序再次正常工作。首先,我必须将参数属性HasCurrentValue设置为true,如下所示:


foreach (CrystalDecisions.Shared.ParameterField pf in rpt.ParameterFields)


{


pf.HasCurrentValue = true ;


}


我要做的第二件事是将报告查看器参数集合设置为与报告相同:


crystalReportViewer1.ParameterFieldInfo = rpt.P arameterFields;



对我来说,最重要的技巧是在将报告的数据源设置为我的预生成数据集(使用dataAdapter(命令)创建)之前必须设置HasCurrentValue



(数据集创建代码)


public 静态 ACS.dsCheckRPT OutstandingChecks(System.DateTime StartDate,System.DateTime EndDate)


{


using (sq l.SqlConnection conn = new sql.SqlConnection(dfw.CreateDataFrameWork()._ connstring))


{


conn.Open();


sql.SqlCommand cmd = new sql.SqlCommand(" dbo.pr_PHP_ACS_RPT_OUTSTANDINGCHECKS",conn);


cmd.CommandType = System.Data.CommandType.StoredProcedure;


cmd.Parameters.Add(" @ START_DATE",sqltype.DateTime).Value = StartDate;


cmd.Parameters.Add(" @ END_DATE",sqltype.DateTime).Value = EndDate;



ACS.dsCheckRPT ds = new ACS.dsCheckRPT();


System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);


da.Fill(ds," CheckData");


return ds;


}


}



(报告创建代码)


ACS.CheckData rpt = new ACS.CheckData() ;


rpt.SetParameterValue(" StartDate",dtpStartDate.Value);


rpt.SetParameterValue(" EndDate",dtpEndDate.Value);


rpt.SetParameterValue(" ReportTitle"," Outstanding Checks");


//检查数据


ACS.dsCheckRPT ds = ACS.Data.DataFrameWork.Reports.OutstandingChecks(dtpSta rtDate.Value,dtpEndDate.Value);


// DisplayData(ds.Tables [0]);



// CR XI要求


foreach (CrystalDecisions.Shared.ParameterField pf in rpt.ParameterFields)


{


pf.HasCurrentValue = true ;


}



rpt.SetDataSource(ds);



ACS.frmRptViewer.ShowReport(rpt);



(实例报告的静态方法)观众)


< font color ="#0000ff"size = 2> public static void ShowReport(CrystalDecisions.CrystalReports。 Engine.ReportDocument rd)


{


ACS.frmRptViewer frm = new frmRptViewer(rd);


frm.MdiParent = ACS.GlobalData.MdiParent;


frm.Show();


}



(报告查看器构造函数)


public frmRptViewer(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt)


{


//


// Windows窗体设计器支持需要


//

< font size = 2>

InitializeComponent();



crystalReportViewer1.ReportSource = rpt;



// CR XI要求。需要设置查看器信息,否则会弹出一个对话框。


crystalReportViewer1.ParameterFieldInfo = rpt.ParameterFields;


}



祝你好运!!!


Does anyone know how to disable the parameters dialog box in Crystal Reports XI.

I am using C# and Visual Studio.NET 2003.

I am passing the parameters to the field from the application, but the pesky dialog box keeps poping up no matter what I do.

Any tips?

解决方案

I just fought with this for the past 4 hours.

Ok, here's the deal.  I had a perfectly running application written in C# (2003) using an embedded report created with Crystal 9.x.  After installing Crystal XI, now it pops up the dialog like you are seeing.

It took 2 parts for my app to work normal again.  First, I had to set the parameter property HasCurrentValue to true as follows:

foreach(CrystalDecisions.Shared.ParameterField pf in rpt.ParameterFields)

{

   pf.HasCurrentValue = true;

}

The second thing I had to do was to set the report viewers parameter collection to the same as the report's:

crystalReportViewer1.ParameterFieldInfo = rpt.ParameterFields;

 

The big trick for me was I had to set HasCurrentValue prior to setting the report's datasource to my pregenerated dataset (created using dataAdapter(command))

 

(dataset creation code)

public static ACS.dsCheckRPT OutstandingChecks(System.DateTime StartDate, System.DateTime EndDate)

{

using (sql.SqlConnection conn = new sql.SqlConnection(dfw.CreateDataFrameWork()._connstring))

{

conn.Open();

sql.SqlCommand cmd = new sql.SqlCommand("dbo.pr_PHP_ACS_RPT_OUTSTANDINGCHECKS",conn);

cmd.CommandType = System.Data.CommandType.StoredProcedure;

cmd.Parameters.Add("@START_DATE",sqltype.DateTime).Value = StartDate;

cmd.Parameters.Add("@END_DATE",sqltype.DateTime).Value = EndDate;

ACS.dsCheckRPT ds = new ACS.dsCheckRPT();

System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);

da.Fill(ds,"CheckData");

return ds;

}

}

 

(report creation code)

ACS.CheckData rpt = new ACS.CheckData();

rpt.SetParameterValue("StartDate",dtpStartDate.Value);

rpt.SetParameterValue("EndDate",dtpEndDate.Value);

rpt.SetParameterValue("ReportTitle","Outstanding Checks");

// check the data

ACS.dsCheckRPT ds = ACS.Data.DataFrameWork.Reports.OutstandingChecks(dtpStartDate.Value,dtpEndDate.Value);

//DisplayData(ds.Tables[0]);

//CR XI requirement

foreach(CrystalDecisions.Shared.ParameterField pf in rpt.ParameterFields)

{

pf.HasCurrentValue = true;

}

rpt.SetDataSource(ds);

ACS.frmRptViewer.ShowReport(rpt);

 

(static method to instance report viewer)

public static void ShowReport(CrystalDecisions.CrystalReports.Engine.ReportDocument rd)

{

ACS.frmRptViewer frm = new frmRptViewer(rd);

frm.MdiParent = ACS.GlobalData.MdiParent;

frm.Show();

}

 

(report viewer constructor)

public frmRptViewer(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt)

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

crystalReportViewer1.ReportSource = rpt;

// CR XI requirement. Need to set the viewer info otherwise it pops up a dialog.

crystalReportViewer1.ParameterFieldInfo = rpt.ParameterFields;

}

 

Good luck!!!


这篇关于Crystal Reports 11 - 禁用参数对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆