Exemplo n.º 1
0
 public ActionResult Report()
 {
     try{
         DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
         var categories = objdb.Master_Roles.Select(c => new
         {
             CategoryID   = c.RoleID,
             CategoryName = c.RoleName
         }).ToList();
         ViewBag.Categories = new MultiSelectList(categories, "CategoryID", "CategoryName");
         List <DSRCManagementSystem.Models.ReportMOD> objmodel = new List <Models.ReportMOD>();
         string        constr = ConfigurationManager.AppSettings["connstr"];
         DataTable     dt     = new DataTable();
         SqlConnection objcon = new SqlConnection(constr);
         SqlCommand    cmd    = new SqlCommand("Sp_Names", objcon);
         cmd.CommandText = "Sp_Names";
         cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter adap = new SqlDataAdapter(cmd);
         adap.Fill(dt);
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             DSRCManagementSystem.Models.ReportMOD obj = new DSRCManagementSystem.Models.ReportMOD();
             obj.Name = dt.Rows[i]["SP"].ToString();
             objmodel.Add(obj);
         }
         SelectList list = new SelectList(objmodel, "Name", "Name");
         list.OrderBy(a => a);
         ViewBag.Roles = 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(View());
 }
Exemplo n.º 2
0
        public ActionResult EditRoll(int ReportID)
        {
            var ReportDetails = new ReportMOD();
            List <DSRCManagementSystem.Models.ReportMOD> objmodel = new List <Models.ReportMOD>();

            try
            {
                DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
                var Role = objdb.CustomReports_UserMapping.Where(x => x.ReportID == ReportID).Select(o => o.RoleID).ToList();
                ViewBag.Role = Role;

                var categories = objdb.Master_Roles.Select(c => new
                {
                    CategoryID   = c.RoleID,
                    CategoryName = c.RoleName
                }).ToList();
                ViewBag.Categories = new MultiSelectList(categories, "CategoryID", "CategoryName", Role);

                Session["ReportID"] = ReportID;

                //var RoleName=objdb.Master_Roles.Where(o=>o.RoleID==Role


                //var Role = (from u in objdb.CustomReports_UserMapping
                //            where u.ReportID == ReportID
                //            select new
                //            {
                //                u.RoleID
                //            }).FirstOrDefault();



                ReportDetails = (from u in objdb.CustomReports
                                 where u.ReportID == ReportID
                                 select new ReportMOD
                {
                    rollid = u.ReportID,
                    Name = u.ReportName,
                    Description = u.ReportDescription,
                    sp = u.ReportQuery,
                }).FirstOrDefault();



                string        constr = ConfigurationManager.AppSettings["connstr"];
                DataTable     dt     = new DataTable();
                SqlConnection objcon = new SqlConnection(constr);
                SqlCommand    cmd    = new SqlCommand("Sp_Names", objcon);
                cmd.CommandText = "Sp_Names";
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adap = new SqlDataAdapter(cmd);
                adap.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DSRCManagementSystem.Models.ReportMOD obj = new DSRCManagementSystem.Models.ReportMOD();
                    obj.Name = dt.Rows[i]["SP"].ToString();
                    objmodel.Add(obj);
                }
                SelectList list = new SelectList(objmodel, "Name", "Name");
                list.OrderBy(a => a);
                ViewBag.Roles = 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(View(ReportDetails));
        }