public ActionResult AddAdmin(Admin p)
        {
            SHA1   sha1     = new SHA1CryptoServiceProvider();
            string password = p.AdminPassword;
            string result   = Convert.ToBase64String(sha1.ComputeHash(Encoding.UTF8.GetBytes(password)));

            p.AdminPassword = result;
            adminManager.Add(p);
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Index(Admin admin)
        {
            SHA1   sha1     = new SHA1CryptoServiceProvider();
            string password = admin.AdminPassword;
            string result   = Convert.ToBase64String(sha1.ComputeHash(Encoding.UTF8.GetBytes(password)));

            admin.AdminPassword = result;
            admin.AdminRole     = "B";
            adminManager.Add(admin);
            return(RedirectToAction("Index", "Login"));
        }
Beispiel #3
0
 public ActionResult AddAdmin(Admin info)
 {
     if (ModelState.IsValid)
     {
         var ss = bll.Add(info);
         if (ss)
         {
             return(Redirect("/Home/QueryAllAdmin"));
         }
         else
         {
             return(Content("新增失败"));
         }
     }
     return(View());
 }
        /// <summary>
        /// 添加操作
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public ActionResult AddAjax(string UserName, string Password, string RealName, string Email, string Phone, int DepartId, int RoleId)
        {
            Admin admin = new Admin();
            //获取最大编号
            string UserCode = Adminmanager.GetByWhere(item => item.Id != 1 && item.IsDelete == 0).OrderByDescending(item => item.UserCode).Take(1).Select(item => item.UserCode).FirstOrDefault();

            if (string.IsNullOrEmpty(UserCode))
            {
                admin.UserCode = "000001";
            }
            else
            {
                admin.UserCode = "00000" + (int.Parse(UserCode) + 1);
                int num = int.Parse(UserCode);
                if (num >= 9)
                {
                    admin.UserCode = "0000" + (int.Parse(UserCode) + 1);
                }
                else if (num >= 99)
                {
                    admin.UserCode = "000" + (int.Parse(UserCode) + 1);
                }
            }
            admin.UserName   = UserName;
            admin.Password   = Password;
            admin.RealName   = RealName;
            admin.Email      = Email;
            admin.Phone      = Phone;
            admin.DepartId   = DepartId;
            admin.RoleId     = RoleId;
            admin.IsDelete   = 0;
            admin.CreateTime = DateTime.Now;
            bool val = Adminmanager.Add(admin);

            if (val)
            {
                return(Json("新增成功", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("新增失败", JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult Add(AdminModelel info)
 {
     if (ModelState.IsValid)
     {
         AdminManager bll      = new AdminManager();
         Completion   db       = new Completion();
         Admin        inf      = db.Admin.ToList().OrderBy(x => x.CreateTime).LastOrDefault();
         int          UserCode = Convert.ToInt32(inf.UserCode) + 1;
         string       code     = UserCode.ToString();
         Admin        info1    = new Admin
         {
             UserCode   = code,
             ZName      = info.ZName,
             IsDelete   = 0,
             LoginCount = 0,
             CreateTime = DateTime.Now,
             UpdateTime = DateTime.Now,
             UserName   = info.UserName,
             PassWord   = info.PassWord,
             Email      = info.Email,
             Phone      = info.Phone,
             RoleNum    = info.RoleNum,
             DepartNum  = info.DepartNum,
             Remark     = info.Remark
         };
         var ss = bll.Add(info1);
         if (ss)
         {
             return(Json(ss, JsonRequestBehavior.DenyGet));
         }
         else
         {
             ModelState.AddModelError("error", "登录失败");
         }
         return(Json(ss, JsonRequestBehavior.DenyGet));
     }
     return(Json(info, JsonRequestBehavior.DenyGet));
 }
 public ActionResult Add(Admin ad)
 {
     ad.CreateTime = DateTime.Now;
     return(Json(AdminManager.Add(ad), JsonRequestBehavior.AllowGet));
 }
 public ActionResult Add(Admin admin)
 {
     adminManager.Add(admin);
     return(RedirectToAction("Index"));
 }
Beispiel #8
0
 public ActionResult Add(Admin admin)
 {
     _adminManager.Add(admin);
     return(RedirectToAction("Index", "Authorization"));
 }