Ejemplo n.º 1
0
        public ActionResult EditPassStudent(string tendangnhap)
        {
            string   user = tendangnhap;
            TAIKHOAN tk   = (TAIKHOAN)Session["TaikhoanSV"];

            ViewBag.Taikhoan = tk.SINHVIEN.TenSV;
            if (tk == null || String.IsNullOrEmpty(tk.ToString()))
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                ViewBag.Tendangnhap = tk.TenDN;
                ViewBag.Matkhau     = tk.MatKhau;

                var pw = data.TAIKHOANs.First(p => p.TenDN.Contains(tk.TenDN));
                if (pw == null)
                {
                    Response.StatusCode = 404;
                    return(null);
                }

                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditPassStudent(string tendangnhap, FormCollection collection)
        {
            string   usersv = tendangnhap;
            TAIKHOAN tk     = (TAIKHOAN)Session["TaikhoanSV"];

            if (tk == null || String.IsNullOrEmpty(tk.ToString()))
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                ViewBag.Tendangnhap = tk.TenDN;
                ViewBag.Matkhau     = tk.MatKhau;


                var    pw     = data.TAIKHOANs.First(p => p.TenDN.Contains(usersv));
                string oldpw  = collection["OldPassword"];
                string pass   = collection["Password"];
                string repass = collection["RePassword"];


                if (oldpw != pw.MatKhau)
                {
                    ViewBag.Erorr1 = "Mật khẩu không đúng!!!";
                    return(View("EditPassStudent"));
                }
                else
                {
                    if (repass != pass)
                    {
                        ViewBag.Error = "Mật khẩu nhập lại không chính xác";
                        return(View("EditPassStudent"));
                    }
                    else
                    {
                        pw.TenDN   = usersv;
                        pw.MatKhau = pass;


                        UpdateModel(pw);
                        data.SubmitChanges();
                        return(RedirectToAction("Login"));
                    }
                }
            }
        }