Example #1
0
        public JsonResult LoadNominationDetailsForGrid(string dept = "", string fromDate = "", string toDate = "")
        {
            _repoResponse = new RepositoryResponse();
            if (dept == "--ALL--")
            {
                dept = "";
            }
            if (fromDate == "--Select--")
            {
                fromDate = "";
            }
            else if (!string.IsNullOrEmpty(fromDate))
            {
                string[] monthYear = fromDate.Split(' ');
                string   month     = monthYear[0].Substring(0, 3);
                string   year      = monthYear[1];
                fromDate = month + "-" + year;
            }

            if (toDate == "--Select--")
            {
                toDate = "";
            }
            else if (!string.IsNullOrEmpty(toDate))
            {
                string[] monthYear = toDate.Split(' ');
                string   month     = monthYear[0].Substring(0, 3);
                string   year      = monthYear[1];
                toDate = month + "-" + year;
            }

            _nominationRepo = new NominationRepo();
            string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString();

            _repoResponse = _nominationRepo.LoadNomination(_loggedInUserID, dept, fromDate, toDate);
            if (_repoResponse.success)
            {
                var _sa = new JsonSerializerSettings();
                return(Json(_repoResponse.Data));
            }
            else
            {
                return(Json(new { success = _repoResponse.success.ToString(), message = _repoResponse.message }));
            }
        }
Example #2
0
        public ActionResult NominationDataExport()
        {
            _repoResponse   = new RepositoryResponse();
            _nominationRepo = new NominationRepo();
            string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString();

            _repoResponse = _nominationRepo.LoadNomination(_loggedInUserID, "");
            if (_repoResponse.success)
            {
                DataSet ds    = Assistant.ToDataSet(_repoResponse.Data);
                string  path  = HostingEnvironment.MapPath("~/bin/Pdf/");
                string  fName = "SOM_NominationDetails_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";

                if (Assistant.DatasetToExcelExport(ds, path, fName, 5, "NominationDetails")) // 4th parameter is field Count
                {
                    byte[] fileBytes = System.IO.File.ReadAllBytes(path + "" + fName);

                    return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fName));
                }
            }
            return(Json(new { success = _repoResponse.success, message = _repoResponse.message }));
        }