protected void rptViewer_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connString"].ToString()); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "uspRptDetailByOrigin"; cmd.CommandType = CommandType.StoredProcedure; if (Session["profilename"].ToString() == "Client") { cmd.Parameters.Add(new SqlParameter("@ClientId", Session["ClientId"].ToString())); } else { cmd.Parameters.Add(new SqlParameter("@ClientId", this.lstClient.SelectedValue.ToString())); } Microsoft.Reporting.WebForms.ReportParameterInfoCollection DrillThroughValues = e.Report.GetParameters(); cmd.Parameters.Add(new SqlParameter("@Src", DrillThroughValues[0].Values[0])); SqlDataReader dr = cmd.ExecuteReader(); dsInvoiceDetail ds = new dsInvoiceDetail(); while (dr.Read()) { ds.Tables[0].Rows.Add(dr[0].ToString(), System.Convert.ToDateTime(dr[1].ToString()), dr[2].ToString(), dr[3].ToString(), System.Convert.ToInt32(dr[4].ToString()), System.Convert.ToDouble(dr[5].ToString())); } dr.Close(); conn.Close(); conn.Dispose(); this.rptViewer.LocalReport.DataSources.Clear(); this.rptViewer.Reset(); LocalReport drillThroughReport = (LocalReport)e.Report; Microsoft.Reporting.WebForms.ReportDataSource rdInvDetail = new Microsoft.Reporting.WebForms.ReportDataSource("dsInvoiceDetailwhatever", ds.Tables[0]); drillThroughReport.DataSources.Add(rdInvDetail); this.rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; this.rptViewer.LocalReport.ReportPath = @"Reports\StatementDetailBySrc.rdlc"; Microsoft.Reporting.WebForms.ReportParameter Origin = new Microsoft.Reporting.WebForms.ReportParameter("Origin", DrillThroughValues[0].Values[0]); this.rptViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { Origin }); this.rptViewer.LocalReport.Refresh(); }
protected void RunInternational() { SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connString"].ToString()); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "uspRptInternational"; cmd.CommandType = CommandType.StoredProcedure; if (Session["profilename"].ToString() == "Client") { cmd.Parameters.Add(new SqlParameter("@ClientId", Session["ClientId"].ToString())); } else { cmd.Parameters.Add(new SqlParameter("@ClientId", this.lstClient.SelectedValue.ToString())); } cmd.Parameters.Add(new SqlParameter("@StartDate", this.txtStartDate.Text)); cmd.Parameters.Add(new SqlParameter("@EndDate", this.txtEndDate.Text)); SqlDataReader dr = cmd.ExecuteReader(); dsInvoiceDetail dsDetail = new dsInvoiceDetail(); while (dr.Read()) { dsDetail.Tables[0].Rows.Add(dr[0].ToString(), System.Convert.ToDateTime(dr[1].ToString()), dr[2].ToString(), dr[3].ToString(), System.Convert.ToInt32(dr[4].ToString()), System.Convert.ToDouble(dr[5].ToString())); } dr.Close(); this.rptViewer.LocalReport.DataSources.Clear(); this.rptViewer.Reset(); Microsoft.Reporting.WebForms.ReportDataSource rdInvDetail = new Microsoft.Reporting.WebForms.ReportDataSource("dsInvoiceDetail", dsDetail.Tables[0]); this.rptViewer.LocalReport.DataSources.Add(rdInvDetail); this.rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; this.rptViewer.LocalReport.ReportPath = @"Reports\International.rdlc"; // Get the date range to show on the report var startDate = (from dta in dsDetail.Tables[0].AsEnumerable() orderby dta.Field <DateTime>("CallDate") ascending select(dta.Field <DateTime>("CallDate"))).FirstOrDefault(); var endDate = (from dta in dsDetail.Tables[0].AsEnumerable() orderby dta.Field <DateTime>("CallDate") ascending select(dta.Field <DateTime>("CallDate"))).LastOrDefault(); // Configure report params Microsoft.Reporting.WebForms.ReportParameter ClientDescription = null; if (Session["profilename"].ToString() == "Client") { ClientDescription = new Microsoft.Reporting.WebForms.ReportParameter("ClientDescription", Session["ClientDesc"].ToString()); } else { ClientDescription = new Microsoft.Reporting.WebForms.ReportParameter("ClientDescription", this.lstClient.SelectedItem.ToString()); } Microsoft.Reporting.WebForms.ReportParameter ReportDescription = new Microsoft.Reporting.WebForms.ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To : " + endDate); this.rptViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { ClientDescription, ReportDescription }); this.rptViewer.LocalReport.Refresh(); }