web报表打印
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmElectronicStatementPrint.aspx.cs" Inherits="FundInfoMg_Report_FrmElectronicStatementPrint" %>
<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<CR:CrystalReportViewer ID="crpView" runat="server"
AutoDataBind="true" />
</form>
</body>
</html>
----------------------------------------------------------------
#region//必要的成员及属性
private DSElectronicStatement dsElectronicStatement = null;
private BLElectronicStatement blElectronicStatement = null;
public DSElectronicStatement DsElectronicStatement
{
get
{
if (dsElectronicStatement == null)
{
this.dsElectronicStatement = new DSElectronicStatement();
}
return this.dsElectronicStatement;
}
set
{
this.dsElectronicStatement = value;
}
}
public BLElectronicStatement BlElectronicStatement
{
get
{
if (this.blElectronicStatement == null)
{
this.blElectronicStatement = new BLElectronicStatement();
}
return blElectronicStatement;
}
}
#endregion
ReportDocument oRpt = new ReportDocument();
protected override void OnUnload(EventArgs e)
{
oRpt.Dispose();
crpView.Dispose();
}
protected void Page_Load(object sender, EventArgs e)
{
string PK_ElectronicStatement = Request["id"];
string sqlCondition = string.Format("{0}.{1} = {2}",
this.DsElectronicStatement.DT_ElectronicStatement.TableName,
this.DsElectronicStatement.DT_ElectronicStatement.PK_ElectronicStatementColumn.ColumnName,PK_ElectronicStatement);
this.DsElectronicStatement = this.BlElectronicStatement.QueryDataByCondition(this.DsElectronicStatement, this.DsElectronicStatement.DT_ElectronicStatement.TableName, sqlCondition);
this.DsElectronicStatement = this.blElectronicStatement.QueryDataByCondition(this.DsElectronicStatement, this.DsElectronicStatement.DT_ElectronicStatementDetail.TableName, sqlCondition);
oRpt.Load(Server.MapPath("CRElectronicStatement.rpt"));
TextObject detailSum1 = (TextObject)oRpt.ReportDefinition.ReportObjects["txtDetailSum1"];
TextObject detailSum2 = (TextObject)oRpt.ReportDefinition.ReportObjects["txtDetailSum2"];
decimal decTotal1 = 0;
decimal decTotal2 = 0;
foreach(DSElectronicStatement.DT_ElectronicStatementDetailRow drDetail in this.DsElectronicStatement.DT_ElectronicStatementDetail)
{
if (!drDetail.IsESD_Item1Null())
{
decTotal1 += drDetail.ESD_Item1;
}
if (!drDetail.IsESD_Item2Null())
{
decTotal2 += drDetail.ESD_Item2;
}
}
detailSum1.Text = decTotal1.ToString("C");
detailSum2.Text = decTotal2.ToString("C");
oRpt.SetDataSource(DsElectronicStatement);
crpView.DisplayGroupTree = false;
crpView.ReportSource = oRpt;
Page.MaintainScrollPositionOnPostBack = true;
}