예제 #1
0
        public ActionResult AddGroup(Web_UserGroup model)
        {
            ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm);
            try
            {
                string t = Request["FunctionId"].ToString();//获取选中的分类ID格式为("1,2,3”)不包含括号。
                List<Int32> idlist = new List<int>();
                if (!string.IsNullOrEmpty(t))
                {
                    if (t.Contains(","))
                    {
                        foreach (var each in t.Split(',').ToList())
                        {
                            idlist.Add(Convert.ToInt32(each));
                        }
                    }
                    else
                    {
                        idlist.Add(Convert.ToInt32(t));
                    }
                }
                IEnumerable<Web_Sys_Function> selectedFuncs = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm).Where(p => idlist.Contains(p.ID));
                if (model.Group_ID == 0) //New
                {
                    model.Web_Sys_Functions = selectedFuncs.ToList();
                    //model.Web_Sys_Functions = new List<Web_Sys_Function>();
                    //selectedFuncs.ToList().ForEach(f => model.Web_Sys_Functions.Add(f));
                    groupBLL.AddNew(model, dbParm);
                }
                else                    //Edit
                {
                    List<Web_Sys_Function> originalFuncs = groupBLL.Get(model.Group_ID, dbParm).Web_Sys_Functions;
                    model.Web_Sys_Functions = originalFuncs;
                    //要删除的function
                    var dlist = originalFuncs.Where(p => !selectedFuncs.Contains(p)).ToList();
                    //要添加的function
                    var alist = selectedFuncs.Where(p => !originalFuncs.Contains(p)).ToList();
                    foreach (var item in dlist)
                    {
                        model.Web_Sys_Functions.Remove(item);
                    }
                    foreach (var item in alist)
                    {
                        model.Web_Sys_Functions.Add(item);
                    }
                    groupBLL.Update(model, dbParm);
                }

                ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm);
                return null;
                //return View();
            }
            catch (Exception ex)
            {
                var y = ex.InnerException;
                return View(model);
            }
        }
예제 #2
0
 /// <summary>
 /// 增加WEB_USERGROUP
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int AddNew(Web_UserGroup model, RogerContext dbParam = null)
 {
     if (dbParam == null)
     {
         dbParam = db;
     }
     dbParam.Web_UserGroups.Add(model);
     return dbParam.SaveChanges();
 }
예제 #3
0
 /// <summary>
 /// 更新WEB_USERGROUP实体
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int Update(Web_UserGroup model, RogerContext dbParm)
 {
     return dal.Update(model, dbParm);
 }
예제 #4
0
 /// <summary>
 /// 增加WEB_USERGROUP
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int AddNew(Web_UserGroup model, RogerContext dbParam = null)
 {
     return dal.AddNew(model,dbParam);
 }
예제 #5
0
        public ActionResult UserGroupInfo(Web_UserGroup model)
        {
            try
            {
                var t = Request["FunctionId"];//获取选中的分类ID格式为("1,2,3”)不包含括号。
                List<Int32> idlist = new List<int>();
                foreach (var each in t.Split(',').ToList())
                {
                    idlist.Add(Convert.ToInt32(each));
                }
                var cate = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm).Where(p => idlist.Contains(p.ID));
                if (model.Web_Sys_Functions == null)
                {
                    model.Web_Sys_Functions = new List<Web_Sys_Function>();
                }
                foreach (var item in cate)
                {
                    model.Web_Sys_Functions.Add(item);
                }
                new Web_UserGroupDAL().AddNew(model, dbParm);

                ViewBag.Functions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm);
                return View();
            }
            catch (Exception ex)
            {
                var y = ex.InnerException;
                return View(model);
            }
        }
예제 #6
0
        /// <summary>
        /// 保存资料业务
        /// </summary>
        /// <param name="context"></param>
        public void SaveUserGroup()
        {
            //用户json数据读取
            //数据为[{"LOGNAME":"tianzh","USERGROUPID":"1","PASSWORD":"******","REALNAME":"tianzhuanghu","MEMO":"tianzhuanghu"}]
            String UserGroupStr = Request["UserGroup"];
            if (string.IsNullOrEmpty(UserGroupStr))
                return;

            ////使用Newtonsoft.Json.dll组件解析json对象
            ////首先过滤掉json中的[和]
            string info = UserGroupStr.TrimStart('[');
            info = info.TrimEnd(']');
            JObject o = JObject.Parse(info);
            string USERGROUP = (string)o.SelectToken("USERGROUP");
            string DESCRIPTION = (string)o.SelectToken("DESCRIPTION");

            Web_UserGroup group = new Web_UserGroup();

            //保存用户数据的model对象
            group.USERGROUP = USERGROUP;
            group.DESCRIPTION = DESCRIPTION;
            if (o.SelectToken("ID") != null)
            {
                group.Group_ID = (int)o.SelectToken("ID");
                groupBLL.Update(group, dbParm);
            }
            else
            {
                groupBLL.AddNew(group);
            }
        }
예제 #7
0
 /// <summary>
 /// 更新WEB_USERGROUP实体
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int Update(Web_UserGroup model, RogerContext dbParm=null)
 {
     return base.Update<Web_UserGroup>(model,model.Group_ID, dbParm);
 }