Exemple #1
0
        public ActionResult UserOrg(FormCollection formCollection)
        {
            string userid = formCollection["userid"];
            string orgid  = formCollection["hidOrg"];

            DaoUSERORGANIZE.DeleteObject(DaoUSERORGANIZE.FindList("", "USER_ID", userid).ToList());

            var orgs = DaoORGANIZE.FindList();
            List <SYS_USERORGANIZE> addroleauths = new List <SYS_USERORGANIZE>();

            if (!string.IsNullOrEmpty(orgid))
            {
                var orgarr = orgid.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var seleorg in orgarr)
                {
                    var org = orgs.FirstOrDefault(obj => obj.ORG_ID == seleorg);
                    addroleauths.Add(new SYS_USERORGANIZE {
                        USER_ID = userid, ORG_ID = org.ORG_ID, CREATE_DTIME = DateTime.Now, CREATE_ID = UserState.UserID
                    });
                }
            }
            if (addroleauths.Count > 0)
            {
                DaoUSERORGANIZE.AddObject(addroleauths);
            }
            TempData["user"] = DaoUser.GetEntity("USER_ID", userid);
            Alter("修改成功!", AlterTypeEnum.Success, true, true);
            return(View(DaoUSERORGANIZE.FindList("", "USER_ID", userid)));
        }
Exemple #2
0
 public ActionResult Edit(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         var user = DaoUser.GetEntity("USER_ID", id);
         return(View(user));
     }
     return(Redirect("/Home/Error"));
 }
Exemple #3
0
        public ActionResult Edit(SYS_USER user, string id)
        {
            try
            {
                var exituser = DaoUser.GetEntity("USER_ID", id);
                if (string.IsNullOrEmpty(user.USER_NAM))
                {
                    ModelState.AddModelError("USER_NAM", "用户名称不能为空!");
                }
                if (!ModelState.IsValidField("USER_PASSWORD"))
                {
                    ModelState.Remove("USER_PASSWORD");//不验证密码
                }
                if (!ModelState.IsValid)
                {
                    //return JsonResult(false, "数据验证失败!");
                    Alter("数据验证失败!", AlterTypeEnum.Error, false, false);
                    return(View(user));
                }
                if (!string.IsNullOrEmpty(user.USER_PASSWORD))
                {
                    user.USER_PASSWORD = CryptTools.Md5(user.USER_PASSWORD);
                }
                else
                {
                    var olduser = DaoUser.GetEntity("USER_ID", user.USER_ID);
                    user.USER_PASSWORD = olduser.USER_PASSWORD;
                }

                user.MODIFY_ID    = UserState.UserID;
                user.MODIFY_DTIME = DateTime.Now;

                var rst = dao.UpdateObject(user, "USER_ID");
                if (rst > 0)
                {
                    Alter("修改成功!", AlterTypeEnum.Success, true, true);
                    return(View(user));
                }
                else
                {
                    ModelState.AddModelError("", "修改失败!");
                    Alter("修改失败!", AlterTypeEnum.Error, false, false);
                    return(View(user));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog("系统错误!", ex);
                ModelState.AddModelError("", "系统错误!");
                Alter("系统错误!", AlterTypeEnum.Error, false, false);
                return(View(user));
            }
        }
Exemple #4
0
 public ActionResult Create(SYS_USER user)
 {
     try
     {
         if (string.IsNullOrEmpty(user.USER_ID))
         {
             ModelState.AddModelError("USER_ID", "用户账号不能为空!");
         }
         if (!string.IsNullOrEmpty(user.USER_ID) && DaoUser.GetEntity("USER_ID", user.USER_ID) != null)
         {
             ModelState.AddModelError("USER_ID", "用户账号已经存在!");
         }
         if (string.IsNullOrEmpty(user.USER_NAM))
         {
             ModelState.AddModelError("USER_NAM", "用户名称不能为空!");
         }
         if (string.IsNullOrEmpty(user.USER_PASSWORD))
         {
             ModelState.AddModelError("USER_PASSWORD", "用户密码不能为空!");
         }
         if (!ModelState.IsValid)
         {
             ModelState.AddModelError("", "数据验证失败!");
             //return JsonResult(false, "数据验证失败!");
             Alter("数据验证失败!", AlterTypeEnum.Error, false, false);
             return(View());
         }
         user.USER_PASSWORD = CryptTools.Md5(user.USER_PASSWORD);
         user.CREATE_ID     = UserState.UserID;
         user.CREATE_DTIME  = DateTime.Now;
         DaoUser.AddObject(user);
         Alter("新增成功!", AlterTypeEnum.Success, true, true);
         return(View());
         //return JsonResult(true, "新增成功!","AUTH","",false);
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLog("系统错误!", ex);
         ModelState.AddModelError("", "系统错误!");
         Alter("系统错误!", AlterTypeEnum.Error, false, false);
         return(View());
     }
 }
Exemple #5
0
 public ActionResult UserOrg(string id)
 {
     TempData["user"] = DaoUser.GetEntity("USER_ID", id);
     return(View(DaoUSERORGANIZE.FindList("", "USER_ID", id)));
 }
Exemple #6
0
 private void GetViewData(string id)
 {
     TempData["user"]  = DaoUser.GetEntity("USER_ID", id);
     TempData["roles"] = DaoRole.FindList("ROLE_ID");
 }
Exemple #7
0
 public ActionResult Details(string id)
 {
     return(View(DaoUser.GetEntity("USER_ID", id)));
 }