Exemple #1
0
        /// <summary>
        /// 操作权限表中的数据
        /// </summary>
        /// <returns></returns>

        public ActionResult OperatePer()
        {
            string id      = Request.Form["perId"].ToString();
            int    operate = 1;//1为新增,2为修改

            if (!string.IsNullOrEmpty(id))
            {
                operate = 2;
            }
            MODEL.T_Permission per = new MODEL.T_Permission();
            per.PerAddTime    = Convert.ToDateTime(Request.Form["PerAddTime"]);
            per.PerName       = Request.Form["PerName"].ToString();
            per.PerParent     = Convert.ToInt32(Request.Form["PerParent"]);
            per.PerAreaName   = Request.Form["PerAreaName"].ToString();
            per.PerController = Request.Form["PerController"].ToString();
            per.PerActionName = Request.Form["PerActionName"].ToString();
            per.PerFormMethod = Convert.ToInt32(Request.Form["PerFormMethod"]);
            int show = Convert.ToInt32(Request.Form["PerIsShow"]);

            if (show == 1)
            {
                per.PerIsShow = true;
            }
            else
            {
                per.PerIsShow = false;
            }
            per.PerIco     = Request.Form["PerIco"].ToString();
            per.IsCommon   = Convert.ToBoolean(Request.Form["IsCommon"]);
            per.perExplain = Request.Form["perExplain"].ToString();

            string[] proNames;
            if (operate == 1)
            {
                if (OperateContext.Current.BLLSession.IPermissionBLL.Add(per) > 0)
                {
                    return(Redirect("/Permission/Permission/PerIndex"));
                }
            }
            if (operate == 2)
            {
                per.PerId = Convert.ToInt32(Request.Form["PerId"]);
                proNames  = new string[] { "PerName", "PerParent", "PerAreaName", "PerController", "PerActionName", "PerFormMethod", "PerIsShow", "PerAddTime",
                                           "PerIco", "perExplain", "IsCommon" };
                //成功或失败信息提示还没做    可以用返回script代码
                if (OperateContext.Current.BLLSession.IPermissionBLL.Modify(per, proNames) > 0)
                {
                    return(Redirect("/Permission/Permission/PerIndex"));
                }
            }
            return(Redirect("/Permission/Permission/PerIndex"));
        }
Exemple #2
0
        //权限操作
        #region 2.1 得到权限操作页面,比如新增,编辑,查看 ActionResult HandlePermission()
        //得到权限操作页面,比如新增,编辑,查看
        public ActionResult HandlePermission()
        {
            int perId   = 0;
            int operate = 0;//得到是什么操作:如果是1则为新增,2为编辑,3为查看

            if (Request.QueryString["operate"] != null)
            {
                operate = Convert.ToInt32(Request.QueryString["operate"]);
            }
            if (operate == 1)
            {
                ViewBag.opeName = "新增权限";
                ViewBag.operate = 1;
                MODEL.T_Permission per = new MODEL.T_Permission();
                ViewBag.perModel = per;
            }
            if (operate == 2)
            {
                perId = Convert.ToInt32(Request.QueryString["perid"]);
                //得到当前ID的权限信息
                var per = OperateContext.Current.BLLSession.IPermissionBLL.GetListBy(u => u.IsDelete == false && u.PerId == perId).First();
                MODEL.T_Permission perModel = per;
                ViewBag.perModel = perModel;
                ViewBag.opeName  = "编辑权限";
                ViewBag.operate  = 2;
            }
            if (operate == 3)
            {
                perId = Convert.ToInt32(Request.QueryString["perid"]);
                try
                {
                    //得到当前ID的权限信息
                    var per = OperateContext.Current.BLLSession.IPermissionBLL.GetListBy(u => u.IsDelete == false && u.PerId == perId).First();
                    MODEL.T_Permission perModel = per;
                    ViewBag.perModel = perModel;
                    ViewBag.opeName  = "权限详细信息";
                    ViewBag.operate  = 3;
                }
                catch
                {
                    return(null);
                }
            }
            return(View());
        }
 //得到权限操作页面,比如新增,编辑,查看
 public ActionResult HandlePermission()
 {
     int perId = 0;
     int operate = 0;//得到是什么操作:如果是1则为新增,2为编辑,3为查看
     if (Request.QueryString["operate"] != null)
     {
         operate = Convert.ToInt32(Request.QueryString["operate"]);
     }
     if (operate == 1)
     {
         ViewBag.opeName = "新增权限";
         ViewBag.operate = 1;
         MODEL.T_Permission per = new MODEL.T_Permission();
         ViewBag.perModel = per;
     }
     if (operate == 2)
     {
         perId = Convert.ToInt32(Request.QueryString["perid"]);
         //得到当前ID的权限信息
         var per = OperateContext.Current.BLLSession.IPermissionBLL.GetListBy(u => u.IsDelete == false && u.PerId == perId).First();
         MODEL.T_Permission perModel = per;
         ViewBag.perModel = perModel;
         ViewBag.opeName = "编辑权限";
         ViewBag.operate = 2;
     }
     if (operate == 3)
     {
         perId = Convert.ToInt32(Request.QueryString["perid"]);
         try
         {
             //得到当前ID的权限信息
             var per = OperateContext.Current.BLLSession.IPermissionBLL.GetListBy(u => u.IsDelete == false && u.PerId == perId).First();
             MODEL.T_Permission perModel = per;
             ViewBag.perModel = perModel;
             ViewBag.opeName = "权限详细信息";
             ViewBag.operate = 3;
         }
         catch
         {
             return null;
         }
     }
     return View();
 }
        public ActionResult OperatePer()
        {
            string id = Request.Form["perId"].ToString();
            int operate = 1;//1为新增,2为修改
            if (!string.IsNullOrEmpty(id))
            {
                operate = 2;
            }
            MODEL.T_Permission per = new MODEL.T_Permission();
            per.PerAddTime = Convert.ToDateTime(Request.Form["PerAddTime"]);
            per.PerName = Request.Form["PerName"].ToString();
            per.PerParent = Convert.ToInt32(Request.Form["PerParent"]);
            per.PerAreaName = Request.Form["PerAreaName"].ToString();
            per.PerController = Request.Form["PerController"].ToString();
            per.PerActionName = Request.Form["PerActionName"].ToString();
            per.PerFormMethod = Convert.ToInt32(Request.Form["PerFormMethod"]);
            int show= Convert.ToInt32(Request.Form["PerIsShow"]);
            if (show == 1) { per.PerIsShow = true; }
            else{per.PerIsShow=false;}
            per.PerIco = Request.Form["PerIco"].ToString();
            per.IsCommon = Convert.ToBoolean(Request.Form["IsCommon"]);
            per.perExplain = Request.Form["perExplain"].ToString();

            string[] proNames;
            if (operate == 1)
            {
                if (OperateContext.Current.BLLSession.IPermissionBLL.Add(per) > 0)
                {
                    return Redirect("/Permission/Permission/PerIndex");
                }
            }
            if (operate == 2)
            {
                per.PerId=Convert.ToInt32(Request.Form["PerId"]);
                proNames = new string[] { "PerName", "PerParent", "PerAreaName", "PerController", "PerActionName", "PerFormMethod", "PerIsShow", "PerAddTime",
                "PerIco","perExplain","IsCommon"};
                //成功或失败信息提示还没做    可以用返回script代码
                if (OperateContext.Current.BLLSession.IPermissionBLL.Modify(per, proNames) > 0)
                {
                    return Redirect("/Permission/Permission/PerIndex");
                }
            }
            return Redirect("/Permission/Permission/PerIndex");
        }