Hi,
In my project file, can debug and can run every report dynamically by report viewer , then I publish to the server. It' was still file. and then I changed master page and I put again report viewer in upload panel. it's still work in local project folder. after publishing , crystal report viewer cannot work anymore on local IIS or server. I cannot see any report even though report path is correct. Finally , I remove the update panel and script manger ,then publish again. It' doesn't work anymore .What sould I do? what might be the problem?
Reportpanel.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Sql;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Web.Security;
using System.Web.UI;
using DevExpress.Web.ASPxEditors;
using DevExpress.WebUtils;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.ComponentModel.Design;
using Backend;
using MMProxy;
using DevExpress;
using System.IO;
using CrystalDecisions.Web;
using CrystalDecisions.Reporting;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using System.Drawing;
namespace REPORT_PORTAL_UAT
{
public partial class ReportPanel : System.Web.UI.Page
{
public static ReportDocument theReport;
ReportDocument reportDouc = new ReportDocument();
public static DataSet reportHeader;
public static DataSet reportDetail;
public static string rptParameterName;
public static string rptParameterValue;
public static List<Control> UIControls;
string pjrPath;
string usrID
{
get
{
if (Session["USER_ID"] != null)
return Convert.ToString(Session["USER_ID"]);
return string.Empty;
}
}
string usedDBName;
string userEmail
{
get
{
if (Session["USER_EMAIL"] != null)
return Convert.ToString(Session["USER_EMAIL"]);
return string.Empty;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["User_ID"] == null)
{
Response.Redirect("~/UserLogin.aspx");
}
else
{
ddlProject_BindData();
butGenerateReport.Visible = false;
showhide.Visible = false;
rptReportViewer.Visible = false;
}
}
}
protected override void LoadViewState(object savedState)
{
try
{
base.LoadViewState(savedState);
if (ViewState["controsladded"] == null)
BindParameters(Application["rptID"].ToString());
}
catch { }
}
void ddlProject_BindData()
{
DataBaseHelper.defineConnection = null;
DataSet ds = DataBaseHelper.RunSQL("SELECT DISTINCT * FROM SV_MASTER_PROJECT");
ddlProjectName.DataSource = ds;
ddlProjectName.TextField = "PROJECT_NAME";
ddlProjectName.ValueField = "PROJECT_ID";
ddlProjectName.DataBind();
}
void rdoReportName_Databind()
{
DataBaseHelper.defineConnection = null;
DataSet reportHeaderds = DataBaseHelper.RunSQL("SELECT DISTINCT * FROM SV_MASTER_REPORT WHERE PROJECT_ID=" + ddlProjectName.SelectedItem.Value.ToString());
reportHeader = reportHeaderds;
rdoReportName.DataSource = reportHeaderds;
rdoReportName.DataTextField = "REPORT_NAME";
rdoReportName.DataValueField = "REPORT_ID";
rdoReportName.DataBind();
}
protected void ddlProjectName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (CustomUITable.Rows.Count > 0)
{
CustomUITable.Rows.Clear();
for (int i = 0; i <= CustomUITable.Rows.Count; i++)
{
foreach (TableRow tr in CustomUITable.Rows)
{
CustomUITable.Rows.Remove(tr);
}
}
}
}
catch
{ }
showhide.Visible = false;
rptReportViewer.Visible = false;
butGenerateReport.Visible = false;
rptReportViewer.ReportSource = null;
rptReportViewer.RefreshReport();
reportDouc = null;
rptReportViewer.ParameterFieldInfo = null;
rdoReportName_Databind();
}
private void AddCustomAttribute(string rptDltID, string rptDtlDataType, string DisplayName, string paraMeterName, string displayType)
{
//Add a row to CustomUITable
TableRow tr = new TableRow();
//Add the name as the left cell
TableCell tdName = new TableCell();
tdName.Text = DisplayName;
tdName.VerticalAlign = VerticalAlign.Top;
tr.Cells.Add(tdName);
//Add the UI as the right cell
UIControls = CreateCustomAttributeUI(rptDltID, rptDtlDataType, DisplayName, paraMeterName, displayType);
TableCell tdUI = new TableCell();
tdUI.VerticalAlign = VerticalAlign.Top;
foreach (Control ctrl in UIControls)
{
tdUI.Controls.Add(ctrl);
}
tr.Cells.Add(tdUI);
CustomUITable.Rows.Add(tr);
}
private List<Control> CreateCustomAttributeUI(string rptDltID, string rptDtlDataType, string DisplayName, string paraMeterName, string rptdisplayType)
{
List<Control> ctrls = new List<Control>();
if (rptdisplayType == "TEXTBOX")
{
//Use a TextBox
string stringValue = string.Empty;
if (!Convert.IsDBNull(paraMeterName))
{
stringValue = paraMeterName.ToString();
}
ASPxTextBox tb = new ASPxTextBox();
tb.ID = rptDltID;
tb.Width =200;
tb.SpriteCssFilePath = "~/App_Themes/Aqua/{0}/sprite.css";
ctrls.Add(tb);
}
else if (rptdisplayType == "NUMERIC TEXTBOX WITH OPERATOR")
{
ASPxComboBox dlOperator = new ASPxComboBox();
ListItemCollection opItem = new ListItemCollection();
opItem.Add(new ListItem("="));
opItem.Add(new ListItem("<>"));
opItem.Add(new ListItem(">"));
opItem.Add(new ListItem("<"));
opItem.Add(new ListItem(">="));
opItem.Add(new ListItem("<="));
dlOperator.DataSource = opItem;
dlOperator.DataBind();
dlOperator.ID = "cboOpNumeric";
ctrls.Add(dlOperator);
string stringValue = string.Empty;
if (!Convert.IsDBNull(paraMeterName))
{
stringValue = paraMeterName.ToString();
}
ASPxTextBox tb = new ASPxTextBox();
tb.ID = rptDltID;
//tb.Text = stringValue;
ctrls.Add(tb);
RegularExpressionValidator val = new RegularExpressionValidator();
val.ControlToValidate = tb.ID;
val.ToolTip = "Only can accept Number";
val.Text = "*";
val.ValidationExpression = "^[0-9]*$";
ctrls.Add(val);
}
else if (rptdisplayType == "DATETIME PICKER")
{
string stringValue = string.Empty;
if (!Convert.IsDBNull(paraMeterName))
{
stringValue = paraMeterName.ToString();
}
ASPxDateEdit dpt = new ASPxDateEdit();
dpt.ID = rptDltID;
//dpt.Text = stringValue;
ctrls.Add(dpt);
}
else if (rptdisplayType == "DATETIME PICKER WITH OPERATOR")
{
ASPxComboBox dlOperator = new ASPxComboBox();
ListItemCollection opItem = new ListItemCollection();
opItem.Add(new ListItem("="));
opItem.Add(new ListItem("<>"));
opItem.Add(new ListItem(">"));
opItem.Add(new ListItem("<"));
opItem.Add(new ListItem(">="));
opItem.Add(new ListItem("<="));
dlOperator.DataSource = opItem;
dlOperator.DataBind();
dlOperator.ID = "cboOpNumeric";
ctrls.Add(dlOperator);
string stringValue = string.Empty;
if (!Convert.IsDBNull(paraMeterName))
{
stringValue = paraMeterName.ToString();
}
ASPxDateEdit dpt = new ASPxDateEdit();
dpt.ID = rptDltID;
//dpt.Text = stringValue;
ctrls.Add(dpt);
}
return ctrls;
}
void BindParameters(string rptID)
{
DataBaseHelper.defineConnection = null;
DataSet rptdtl = DataBaseHelper.RunSQL("SELECT DISTINCT REPORT_DTL_ID,REPORT_ID,PARAMETER_NAME,DATA_TYPE,PARAMETER_FIELD,DISPLAY_TYPE FROM MASTER_REPORT_DTL WHERE REPORT_ID=" + rptID);
reportDetail = rptdtl;
if (reportDetail.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < rptdtl.Tables[0].Rows.Count; i++)
{
string rptdtlID = rptdtl.Tables[0].Rows[i]["REPORT_DTL_ID"].ToString();
string paraName = rptdtl.Tables[0].Rows[i]["PARAMETER_FIELD"].ToString();
string displayName = rptdtl.Tables[0].Rows[i]["PARAMETER_NAME"].ToString();
string datatype = rptdtl.Tables[0].Rows[i]["DATA_TYPE"].ToString();
string displayType = rptdtl.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString();
AddCustomAttribute(rptdtlID, datatype, displayName, paraName, displayType);
}
}
else
{
}
ViewState["controlsadded"] = true;
}
protected void rdoReportName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (CustomUITable.Rows.Count > 0)
{
CustomUITable.Rows.Clear();
for (int i = 0; i <= CustomUITable.Rows.Count; i++)
{
foreach (TableRow tr in CustomUITable.Rows)
{
CustomUITable.Rows.Remove(tr);
}
}
}
}
catch
{ }
rptReportViewer.ReportSource = null;
rptReportViewer.RefreshReport();
reportDouc = null;
rptReportViewer.ParameterFieldInfo = null;
showhide.Visible = false;
rptReportViewer.Visible = false;
Application["rptID"] = rdoReportName.SelectedValue.ToString();
BindParameters(Application["rptID"].ToString());
butGenerateReport.Visible = true;
}
private DataSet GetDataSet()
{
DataSet ds = new DataSet();
return ds;
}
protected void butGenerateReport_Click(object sender, EventArgs e)
{
showhide.Visible = true;
rptReportViewer.Visible = true;
BindReportViewer();
}
#region SqlParameter
//private SqlParameter GetValueForCustomAttribute(string rptDltid, string dataType, bool isRange, bool isOperator)
//{
// SqlParameter userInputParam = new SqlParameter();
// Control ctrl = CustomUITable.FindControl(rptDltid);
// if (dataType == "NVARCHAR")
// {
// TextBox tb = (TextBox)ctrl;
// userInputParam.DbType = System.Data.DbType.String;
// if (!string.IsNullOrEmpty(tb.Text))
// {
// userInputParam.Value = tb.Text.Trim();
// }
// }
// if (isRange == true)
// {
// ASPxDateEdit dtp = (ASPxDateEdit)ctrl;
// userInputParam.DbType = System.Data.DbType.String;
// if (!string.IsNullOrEmpty(dtp.Text))
// {
// userInputParam.Value = dtp.Text.ToString();
// }
// }
// return userInputParam;
//}
#endregion
private void BindReportViewer()
{
try
{
ArrayList commands = new ArrayList();
ArrayList values = new ArrayList();
for (int i = 0; i < CustomUITable.Controls.Count; i++)
{
Control ctrl = CustomUITable.FindControl(reportDetail.Tables[0].Rows[i]["REPORT_DTL_ID"].ToString());
rptParameterName = reportDetail.Tables[0].Rows[i]["PARAMETER_FIELD"].ToString();
string subrptParaName = rptParameterName.Substring(1);
if (reportDetail.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString() == "TEXTBOX")
{
ASPxTextBox tb = (ASPxTextBox)ctrl;
if (!string.IsNullOrEmpty(tb.Text))
{
rptParameterValue = tb.Text;
commands.Add(rptParameterName);
values.Add(rptParameterValue);
}
}
if (reportDetail.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString() == "NUMERIC TEXTBOX")
{
ASPxTextBox dtp = (ASPxTextBox)ctrl;
if (!string.IsNullOrEmpty(dtp.Text.ToString()))
{
rptParameterValue = dtp.Text;
commands.Add(rptParameterName);
values.Add(rptParameterValue);
}
}
if (reportDetail.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString() == "DATETIME PICKER")
{
ASPxDateEdit dtp = (ASPxDateEdit)ctrl;
if (!string.IsNullOrEmpty(dtp.Text.ToString()))
{
string selectedDayInt = dtp.Date.Day.ToString();
if (selectedDayInt.Length == 1)
{
selectedDayInt = "0" + selectedDayInt;
}
string selectedMonthInt = dtp.Date.Month.ToString();
if (selectedMonthInt.Length == 1)
{
selectedMonthInt = "0" + selectedMonthInt;
}
rptParameterValue = dtp.Date.Year.ToString() + selectedMonthInt + selectedDayInt;
//rptParameterValue = dtp.Text;
commands.Add(rptParameterName);
values.Add(rptParameterValue);
}
}
if (reportDetail.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString() == "NUMERIC TEXTBOX WITH OPERATOR")
{
ASPxTextBox dtp = (ASPxTextBox)ctrl;
if (!string.IsNullOrEmpty(dtp.Text.ToString()))
{
rptParameterValue = dtp.Text;
commands.Add(rptParameterName);
values.Add(rptParameterValue);
}
}
if (reportDetail.Tables[0].Rows[i]["DISPLAY_TYPE"].ToString() == "DATETIME PICKER WITH OPERATOR")
{
ASPxDateEdit dtp = (ASPxDateEdit)ctrl;
if (!string.IsNullOrEmpty(dtp.Text.ToString()))
{
string selectedDayInt = dtp.Date.Day.ToString();
if (selectedDayInt.Length == 1)
{
selectedDayInt = "0" + selectedDayInt;
}
string selectedMonthInt = dtp.Date.Month.ToString();
if (selectedMonthInt.Length == 1)
{
selectedMonthInt = "0" + selectedMonthInt;
}
rptParameterValue = dtp.Date.Year.ToString() + selectedMonthInt + selectedDayInt;
//rptParameterValue = dtp.Text;
commands.Add(rptParameterName);
values.Add(rptParameterValue);
}
}
}
//ConfigureReports(values, commands);
Configure_Reports_Pdf(values, commands);
}
catch (Exception ex)
{
string error = ex.ToString();
}
}
private void ConfigureReports(ArrayList valuesLists, ArrayList parameterLists)
{
rptReportViewer.RefreshReport();
DataBaseHelper.myReportConnectionInfo = new ConnectionInfo();
DataBaseHelper.defineConnection = null;
DataSet connectionstring = DataBaseHelper.RunSQL("SELECT TOP 1 * FROM SV_MASTER_REPORT WHERE REPORT_ID=" + rdoReportName.SelectedValue.ToString());
DataBaseHelper.myReportConnectionInfo.UserID = connectionstring.Tables[0].Rows[0]["DB_USERID"].ToString();
DataBaseHelper.myReportConnectionInfo.Password = connectionstring.Tables[0].Rows[0]["DB_PASSWORD"].ToString();
DataBaseHelper.myReportConnectionInfo.ServerName = connectionstring.Tables[0].Rows[0]["DB_SERVERNAME"].ToString();
DataBaseHelper.myReportConnectionInfo.DatabaseName = connectionstring.Tables[0].Rows[0]["DB_NAME"].ToString();
reportDouc = new ReportDocument();
string reportPath = Server.MapPath(connectionstring.Tables[0].Rows[0]["REPORT_PATH"].ToString());
reportDouc.Load(reportPath);
reportDouc.FileName = reportPath;
for (int paracount = 0; valuesLists.Count > paracount; paracount++)
{
//reportDouc.SetParameterValue(parameterLists[paracount].ToString(), valuesLists[paracount]);
SetCurrentValuesForParameterField(reportDouc, valuesLists[paracount].ToString(), parameterLists[paracount].ToString());
}
DataBaseHelper.SetDBLogonReport(DataBaseHelper.myReportConnectionInfo, reportDouc);
rptReportViewer.ReportSource = reportDouc;
rptReportViewer.DataBind();
}
public void SetCurrentValuesForParameterField(ReportDocument reportDocument, string value, string strParameter)
{
ParameterValues currentParameterValues = new ParameterValues();
//foreach (object submittedValue in arrayList)
//{
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = value.ToString();
currentParameterValues.Add(parameterDiscreteValue);
//}
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[strParameter];
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
}
public void Configure_Reports_Pdf(ArrayList valueLists, ArrayList parameterLists)
{
//rptReportViewer.RefreshReport();
//DataBaseHelper.myReportConnectionInfo = new ConnectionInfo();
// reportDouc.EnterpriseSession.ServerNames. = connectionstring;
//reportDouc.SetParameterValue(0, TextBox1.Text);
//reportDouc.SetParameterValue(1, TextBox2.Text);
//for (int paracount = 0; valuesLists.Count > paracount; paracount++)
//{
// //reportDouc.SetParameterValue(parameterLists[paracount].ToString(), valuesLists[paracount]);
// SetCurrentValuesForParameterField(reportDouc, valuesLists[paracount].ToString(), parameterLists[paracount].ToString());
//}
//DataBaseHelper.SetDBLogonReport(DataBaseHelper.myReportConnectionInfo, reportDouc);
//rptReportViewer.ReportSource = reportDouc;
//rptReportViewer.DataBind();
////////////start from here\\\\\\\\\\\\\\\\\\\\\
DataBaseHelper.defineConnection = null;
DataSet connectionstring = DataBaseHelper.RunSQL("SELECT TOP 1 * FROM SV_MASTER_REPORT WHERE REPORT_ID=" + rdoReportName.SelectedValue.ToString());
// Put user code to initialize the page here
// 1. Load report file
String reportPath = Server.MapPath(connectionstring.Tables[0].Rows[0]["REPORT_PATH"].ToString());
theReport = new ReportDocument();
theReport.FileName = reportPath;
theReport.Load(reportPath);
//2. set logon info
CrystalDecisions.Shared.ConnectionInfo conn = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Table myTable;
CrystalDecisions.Shared.TableLogOnInfo myLog;
conn.ServerName = connectionstring.Tables[0].Rows[0]["DB_SERVERNAME"].ToString();
conn.DatabaseName = connectionstring.Tables[0].Rows[0]["DB_NAME"].ToString();
conn.UserID = connectionstring.Tables[0].Rows[0]["DB_USERID"].ToString();
conn.Password = connectionstring.Tables[0].Rows[0]["DB_PASSWORD"].ToString();
for (int i = 0; i < theReport.Database.Tables.Count; i++)
{
myTable = theReport.Database.Tables[i];
myLog = myTable.LogOnInfo;
myLog.ConnectionInfo = conn;
myTable.ApplyLogOnInfo(myLog);
myTable.Location = myLog.TableName;
}
// In case there are subreports in report file
for (int i = 0; i < theReport.ReportDefinition.ReportObjects.Count - 1; i++)
{
CrystalDecisions.CrystalReports.Engine.ReportObject rpt;
rpt = theReport.ReportDefinition.ReportObjects[i];
if (rpt.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
{
CrystalDecisions.CrystalReports.Engine.SubreportObject subrpt = (SubreportObject)rpt;
CrystalDecisions.CrystalReports.Engine.ReportDocument r = theReport.OpenSubreport(subrpt.SubreportName);
for (int j = 0; j < r.Database.Tables.Count - 1; j++)
{
myTable = r.Database.Tables[j];
myLog = myTable.LogOnInfo;
myTable.ApplyLogOnInfo(myLog);
myTable.Location = myLog.TableName;
}
}
}
// 3. process paramters received from URL and pass them to report file
String paramName, paramValue;
CrystalDecisions.Shared.ParameterValues pList = new ParameterValues();
CrystalDecisions.Shared.ParameterDiscreteValue pV = new ParameterDiscreteValue();
for (int i = 0; i < theReport.DataDefinition.ParameterFields.Count; i++)
{
paramName = parameterLists[i].ToString();
paramValue = valueLists[i].ToString();
pV.Value = paramValue;
pList.Add(pV);
theReport.DataDefinition.ParameterFields[paramName].ApplyCurrentValues(pList);
}
rptReportViewer.ReportSource = theReport;
rptReportViewer.DataBind();
// // 4. export report to PDF file and write back to client browser
// System.IO.MemoryStream m;
// m = (System.IO.MemoryStream)theReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
//// theReport.ExportToDisk(ExportFormatType.PortableDocFormat, theReport.FileName.ToString());
// theReport.Close();
// try
// {
// Session["rptPath"] = reportPath;
// DataBaseHelper.mstr = m;
// Response.Redirect("~/ReportViewer.aspx", false);
// //Server.Transfer("~/ReportViewer.aspx");
// //Server.Transfer("~/ReportViewer.aspx", false);
// // displaystring.Attributes.Add("src", "./ReportViewer.aspx");
// }
// catch(Exception ex)
// {
// ex.ToString();
// }
// //this.Response.ClearContent();
// //this.Response.ClearHeaders();
// //this.Response.AddHeader("Title", reportPath);
// //this.Response.ContentType = "Application/pdf";
// //this.Response.Buffer = true;
// //this.Response.BinaryWrite(m.ToArray());
// //this.Response.End();
}
private void ExportingReport()
{
ExportOptions ExpOptions = default(ExportOptions);
DiskFileDestinationOptions DiskFileDestOpts = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions FormatTypeOpts = new PdfRtfWordFormatOptions();
try
{
if (cboExport.SelectedItem.Text == "PORTABLE DOCUMENT FORMAT(.pdf)")
{
DiskFileDestOpts.DiskFileName = Server.MapPath("Test.pdf");
//DiskFileDestOpts.DiskFileName = "D:\\Temp\\Test.pdf";
ExpOptions = theReport.ExportOptions;
ExpOptions.ExportDestinationType = ExportDestinationType.DiskFile;
ExpOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
ExpOptions.DestinationOptions = DiskFileDestOpts;
ExpOptions.FormatOptions = FormatTypeOpts;
theReport.Export(ExpOptions);
}
else if (cboExport.SelectedItem.Text == "MICROSOFT WORD(.doc)")
{
DiskFileDestOpts.DiskFileName = Server.MapPath("Test.doc");
//DiskFileDestOpts.DiskFileName = "D:\\Temp\\Test.doc";
ExpOptions = theReport.ExportOptions;
ExpOptions.ExportDestinationType = ExportDestinationType.DiskFile;
ExpOptions.ExportFormatType = ExportFormatType.WordForWindows;
ExpOptions.DestinationOptions = DiskFileDestOpts;
ExpOptions.FormatOptions = FormatTypeOpts;
theReport.Export(ExpOptions);
}
else if (cboExport.SelectedItem.Text == "MICROSOFT EXECL(.xsl)")
{
DiskFileDestOpts.DiskFileName = Server.MapPath("Test.xsl");
//DiskFileDestOpts.DiskFileName = "D:\\Temp\\Test.xsl";
ExpOptions = theReport.ExportOptions;
ExpOptions.ExportDestinationType = ExportDestinationType.DiskFile;
ExpOptions.ExportFormatType = ExportFormatType.Excel;
ExpOptions.DestinationOptions = DiskFileDestOpts;
ExpOptions.FormatOptions = FormatTypeOpts;
theReport.Export(ExpOptions);
}
else if (cboExport.SelectedItem.Text == "RICH TEXT FORMAT(.rtf)")
{
DiskFileDestOpts.DiskFileName = Server.MapPath("Test.rtf");
//DiskFileDestOpts.DiskFileName = "D:\\Temp\\Test.rtf";
ExpOptions = theReport.ExportOptions;
ExpOptions.ExportDestinationType = ExportDestinationType.DiskFile;
ExpOptions.ExportFormatType = ExportFormatType.RichText;
ExpOptions.DestinationOptions = DiskFileDestOpts;
ExpOptions.FormatOptions = FormatTypeOpts;
theReport.Export(ExpOptions);
}
BindReportViewer();
}
catch (Exception Ex)
{
}
}
protected void butExport_Click(object sender, EventArgs e)
{
if (cboExport.SelectedItem.Text != "")
{
this.Response.Buffer = false;
//Clear the response content and headers
this.Response.ClearContent();
this.Response.ClearHeaders();
try
{
if (cboExport.SelectedItem.Text == "PORTABLE DOCUMENT FORMAT(.pdf)")
{
// Export the Report to Response stream in PDF format and file name Customers
theReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, this.Response, true, rdoReportName.SelectedItem.Text);
}
else if (cboExport.SelectedItem.Text == "MICROSOFT WORD(.doc)")
{
// Export the Report to Response stream in doc format and file name Customers
theReport.ExportToHttpResponse(ExportFormatType.WordForWindows, this.Response, true, rdoReportName.SelectedItem.Text);
}
else if (cboExport.SelectedItem.Text == "MICROSOFT EXECL(.xsl)")
{
// Export the Report to Response stream in excel format and file name Customers
theReport.ExportToHttpResponse(ExportFormatType.Excel, this.Response, true, rdoReportName.SelectedItem.Text);
}
else if (cboExport.SelectedItem.Text == "RICH TEXT FORMAT(.rtf)")
{
// Export the Report to Response stream in rich text format and file name Customers
theReport.ExportToHttpResponse(ExportFormatType.RichText, this.Response, true, rdoReportName.SelectedItem.Text);
}
}
catch
{
}
}
BindReportViewer();
}
protected void butPrint_Click(object sender, EventArgs e)
{
try
{
DataBaseHelper.defineConnection = null;
DataSet connectionstring = DataBaseHelper.RunSQL("SELECT TOP 1 * FROM SV_MASTER_REPORT WHERE REPORT_ID=" + rdoReportName.SelectedValue.ToString());
theReport.SetDatabaseLogon(connectionstring.Tables[0].Rows[0]["DB_USERID"].ToString(), connectionstring.Tables[0].Rows[0]["DB_PASSWORD"].ToString(), connectionstring.Tables[0].Rows[0]["DB_SERVERNAME"].ToString(), connectionstring.Tables[0].Rows[0]["DB_NAME"].ToString());
theReport.PrintToPrinter(1, false, 0, 0);
BindReportViewer();
}
catch (Exception ex)
{
}
}
protected void butMgr_Click(object sender, EventArgs e)
{
Response.Redirect("~/ConfigMgr.aspx");
}
protected void butvwRpt_Click(object sender, EventArgs e)
{
Response.Redirect("~/ReportPanel.aspx");
}
protected void butvwAdmin_Click(object sender, EventArgs e)
{
Response.Redirect("~/AdminMgr.aspx");
}
}
}