protected void btnReport_Click(object sender, EventArgs e) { ISearchCriteria iSearchCriteria = new SearchCriteria(); iSearchCriteria.StringParams = new List <string>() { ddlBlNo.SelectedValue }; // iSearchCriteria = null; var temp = ExpBLPrintingBLL.GetxpBLPrinting(iSearchCriteria); Model = temp == null?(List <BLPrintModel>)null:new List <BLPrintModel>() { temp }; }
protected void btnReport_Click(object sender, EventArgs e) { DownLoadPDF(); return; ISearchCriteria iSearchCriteria = new SearchCriteria(); iSearchCriteria.StringParams = new List <string>() { ddlBlNo.SelectedValue //"MUM/UA/13-14/000001" }; /*Report Viewer PDF on aspx*/ // iSearchCriteria = null; // var temp = ExpBLPrintingBLL.GetxpBLPrinting(iSearchCriteria); // Model = temp==null?(List<BLPrintModel>)null:new List<BLPrintModel>() {temp }; var temp = ExpBLPrintingBLL.GetxpBLPrintingDS(iSearchCriteria); DataSet dsBLPrinting = new DataSet(); DataTable dtBLPrintingCons = null; DataTable dtBLPrintingCons5 = null; //int i = 0; if (temp != null && temp.Tables.Count > 0) { //fillFakData(temp.Tables[1]); var top5 = temp.Tables[1].AsEnumerable().Take(5); var Next5 = temp.Tables[1].AsEnumerable().Skip(5); dtBLPrintingCons = temp.Tables[1].Clone(); dtBLPrintingCons5 = temp.Tables[1].Clone(); //foreach (DataRow dr in top5){ // dtBLPrintingCons5.ImportRow(dr); //} //foreach (DataRow dr in Next5){ // dtBLPrintingCons.ImportRow(dr); //} string rptName; LocalReportManager reportManager = new LocalReportManager(rptViewer, "BLPrint", ConfigurationManager.AppSettings["ReportNamespace"].ToString(), ConfigurationManager.AppSettings["ReportPath"].ToString()); if (ddlLine.SelectedValue == "ABF") { rptName = "BLPrintFwdABF.rdlc"; } else if (ddlLine.SelectedValue == "BLP") { rptName = "BLPrintFwdBLPL.rdlc"; } else { rptName = "BLPrintFwdSim.rdlc"; } rptViewer.Reset(); rptViewer.LocalReport.Dispose(); rptViewer.LocalReport.DataSources.Clear(); rptViewer.LocalReport.ReportPath = this.Server.MapPath(this.Request.ApplicationPath) + ConfigurationManager.AppSettings["ReportPath"].ToString() + "/" + rptName; rptViewer.LocalReport.DataSources.Add(new ReportDataSource("DSFWDBLPrinting", temp.Tables[0])); rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsBLPrintingContainerTopFive", dtBLPrintingCons5)); rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsBLPrintingContainer", dtBLPrintingCons)); rptViewer.LocalReport.SetParameters(new ReportParameter("ImageShow", "false")); rptViewer.LocalReport.Refresh(); } }
public void DownLoadPDF() { ISearchCriteria iSearchCriteria = new SearchCriteria(); iSearchCriteria.StringParams = new List <string>() { ddlBlNo.SelectedValue //"MUM/UA/13-14/000001" }; string Original = "O"; //if (ExpBLPrintingBLL.CheckDraftOrOriginal(ddlBlNo.SelectedValue)) // Original = "O"; var temp = ExpBLPrintingBLL.GetfwdBLPrintingDS(iSearchCriteria); DataSet dsBLPrinting = new DataSet(); DataTable dtBLPrintingCons = null; DataTable dtBLPrintingCons5 = null; DataTable dtBLPrintingDesc = null; int i = 0; if (temp != null && temp.Tables.Count > 0) { //fillFakData(temp.Tables[1]); var top5 = temp.Tables[1].AsEnumerable().Take(100); var Next5 = temp.Tables[1].AsEnumerable().Skip(100); dtBLPrintingCons = temp.Tables[1].Clone(); dtBLPrintingCons5 = temp.Tables[1].Clone(); dtBLPrintingDesc = temp.Tables[2]; foreach (DataRow dr in top5) { dtBLPrintingCons5.ImportRow(dr); } foreach (DataRow dr in Next5) { dtBLPrintingCons.ImportRow(dr); } var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); viewer.ProcessingMode = ProcessingMode.Local; if (ddlLine.SelectedItem.Text == "ABF") { viewer.LocalReport.ReportPath = this.Server.MapPath(this.Request.ApplicationPath) + ConfigurationManager.AppSettings["ReportPath"].ToString() + "/" + "BLPrintFwdABF.rdlc"; } else if (ddlLine.SelectedItem.Text == "BLP") { viewer.LocalReport.ReportPath = this.Server.MapPath(this.Request.ApplicationPath) + ConfigurationManager.AppSettings["ReportPath"].ToString() + "/" + "BLPrintFwdBLPL.rdlc"; } else { viewer.LocalReport.ReportPath = this.Server.MapPath(this.Request.ApplicationPath) + ConfigurationManager.AppSettings["ReportPath"].ToString() + "/" + "BLPrintFwdSim.rdlc"; } viewer.LocalReport.DataSources.Add(new ReportDataSource("DSFWDBLPrinting", temp.Tables[0])); viewer.LocalReport.DataSources.Add(new ReportDataSource("dsBLPrintingContainerTopFive", dtBLPrintingCons5)); viewer.LocalReport.DataSources.Add(new ReportDataSource("dsBLPrintingContainer", dtBLPrintingCons)); viewer.LocalReport.DataSources.Add(new ReportDataSource("dsBLPrintDesc", dtBLPrintingDesc)); viewer.LocalReport.SetParameters(new ReportParameter("ReportType", Original)); Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=ExpBL" + ddlBlNo.Text + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download } }