public ActionResult DashBoard(CustomReports obj, FormCollection form, string Column)
        {
            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
            List <DSRCManagementSystem.Models.CustomReports> value       = new List <DSRCManagementSystem.Models.CustomReports>();
            List <DSRCManagementSystem.Models.CustomReports> Report      = new List <DSRCManagementSystem.Models.CustomReports>();
            List <DSRCManagementSystem.Models.CustomReports> ExportValue = new List <DSRCManagementSystem.Models.CustomReports>();

            TempData["Column"] = Column;
            ViewBag.Column     = Column;
            int roleid = Convert.ToInt32(Session["RoleID"]);

            try
            {
                if (Column == null)
                {
                    string CusReportId = (form["Id3"] == "") ? "0" : form["Id3"].ToString();
                    int    cusId       = Convert.ToInt32(CusReportId);
                    var    Id          =
                        objdb.CustomReports.Where(x => x.ReportID == cusId && x.IsActive == true)
                        .Select(o => o.ReportQuery)
                        .FirstOrDefault();
                    string ZoneId = Id;
                    var    temp   = objdb.CustomReports.Where(r => r.ReportQuery == Id).Select(f => f.ReportName).ToList();
                    foreach (var list in temp)
                    {
                        ViewBag.ReportName = list;
                    }


                    if (CusReportId == Convert.ToString(0))
                    {
                        var Purpose = (from cr in objdb.CustomReports
                                       join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID
                                       where (cru.RoleID == roleid && cr.IsActive == true)
                                       select new
                        {
                            ReportID = cr.ReportID,
                            ReportName = cr.ReportName
                        }).ToList();
                        ViewBag.Purpose = new SelectList(Purpose, "ReportID", "ReportName", 0);
                        ModelState.AddModelError("RoleName", "Select Report Name");
                    }
                    TempData["cusId"]    = cusId;
                    TempData["ReportID"] = ZoneId;

                    if (CusReportId != Convert.ToString(0))
                    {
                        List <string> Parameter = new List <string>();
                        List <string> value1    = objdb.SP_GetName(Id).ToList();
                        foreach (var s in value1)
                        {
                            DSRCManagementSystem.Models.CustomReports ob =
                                new DSRCManagementSystem.Models.CustomReports();
                            var trims    = s.TrimStart('@');
                            var newValue = trims.Substring(trims.IndexOf('_') + 1);
                            var trim     = Regex.Replace(newValue, "([a-z])([A-Z])", "$1 $2");
                            ob.CustomName = trim;
                            value.Add(ob);
                            Parameter.Add(ob.CustomName);
                        }
                        ViewData["Parameter"] = Parameter;
                        ViewBag.Id            = value;
                        string id1 = Id;

                        if (value.Count() == 0)
                        {
                            var pose = (from cr in objdb.CustomReports
                                        join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID
                                        where (cru.RoleID == roleid && cr.IsActive == true)
                                        select new
                            {
                                ReportID = cr.ReportID,
                                ReportName = cr.ReportName
                            }).ToList();
                            ViewBag.Purpose = new SelectList(pose, "ReportID", "ReportName", cusId);
                            string        constr = ConfigurationManager.AppSettings["connstr"];
                            DataSet       ds     = new DataSet();
                            SqlConnection objcon = new SqlConnection(constr);
                            SqlCommand    cmd    = new SqlCommand(id1, objcon);
                            cmd.CommandText = id1;
                            cmd.CommandType = CommandType.StoredProcedure;
                            SqlDataAdapter adap = new SqlDataAdapter(cmd);
                            adap.Fill(ds);
                            List <object> chartData = new List <object>();
                            List <DSRCManagementSystem.Models.CustomReports> value5 =
                                new List <DSRCManagementSystem.Models.CustomReports>();
                            List <object> Listvalue = new List <object>();
                            List <object> Val       = new List <object>();
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                DSRCManagementSystem.Models.CustomReports ob =
                                    new DSRCManagementSystem.Models.CustomReports();
                                Array x = dr.ItemArray;
                                ob.ReportName1 = x;
                                Listvalue.Add(ob.ReportName1);
                                chartData.Add(new object[]
                                {
                                    dr[0]
                                });
                                ExportValue.Add(ob);
                            }
                            foreach (DataColumn dr in ds.Tables[0].Columns)
                            {
                                DSRCManagementSystem.Models.CustomReports ob1 =
                                    new DSRCManagementSystem.Models.CustomReports();
                                ob1.CustomNameId = dr.ColumnName;
                                Val.Add(ob1.CustomNameId);
                            }
                            ViewBag.Val       = Val;
                            ViewBag.ListValue = Listvalue;
                            ViewBag.data      = chartData;
                            return(View(ExportValue));
                        }
                        var Purpose = (from cr in objdb.CustomReports
                                       join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID
                                       where (cru.RoleID == roleid && cr.IsActive == true)
                                       select new
                        {
                            ReportID = cr.ReportID,
                            ReportName = cr.ReportName
                        }).ToList();
                        foreach (var item in value)
                        {
                            ViewBag.Purpose = new SelectList(Purpose, "ReportID", "ReportName", cusId);
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                //string actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                //string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                //ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
                //return Json("Warning", JsonRequestBehavior.AllowGet);
                ModelState.AddModelError("RoleName", "Stored Procedure Was Not Supported ");
            }

            try
            {
                if (Column != null)
                {
                    string        Id     = Convert.ToString(TempData["ReportID"]);
                    List <string> value1 = objdb.SP_GetName(Id).ToList();
                    foreach (var s in value1)
                    {
                        DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports();
                        ob.CustomName = s;
                        value.Add(ob);
                    }
                    ViewBag.Id = value;
                    string        values  = string.Empty;
                    List <string> objuser = new List <string>();
                    string[]      value2  = Column.Split(',');
                    for (int k = 0; k < value2.Count(); k++)
                    {
                        if (value2[k] != "")
                        {
                            objuser.Add(value2[k].Replace(",", "''"));
                        }
                    }
                    var pose = (from pi in objdb.CustomReports
                                select new
                    {
                        Id3 = pi.ReportQuery,
                        Template = pi.ReportName
                    }).ToList();
                    ViewBag.Purpose = new SelectList(pose, "Id3", "Template");
                    string        constr1 = ConfigurationManager.AppSettings["connstr"];
                    DataSet       ds1     = new DataSet();
                    SqlConnection objcon1 = new SqlConnection(constr1);
                    SqlCommand    cmd1    = new SqlCommand(Id, objcon1);
                    TempData["ReportID"] = ds1;
                    int i = 0;
                    foreach (var s in value1)
                    {
                        cmd1.Parameters.Add(s, SqlDbType.VarChar).Value = value2[i];
                        i++;
                    }
                    cmd1.CommandText = Id;                          //  Stored procedure name
                    cmd1.CommandType = CommandType.StoredProcedure; // set it to stored proc
                    SqlDataAdapter adap1 = new SqlDataAdapter(cmd1);
                    adap1.Fill(ds1);
                    TempData["ID"] = adap1;
                    List <object> chartData = new List <object>();
                    List <object> List      = new List <object>();
                    List <object> valueList = new List <object>();
                    foreach (DataRow dr in ds1.Tables[0].Rows)
                    {
                        DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports();
                        Array column = dr.ItemArray;
                        ob.ReportName1 = column;
                        List.Add(ob.ReportName1);
                        Report.Add(ob);
                    }
                    foreach (DataColumn dr in ds1.Tables[0].Columns)
                    {
                        DSRCManagementSystem.Models.CustomReports ob1 = new DSRCManagementSystem.Models.CustomReports();
                        ob1.CustomNameId = dr.ColumnName;
                        valueList.Add(ob1.CustomNameId);
                    }
                    ViewBag.List          = Report.ToList();
                    TempData["Value"]     = Report.ToList();
                    TempData["List"]      = ViewBag.Val = valueList;
                    TempData["ReportIDs"] = TempData["cusId"];
                    ViewBag.Val           = valueList;
                    ViewBag.ListValue     = List;
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
                return(Json("Warning", JsonRequestBehavior.AllowGet));
            }
            var userid = Convert.ToInt32(Session["UserID"]);

            ViewBag.permission = (from p in objdb.ReportsPermissions
                                  where p.UserId == userid && p.IsAuthorized == true
                                  select p.UserId).SingleOrDefault();
            ViewBag.UserID = Convert.ToInt32(Session["UserID"]);

            return(View(value));
        }