Exemple #1
0
 // GET: DashboardFilter/DashboardCompany
 public string DashboardCompany(DashboardFilter aInfo)
 {
     try
     {
         var userId = Session["UserId"].ToString();
         if (true)
         {
             _aDashboardMultiFilterHandler = new DashboardMultiFilterHandler();
             var data = _aDashboardMultiFilterHandler.GetMpCompanies(userId, aInfo);
             TempData["FilterData"] = data;
             return(JsonConvert.SerializeObject(data));
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemple #2
0
        public ActionResult GetExportToExcell(DashboardFilter aInfo)
        {
            try
            {
                DataTable data;
                if (TempData["FilterData"] == null)
                {
                    var userId = Session["UserId"].ToString();
                    data = _aDashboardMultiFilterHandler.GetMpCompanies(userId, aInfo);
                }
                else
                {
                    data = TempData["FilterData"] as DataTable;
                }

                var fileName = "MP_Filtered_Data_" + DateTime.Now.ToString("yyyy_dd_M_HH_mm_ss") + ".xls";
                var gv       = new GridView {
                    DataSource = data
                };
                gv.DataBind();
                Response.ClearContent();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
                Response.ContentType = "application/ms-excel";
                Response.Charset     = "";
                var sw  = new StringWriter();
                var htw = new HtmlTextWriter(sw);
                gv.RenderControl(htw);
                Response.Output.Write(sw.ToString());
                Response.Flush();
                Response.End();
                return(View("MpBudgetOnroll"));
            }
            catch (Exception ex)
            {
                throw new HttpException(404, "Not found");
            }
        }