示例#1
0
 /* 修改用户密码 */
 public bool ChangeUserPassword(UserAccout account, UserType userType)
 {
     if (userType == UserType.Principal)
     {
     }
     throw new NotImplementedException();
 }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserAccout userAccout = db.UserAccouts.Find(id);

            db.UserAccouts.Remove(userAccout);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "User_Id,User_Name,User_Lastname,User_Sex,User_Tel,User_Email,User_Address,User_Password")] UserAccout userAccout)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userAccout).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userAccout));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "User_Id,User_Name,User_Lastname,User_Sex,User_Tel,User_Email,User_Address,User_Password")] UserAccout userAccout)
        {
            if (ModelState.IsValid)
            {
                db.UserAccouts.Add(userAccout);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userAccout));
        }
示例#5
0
        // GET: UserAccouts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserAccout userAccout = db.UserAccouts.Find(id);

            if (userAccout == null)
            {
                return(HttpNotFound());
            }
            return(View(userAccout));
        }
        public ActionResult Create([Bind(Include = "User_Id,User_Name,User_Lastname,User_Sex,User_Tel,User_Email,User_Address")] UserAccout userAccout)
        {
            if (ModelState.IsValid)
            {
                Session["User_Email"]    = userAccout.User_Email;
                Session["User_Id"]       = userAccout.User_Id;
                Session["User_Name"]     = userAccout.User_Name;
                Session["User_Lastname"] = userAccout.User_Lastname;
                Session["User_Tel"]      = userAccout.User_Tel;
                db.UserAccouts.Add(userAccout);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Home"));
        }
示例#7
0
        public ActionResult Login([Bind(Include = "UserAccoutID,UserPassword")] UserAccout userAccout, String returnurl)
        {
            if (ModelState.IsValid)
            {
                #region 用户登录信息票证
                FormsAuthentication.SignOut(); //将之前的票证取消
                //将用户信息保存为Json信息存储在 Cookies 里面
                //用户数据
                JsonData data = new JsonData();
                data["UserID"]  = userAccout.UserAccoutID;
                data["UserPwd"] = userAccout.UserPassword;
                String UserData = JsonMapper.ToJson(data).ToString();

                /*创建一个票据*/
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                    1,
                    userAccout.UserAccoutID,
                    DateTime.Now,              //发放票证的时间
                    DateTime.Now.AddHours(12), //认证Cookie 设置过期时间6小时
                    true,
                    UserData,
                    FormsAuthentication.FormsCookieName
                    );
                /*加密这个票据*/
                string     encTicket = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                cookie.HttpOnly = true;
                //添加cookie信息
                Response.Cookies.Add(cookie);
                #endregion

                #region 存储用户登陆信息

                #endregion

                return(Redirect(returnurl ?? Url.Action("Index", "Home")));
            }
            else
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Create([Bind(Include = "User_Id,User_Name,User_Lastname,User_Sex,User_Tel,User_Email,User_Address")] UserAccout userAccout, VIVOSHOP.Models.UserAccout userModel)
        {
            try
            {
                var emailChecked = new System.Net.Mail.MailAddress(userAccout.User_Email);
                if (userAccout.User_Tel.Length < 10)
                {
                    var phoneChecked = new System.Net.Mail.MailAddress(userAccout.User_Tel);
                }
                if (ModelState.IsValid)
                {
                    Session["id"]            = userAccout.User_Id;
                    Session["User_Email"]    = userAccout.User_Email;
                    Session["User_Id"]       = userAccout.User_Id;
                    Session["User_Name"]     = userAccout.User_Name;
                    Session["User_Lastname"] = userAccout.User_Lastname;
                    Session["User_Tel"]      = userAccout.User_Tel;
                    Session["User_Address"]  = userAccout.User_Address;
                    db.UserAccouts.Add(userAccout);
                    db.SaveChanges();
                    var user = db.UserAccouts.OrderByDescending(x => x.User_Id).FirstOrDefault();
                    Session["id"]            = user.User_Id;
                    Session["User_Email"]    = user.User_Email;
                    Session["User_Id"]       = user.User_Id;
                    Session["User_Name"]     = user.User_Name;
                    Session["User_Lastname"] = user.User_Lastname;
                    Session["User_Tel"]      = user.User_Tel;
                    Session["User_Address"]  = user.User_Address;
                }

                return(RedirectToAction("Index", "Home"));
            }
            catch
            {
                ViewBag.ErrorCHK = "True";
                userModel.LoginErrorMessageTEL   = "เบอร์โทรต้องมี 10 หลัก";
                userModel.LoginErrorMessageEMAIL = "กรุณาตรวจสอบ Email";
                return(View(userModel));
            }
        }
示例#9
0
        /// <summary>
        /// 修改账户密码/只允许学生修改  教师密码只允许管理员修改
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="UserNewPassword"></param>
        /// <param name="IDNumber"></param>
        /// <returns></returns>
        public String ChangePassword(String UserID, String UserNewPassword, String IDNumber)
        {
            Map.UserType type = UserAccountService.GetUserType(UserID);

            JsonData val = new JsonData();

            if (UserID.Trim() != "" || UserNewPassword.Trim() != "" || IDNumber.Trim() != "")
            {
                FormsAuthentication.SignOut();
                UserAccout accout = new UserAccout();
                accout.UserAccoutID = UserID;
                accout.UserPassword = UserNewPassword;
                Boolean result = UserAccountService.ChangeUserPassword(accout, Map.UserType.Student);
                val["isOk"] = result;//返回状态如何 成功
            }
            else
            {
                RedirectToAction("Error", "Home");
                val["isOk"] = false;//返回状态如何 失败
            }
            return(val.ToJson());
        }