private byte[] GenerateCustomerBillReportData(int month, int year, string format) { if (month == 0 || year == 0) return null; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Report/rpCustomerBill.rdlc"); ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "dsCustomerBill"; if (Session["LoggedUser"] == null || !(Session["LoggedUser"] is Customer)) return null; Customer customer = (Customer)Session["LoggedUser"]; var customerBill = new ReportDAL().GetCustomerBill(customer.ID, month, year); reportDataSource.Value = customerBill; localReport.DataSources.Add(reportDataSource); string period = string.Format("{0}/{1}", month, year); ReportParameter pCustomerName = new ReportParameter("CustomerName", string.Format("{0} {1}", customer.FirstName, customer.LastName)); ReportParameter pCustomerPhoneNo = new ReportParameter("CustomerPhoneNo", customer.PhoneNo); ReportParameter pCustomerAddress = new ReportParameter("CustomerAddress", string.Format("{0} , {1}, {2}", customer.StreetAddress, customer.ZipCode, customer.State)); ReportParameter pPeriod = new ReportParameter("Period", period); localReport.SetParameters(pCustomerName); localReport.SetParameters(pCustomerPhoneNo); localReport.SetParameters(pCustomerAddress); localReport.SetParameters(pPeriod); string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn2.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>jpeg</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return renderedBytes; }
private byte[] GenerateTrafficSummaryData(int month, int year, string format) { if (month == 0 || year == 0) return null; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Report/rpTrafficSummary.rdlc"); ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "dsTrafficSummary"; var trafficSummary = new ReportDAL().GetTrafficSummary(month, year); reportDataSource.Value = trafficSummary; localReport.DataSources.Add(reportDataSource); string period = string.Format("{0}/{1}", month, year); ReportParameter pPeriod = new ReportParameter("Period", period); localReport.SetParameters(pPeriod); string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn2.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>jpeg</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return renderedBytes; }
private byte[] GenerateRateData(long serviceID, long sourceCountryID, int month, int year, string format) { LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Report/rpRate.rdlc"); string period = string.Format("{0}/{1}", month, year); Service service = db.Services.Where(s => s.ID == serviceID).FirstOrDefault(); if (service == null) return null; Country country = db.Countries.Where(c => c.ID == sourceCountryID).FirstOrDefault(); if (country == null) return null; ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "dsRate"; var rate = new ReportDAL().GetRate(service.Name, sourceCountryID, month, year); reportDataSource.Value = rate; localReport.DataSources.Add(reportDataSource); ReportParameter pPeriod = new ReportParameter("Period", period); localReport.SetParameters(pPeriod); ReportParameter pServiceName = new ReportParameter("ServiceName", service.Name); localReport.SetParameters(pServiceName); ReportParameter pSourceCountryName = new ReportParameter("SourceCountryName", country.Name); localReport.SetParameters(pSourceCountryName); string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn2.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>jpeg</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return renderedBytes; }
private byte[] GenerateSalesRepCommissionData(int month, int year, string format) { if (month == 0 || year == 0) return null; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Report/rpSalesRepCommission.rdlc"); if (Session["LoggedUser"] == null || !(Session["LoggedUser"] is SalesRep)) return null; SalesRep salesRep = (SalesRep)Session["LoggedUser"]; var salesRepCommission = new ReportDAL().GetSalesRepCommission(salesRep.ID, month, year); string period = string.Format("{0}/{1}", month, year); ReportParameter pSalesRepName = new ReportParameter("SalesRepName", string.Format("{0} {1}", salesRep.FirstName, salesRep.LastName)); ReportParameter pSalesRepCommission = new ReportParameter("SalesRepCommission", String.Format("{0:0.00}", salesRepCommission)); ReportParameter pPeriod = new ReportParameter("Period", period); localReport.SetParameters(pSalesRepName); localReport.SetParameters(pSalesRepCommission); localReport.SetParameters(pPeriod); string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn2.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>jpeg</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return renderedBytes; }