Beispiel #1
0
        public JsonResult GetBillGenerateList(string month, int year)
        {
            try
            {
                List <BillGenerateVM> _objList = _internetBillGenerateDA.GetBillList(month, year).OrderByDescending(x => x.billDetailId).ToList();
                int    totalRows      = _objList.Count;
                int    start          = Convert.ToInt32(Request["start"]);
                int    length         = Convert.ToInt32(Request["length"]);
                string searchValue    = Request["search[value]"];
                string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
                string sortDirection  = Request["order[0][dir]"];

                if (!string.IsNullOrEmpty(searchValue))
                {
                    _objList = _objList.Where(x => x.customerSerial.ToLower().Contains(searchValue.ToLower()) ||
                                              x.month.ToLower().Contains(searchValue.ToLower()) ||
                                              x.yearName.ToLower().Contains(searchValue.ToLower())).ToList();
                }
                //_objList = _objList.OrderBy(sortColumnName + " " + sortDirection).ToList<CustomerVM>();
                _objList = _objList.Skip(start).Take(length).ToList();

                return(Json(new { success = true, data = _objList, draw = Request["draw"], recordsTotal = totalRows, recordsFiltered = totalRows }, JsonRequestBehavior.AllowGet));
                //return Json(new { success = true, data = _objList }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public ActionResult ShowReport(string fileType, string reportType, int?cid, int?receivedBy, int?collectedBy, bool?isActive, int?zoneId, string fromDate = "", string toDate = "", string ctype = "", string month = "", int year = 0, int pageNo = 0)
        {
            LocalReport lr = new LocalReport();

            if (reportType == "AllDishCustomerDetails")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "AllDishCustomerDetails.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("isActive", isActive == null ? null : isActive.ToString()));
                reportParameters.Add(new ReportParameter("zoneId", zoneId + ""));
                lr.SetParameters(reportParameters);
                var dataList = _da.GetDishCustomerList(isActive, zoneId ?? 0, 0) ?? new List <CustomerVM>();
                rd = new ReportDataSource("CustomerDataSet", dataList);
                lr.DataSources.Add(rd);
            }
            else if (reportType == "AllInternetCustomerDetails")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "AllInternetCustomerDetails.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("isActive", isActive == null ? null : isActive.ToString()));
                reportParameters.Add(new ReportParameter("zoneId", zoneId + ""));
                lr.SetParameters(reportParameters);
                var dataList = _da.GetInternetCustomerList(isActive, zoneId ?? 0, 0) ?? new List <CustomerVM>();
                rd = new ReportDataSource("CustomerDataSet", dataList);
                lr.DataSources.Add(rd);
            }
            else if (reportType == "DishBillDetails")
            {
                DateTime rptFromDate = DateTime.ParseExact(fromDate, "dd/MM/yyyy", null);
                DateTime rptToDate   = DateTime.ParseExact(toDate, "dd/MM/yyyy", null);
                string   path        = System.IO.Path.Combine(Server.MapPath("~/Reports"), ctype == "0" ? "AllDishBillDetails.rdlc" : "AllDishBillDetailsByType.rdlc");
                lr.ReportPath = path;


                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("fromDate", rptFromDate.ToString()));
                reportParameters.Add(new ReportParameter("toDate", rptToDate.ToString()));
                reportParameters.Add(new ReportParameter("cid", cid.ToString()));
                reportParameters.Add(new ReportParameter("receivedBy", receivedBy.ToString()));
                reportParameters.Add(new ReportParameter("collectedBy", collectedBy.ToString()));
                if (ctype != "0")
                {
                    reportParameters.Add(new ReportParameter("ctype", ctype));
                }
                lr.SetParameters(reportParameters);
                if (ctype == "0")
                {
                    var dataList         = _da.GetDishBillCollections(rptFromDate, rptToDate, cid ?? 0, receivedBy ?? 0, collectedBy ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();
                    ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                    lr.DataSources.Add(rds);
                }
                else
                {
                    var dataList         = _da.GetDishBillCollectionByType(rptFromDate, rptToDate, cid ?? 0, receivedBy ?? 0, collectedBy ?? 0, ctype) ?? new List <PCOHRApp.Models.BillCollectionVM>();
                    ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                    lr.DataSources.Add(rds);
                }
            }
            else if (reportType == "InternetBillDetails")
            {
                DateTime rptFromDate = DateTime.ParseExact(fromDate, "dd/MM/yyyy", null);
                DateTime rptToDate   = DateTime.ParseExact(toDate, "dd/MM/yyyy", null);
                string   path        = System.IO.Path.Combine(Server.MapPath("~/Reports"), ctype == "0" ? "AllInternetBillDetails.rdlc" : "AllInternetBillDetailsByType.rdlc");
                lr.ReportPath = path;


                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("fromDate", rptFromDate.ToString()));
                reportParameters.Add(new ReportParameter("toDate", rptToDate.ToString()));
                reportParameters.Add(new ReportParameter("cid", cid.ToString()));
                reportParameters.Add(new ReportParameter("receivedBy", receivedBy.ToString()));
                reportParameters.Add(new ReportParameter("collectedBy", collectedBy.ToString()));
                if (ctype != "0")
                {
                    reportParameters.Add(new ReportParameter("ctype", ctype));
                }
                lr.SetParameters(reportParameters);
                if (ctype == "0")
                {
                    var dataList         = _da.GetInternetBillCollections(rptFromDate, rptToDate, cid ?? 0, receivedBy ?? 0, collectedBy ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();
                    ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                    lr.DataSources.Add(rds);
                }
                else
                {
                    var dataList         = _da.GetInternetBillCollectionByType(rptFromDate, rptToDate, cid ?? 0, receivedBy ?? 0, collectedBy ?? 0, ctype) ?? new List <PCOHRApp.Models.BillCollectionVM>();
                    ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                    lr.DataSources.Add(rds);
                }
            }
            else if (reportType == "DishBillDue")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "DishCustomerDue.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("zoneId", zoneId + ""));

                lr.SetParameters(reportParameters);
                var dataList = _da.GetDishCustomerDue(zoneId ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();

                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
                lr.Refresh();
            }
            else if (reportType == "InternetBillDue")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "InternetCustomerDue.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("zoneId", zoneId + ""));

                lr.SetParameters(reportParameters);
                var dataList = _da.GetInternetCustomerDue(zoneId ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();

                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
                lr.Refresh();
            }
            else if (reportType == "DishPaymentHistory")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "DishPaymentHistory.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("cid", cid + ""));

                lr.SetParameters(reportParameters);
                var dataList = _da.GetDishPaymentHistory(cid ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();

                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "InternetPaymentHistory")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "InternetPaymentHistory.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("cid", cid + ""));

                lr.SetParameters(reportParameters);
                var dataList = _da.GetInternetPaymentHistory(cid ?? 0) ?? new List <PCOHRApp.Models.BillCollectionVM>();

                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "HostList")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "HostList.rdlc");
                lr.ReportPath = path;
                var dataList = _hostDa.GetHostList() ?? new List <HostVM>();
                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("HostDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "MonthWiseDishBillGenerate")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "MonthWiseDishBillGenerate.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("month", month));
                reportParameters.Add(new ReportParameter("year", year + ""));
                lr.SetParameters(reportParameters);
                var dataList = _dishBillGenerateDA.GetBillList(month, year) ?? new List <BillGenerateVM>();
                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("BillDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "MonthWiseInternetBillGenerate")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "MonthWiseInternetBillGenerate.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                reportParameters.Add(new ReportParameter("month", month));
                reportParameters.Add(new ReportParameter("year", year + ""));
                lr.SetParameters(reportParameters);
                var dataList = _internetBillGenerateDA.GetBillList(month, year) ?? new List <BillGenerateVM>();
                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("BillDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "DishBillCollectionPageWise")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "DishBillDetails.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                lr.SetParameters(reportParameters);
                var dataList = _da.GetDishCollectionPageWise(year, pageNo, receivedBy ?? 0) ?? new List <BillCollectionVM>();
                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
            }
            else if (reportType == "InternetBillCollectionPageWise")
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Reports"), "InternetBillDetails.rdlc");
                lr.ReportPath = path;
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                lr.SetParameters(reportParameters);
                var dataList = _da.GetInternetCollectionPageWise(year, pageNo, receivedBy ?? 0) ?? new List <BillCollectionVM>();
                lr.DataSources.Clear();
                ReportDataSource rds = new ReportDataSource("CollectionDataSet", dataList);
                lr.DataSources.Add(rds);
            }

            string rptType = fileType;
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo =

                "<DeviceInfo>" +
                "  <OutputFormat>" + fileType + "</OutputFormat>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            renderedBytes = lr.Render(
                rptType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            return(File(renderedBytes, mimeType));
        }