why we declare "ReportDocument doc;" in this coding?what it is doing here?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murthychvrm
    New Member
    • Apr 2008
    • 3

    why we declare "ReportDocument doc;" in this coding?what it is doing here?

    why we declare "ReportDocu ment doc;" in this coding?what it is doing here?

    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Dal_ricepack;
    using System.Text;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Web;
    using System.Data.SqlClient;
    
    public partial class CRYSTALREPORTS_CRSalesrpt : System.Web.UI.Page
    {
    ReportDocument doc;
    
    protected void Page_Load(object sender, EventArgs e)
    {
    doc = new ReportDocument();
    if (Session["user"] != null)
    {
    //doc = new ReportDocument();
    if (Page.IsPostBack == false)
    {
    txtValidFrom.Attributes.Add("onfocus", "showCalendarControl(this);");
    txtValidTo.Attributes.Add("onfocus", "showCalendarControl(this);");
    clsagent iss = new clsagent();
    
    string type = Session["user_type"].ToString();
    DataTable dt1 = iss.selectagentdetails(type);
    ddlAgenCode.DataSource = dt1;
    
    ddlAgenCode.DataTextField = dt1.Columns["Agent_Name"].ToString();
    ddlAgenCode.DataValueField = dt1.Columns["Agent_Code"].ToString();
    
    //ddlStatus.DataValueField = dt1.Columns["IssuesorReturns"].ToString();
    //ddlStatus.DataBind();
    ddlAgenCode.DataBind();
    ddlAgenCode.Items.Insert(0, new ListItem("select AgentName", ""));
    }
    else
    {
    doc = new ReportDocument();
    doc.Load(Server.MapPath("~/CRsales.rpt"));
    CRClasses issu = new CRClasses();
    string i = ddlAgenCode.SelectedItem.Value;
    //string j = ddltogodown.SelectedItem.Value;
    string type = Session["user_type"].ToString();
    DataTable dt = issu.selectsalesrpt(txtValidFrom.Text, txtValidTo.Text, i,type);
    doc.SetDataSource(dt);
    doc.SetParameterValue("@fromdate", txtValidFrom.Text);
    doc.SetParameterValue("@todate", txtValidTo.Text);
    doc.SetParameterValue("@agentcode", ddlAgenCode.SelectedItem.Value);
    string s = Session["User"].ToString();
    doc.SetParameterValue("@username", s);
    CrystalReportViewer1.ReportSource = doc;
    CrystalReportViewer1.DataBind();
    }
    }
    else
    {
    Response.Redirect("~/loginpage.aspx");
    }
    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    doc = new ReportDocument();
    doc.Load(Server.MapPath("~/CRsales.rpt"));
    CRClasses issu = new CRClasses();
    string i = ddlAgenCode.SelectedItem.Value;
    //string j = ddltogodown.SelectedItem.Value;
    string type = Session["user_type"].ToString();
    DataTable dt = issu.selectsalesrpt(txtValidFrom.Text, txtValidTo.Text, i, type);
    doc.SetDataSource(dt);
    doc.SetParameterValue("@fromdate", txtValidFrom.Text);
    doc.SetParameterValue("@todate", txtValidTo.Text);
    doc.SetParameterValue("@agentcode", ddlAgenCode.SelectedItem.Value);
    string s = Session["User"].ToString();
    doc.SetParameterValue("@username", s);
    CrystalReportViewer1.ReportSource = doc;
    CrystalReportViewer1.DataBind();
    
    }
    
    protected void CrystalReportViewer1_Init(object sender, EventArgs e)
    {
    
    }
    protected void Page_UnLoad(object sender, EventArgs e)
    {
    doc.Close();
    doc.Dispose();
    GC.Collect();
    
    }
    protected void Page_PreInit(object sender, EventArgs e)
    {
    string i = (Session["user_type"].ToString());
    if (i == "private")
    {
    this.MasterPageFile = "Ricemaster.master";
    
    }
    else
    {
    this.MasterPageFile = "MasterPage.master";
    }
    }
    
    }
    Last edited by DrBunchman; Oct 16 '08, 10:47 AM. Reason: Added [Code] Tags - Please use the '#' button
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Where did you get the code from? Did they not give you a manual together with that code?

    Comment

    Working...