.Net(c#)调用采用"提取模式"获取数据的水晶报表
2024-07-10 13:03:44
供稿:网友
网站运营seo文章大全提供全面的站长运营经验及seo技术!using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using crystaldecisions.crystalreports.engine;
using crystaldecisions.shared;
namespace dllcrystal
{
/// <summary>
/// frmcrystalview 的摘要说明。
/// </summary>
internal class frmcrystalview : system.windows.forms.form
{
private crystaldecisions.windows.forms.crystalreportviewer crview;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private system.componentmodel.container components = null;
private string[] strinfo;
public frmcrystalview(string[] strinfomation)
{
//
// windows 窗体设计器支持所必需的
//
initializecomponent();
//
// todo: 在 initializecomponent 调用后添加任何构造函数代码
//
strinfo=strinfomation;
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}
#region windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void initializecomponent()
{
this.crview = new crystaldecisions.windows.forms.crystalreportviewer();
this.suspendlayout();
//
// crview
//
this.crview.activeviewindex = -1;
this.crview.dock = system.windows.forms.dockstyle.fill;
this.crview.location = new system.drawing.point(0, 0);
this.crview.name = "crview";
this.crview.reportsource = null;
this.crview.showrefreshbutton = false;
this.crview.size = new system.drawing.size(640, 509);
this.crview.tabindex = 0;
//
// frmcrystalview
//
this.autoscalebasesize = new system.drawing.size(6, 14);
this.clientsize = new system.drawing.size(640, 509);
this.controls.add(this.crview);
this.name = "frmcrystalview";
this.text = "预览报表";
this.load += new system.eventhandler(this.frmcrystalview_load);
this.resumelayout(false);
}
#endregion
private void frmcrystalview_load(object sender, system.eventargs e)
{
reportdocument rdview=new reportdocument();
rdview.load(@strinfo[0]);
foreach (table tbview in rdview.database.tables)
{
tablelogoninfo tliview=new tablelogoninfo();
tliview=tbview.logoninfo;
tliview.connectioninfo.servername=strinfo[1];
tliview.connectioninfo.databasename=strinfo[2];
tliview.connectioninfo.userid=strinfo[3];
tliview.connectioninfo.password=strinfo[4];
tbview.applylogoninfo(tliview);
}
string [] strparameter=strinfo[5].split(new char[] {'+'});
for (int i=0;i<strparameter.length;i++)
{
string [] strsubparam=strparameter[i].split(new char[] {'='});
parametervalues pvvalue=new parametervalues();
parameterdiscretevalue pdvvalue=new parameterdiscretevalue();
pdvvalue.value=strsubparam[1];
pvvalue.add(pdvvalue);
rdview.datadefinition.parameterfields[strsubparam[0]].applycurrentvalues(pvvalue);
}
crview.reportsource=rdview;
this.location = new point(0, 0);
this.size = new system.drawing.size(1024,744);
}
}
}