using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//Need these to run a Crystal Report
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
namespace Extranet.Reports
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
////////////////////
// Use the name vs.net gives you here, so it matches with
// the aspx page..
///////////////////
public class document_log_hits_person_graph1 : System.Web.UI.Page
{
//This is the report viewer control.
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
///////////////////////////
// param adding func - thanks to whoever I nicked this off!
///////////////////////////
private static void SetReportParameter(ReportDocument report, string parameterName, object parameterValue)
{
ParameterFieldDefinition crParamDef;
ParameterValues currentValues;
ParameterDiscreteValue paramValue = new ParameterDiscreteValue();
crParamDef = report.DataDefinition.ParameterFields[parameterName];
currentValues = crParamDef.CurrentValues;
paramValue.Value = parameterValue;
currentValues.Add(paramValue);
crParamDef.ApplyCurrentValues(currentValues);
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
//Create a new report object.
ReportDocument crReportDocument = new ReportDocument();
//////////////////////////////////
// escaped physical location
//////////////////////////////////
crReportDocument.Load("C:\\Inetpub\\[URL unfurl="true"]wwwroot\\BluePrintStage\\Central\\Extranet\\Reports\\document_log_hits_person_graph.rpt");[/URL]
//Create a logonInfo Structure
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
//Crystal Report Properties
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
crConnectionInfo.ServerName = "dbserver";
crConnectionInfo.DatabaseName = "dbname";
crConnectionInfo.UserID = "user";
crConnectionInfo.Password = "password";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
foreach(CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
SetReportParameter(crReportDocument, "dateStart", Request.QueryString["dateStart"]);
SetReportParameter(crReportDocument, "item_FKID", Request.QueryString["item_FKID"]);
CrystalReportViewer1.ReportSource = crReportDocument;
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}