Esempio n. 1
0
        public ActionResult edit(EditPasswordViewModel m)
        {
            m.Password = Global.md5(m.Password);
            m.Password1 = Global.md5(m.Password1);
            m.Password2 = Global.md5(m.Password2);

            if (!isLogin()) return RedirectToAction("login", "auth");
            Provider db = new Provider();
            if (m.Password1 != m.Password2)
            {
                ViewData["error"] = "两次密码不一样";
                return View();
            }
            User u = getCurrentUser();
            if (u.Password != m.Password)
            {
                ViewData["error"] = "密码错了,再试试吧";
                return View();
            }
            u.Password = m.Password1;
            db.updateUser(u);
            UserInfo ui = new UserInfo();
            ui.Id = u.Id;
            ui.Address = m.Address;
            ui.Phone = m.Phone;
            ui.Email = m.Email;
            ui.Info = m.Info;
            db.updateUserInfo(ui);
            return View("EditSuccess");
        }
Esempio n. 2
0
 public void updateUserInfo(UserInfo userinfo)
 {
     executeNonQuery("UPDATE [UserInfo] SET Email='" + userinfo.Email + "', Address='" + userinfo.Address + "', Phone='" + userinfo.Phone + "', Info='" + userinfo.Info + "' WHERE Id=" + userinfo.Id);
 }
Esempio n. 3
0
 public UserInfo toUserInfo(DataRow data)
 {
     if (data == null) return null;
     UserInfo userinfo = new UserInfo();
     userinfo.Id = (int)data["Id"];
     userinfo.Email = (data["Email"] is DBNull)?"":(string)data["Email"];
     userinfo.Phone = (data["Phone"] is DBNull) ? "" : (string)data["Phone"];
     userinfo.Info = (data["Info"] is DBNull) ? "" : (string)data["Info"];
     userinfo.Address = (data["Address"] is DBNull) ? "" : (string)data["Address"];
     return userinfo;
 }
Esempio n. 4
0
 public void insertUserInfo(UserInfo userinfo)
 {
     executeNonQuery("INSERT INTO [UserInfo] (Id, Email, Address, Phone, Info) VALUES ("+userinfo.Id+ ",'" + userinfo.Email + "','" + userinfo.Address + "','" + userinfo.Phone + "','" + userinfo.Info + "')");
 }
Esempio n. 5
0
        public ActionResult register(RegisterViewModel m)
        {
            if (m.UserName==null || m.Password1 == null || m.Password2 == null)
            {
                ViewData["error"] = "没填的input伤不起";
                return View();
            }
            m.Password1 = Global.md5(m.Password1);
            m.Password2 = Global.md5(m.Password2);
            Provider db = new Provider();
            User user = db.getUser(m.UserName);
            if (user != null)
            {
                ViewData["error"] = "哎呀,此用户名已经被注册了";
                return View();
            }
            if (m.Password1 != m.Password2)
            {
                ViewData["error"] = "两次密码不一样";
                return View();
            }
            Regex emailExp = new Regex(@"^\w+@\w+(\.\w+)+(\,\w+@\w+(\.\w+)+)*$");
            if (!string.IsNullOrEmpty(m.Email) && !emailExp.Match(m.Email).Success)
            {
                ViewData["error"] = "邮箱格式不正确";
                return View();
            }

            User u = new User();
            u.UserName = m.UserName;
            u.Password = m.Password1;
            u.RegisterTime = DateTime.Now;
            db.insertUser(u);

            int uid = (int)db.getDataRow("SELECT Id FROM [User] ORDER BY Id DESC")["Id"];
            Global.addDefaultTag(uid);

            UserInfo userinfo = new UserInfo();
            userinfo.Id = uid;
            userinfo.Address = m.Address;
            userinfo.Email = m.Email;
            userinfo.Phone = m.Phone;
            userinfo.Info = "";
            db.insertUserInfo(userinfo);
            return View("msg", new MsgViewModel() { msg = "注册成功", url = "/auth/login" });
        }