示例#1
0
 public ActionResult RdlcReportCategoryWiseItemSales(string companyId, string branchId, string supplierId, string dateFrom, string dateTo)
 {
     try
     {
         if (branchId == "null")
         {
             branchId = "";
         }
         if (supplierId == "null")
         {
             supplierId = "";
         }
         if (dateFrom == "null")
         {
             dateFrom = "";
         }
         if (dateTo == "null")
         {
             dateTo = "";
         }
         if (!string.IsNullOrEmpty(dateFrom))
         {
             DateTime?dfrom = Convert.ToDateTime(dateFrom);
             dfrom    = new DateTime(dfrom.Value.Year, dfrom.Value.Month, dfrom.Value.Day, 0, 0, 0);
             dateFrom = dfrom.Value.ToString(CultureInfo.InvariantCulture);
         }
         if (!string.IsNullOrEmpty(dateTo))
         {
             DateTime?dto = Convert.ToDateTime(dateTo);
             dto    = new DateTime(dto.Value.Year, dto.Value.Month, dto.Value.Day, 23, 59, 59);
             dateTo = dto.Value.ToString(CultureInfo.InvariantCulture);
         }
         IEnumerable <SaleVm> sales = new List <SaleVm>();
         if (!string.IsNullOrEmpty(companyId))
         {
             sales = _rawSqlService.GetCategoryWiseItemSales(companyId, branchId, supplierId, dateFrom, dateTo);
         }
         ReportDataSource rpt = new ReportDataSource("Sale", sales);
         RdlcReportViewerWithDate.reportDataSource = rpt;
         string rPath = "RdlcReport/RptCategoryWiseItemSales.rdlc";
         Response.Redirect("~/ReportViewer/RdlcReportViewerWithDate.aspx?rPath=" + rPath + "&dfrom=" + dateFrom + "&dto=" + dateTo + "&companyId=" + companyId + "&branchId=" + branchId);
         return(View());
     }
     catch (Exception ex)
     {
         return(JavaScript($"ShowResult('{ex.Message}','failure')"));
     }
 }