.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);
}
}
}