inforakesha

A fine WordPress.com site

Report RDLC

Leave a comment

 protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            LoadReport();
        }
 
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            LoadReport();
        }
        public void LoadReport()
        {
 
            ReportViewer1.Visible = true;
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            LocalReport localreport = ReportViewer1.LocalReport;
            localreport.DataSources.Clear();
 
            DataSet ds = new DataSet();
            ds = FillDataset();
            localreport.DataSources.Clear();
            localreport.DataSources.Add(new ReportDataSource() { Name = "ds_Invoice", Value = ds.Tables[0] });
 
            StringBuilder header = new StringBuilder();
            header.AppendFormat("{0}", "AR Report for " + ddlCountry.SelectedItem.Text.ToString() + " Year");
            //string sHeader = "Collection Report";
 
 
            if (ddlCountry.SelectedIndex > 0)
            {
                header.AppendFormat("{0}", " from " + ddlCountry.SelectedItem.Text.ToString());
 
            }
            if (ddlCountry.SelectedIndex > 0 && ddlCity.SelectedIndex == 0)
            {
                header.AppendFormat("{0}", " for " + ddlCountry.SelectedItem.Text.ToString());
 
            }
            else if (ddlCity.SelectedIndex == 0 && ddlCountry.SelectedIndex == 0)
            {
                header.AppendFormat("{0}", " and all Conutry all City");
 
            }
 
            else
            {
                header.AppendFormat("{0}", " for " + ddlCountry.SelectedItem.Text.ToString());
 
            }
            ReportParameter[] prm = new ReportParameter[1];
 
            prm[0] = new ReportParameter("ReportParameter1", header.ToString(), false);
           localreport.SetParameters(prm);
            localreport.Refresh();
        }
 
        /// <summary>
        /// Fills the dataset.
        /// </summary>
        /// <returns>DataSet.</returns>
        public DataSet FillDataset()
        {
            DataSet ds = new DataSet();
          
                //Database db = DatabaseFactory.CreateDatabase(sConn);
 
                // Establish Select command
 
                SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString());
                SqlCommand cmd = new SqlCommand("dbo.RP_Northwind",con);
                cmd.CommandType = CommandType.StoredProcedure;
 
 
 
                if (ddlCountry.SelectedValue.ToString()!="0")
              cmd.Parameters.AddWithValue("@Country", ddlCountry.SelectedValue.ToString());
                if(ddlCity.SelectedValue.ToString()!="0")
                cmd.Parameters.AddWithValue("@City",ddlCity.SelectedValue.ToString());
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                //Gv1.DataSource=ds.Tables[0];
                //Gv1.DataBind();
                Gv1.Visible = false;
           
             
         
            return ds;
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s