コード例 #1
0
ファイル: LoginController.cs プロジェクト: AnhTu512/dat_tour
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new TaiKhoanDao();
                var result = dao.DangNhap(model.UserName, Encryptor.MD5Hash(model.PassWord));
                if (result == 1)
                {
                    var user        = dao.GetById(model.UserName);
                    var userSession = new UserLogin();
                    userSession.UserName = user.UserName;
                    userSession.UserID   = user.ID;

                    Session.Add(CommonConstants.USER_SESSION, userSession);
                    return(RedirectToAction("_Home", "Home"));
                }
                else if (result == 0)
                {
                    ModelState.AddModelError("", "Tài khoản không tồn tại !");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", "Tài khoản đang bị khóa !");
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", "Mật khẩu không đúng !");
                }
                else
                {
                    ModelState.AddModelError("", "Đăng nhập không đúng !");
                }
            }
            return(View("_Login"));
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: AnhTu512/dat_tour
        // GET: Admin/User
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new TaiKhoanDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
コード例 #3
0
        public ActionResult Login(LoginModel model)
        {
            var   userSession = new UserLogin();
            Regex regex       = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match       = regex.Match(model.TaiKhoan);

            if (match.Success)
            {
                if (ModelState.IsValid)
                {
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    var dao    = new TaiKhoanDao();
                    var result = dao.Login(model.TaiKhoan, Encryptor.MD5Hash(model.MatKhau));
                    if (result == 1)
                    {
                        var user = dao.GetById(model.TaiKhoan);
                        userSession.UserId   = user.MaTaiKhoan;
                        userSession.TaiKhoan = user.TaiKhoan;
                        userSession.MaVaiTro = user.MaVaiTro;
                        var listCredentials = dao.GetListCredential(model.TaiKhoan);

                        Session.Add(CommonConstants.SESSION_CREDENTIALS, listCredentials);
                        Session.Add(CommonConstants.USER_SESSION, userSession);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else if (result == -1)
                    {
                        ModelState.AddModelError("", "Tài khoản hiện đang bị khóa");
                    }
                    else if (result == -2)
                    {
                        ModelState.AddModelError("", "Vui lòng nhập lại mật khẩu");
                    }
                    else if (result == 0)
                    {
                        ModelState.AddModelError("", "Tài khoản không tồn tại");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Đăng nhập thất bại, vui lòng liên hệ Admin");
                    }
                }
            }
            return(View("Index"));
        }
コード例 #4
0
 public ActionResult Index(TaikhoanModel collection)
 {
     if (ModelState.IsValid)
     {
         var dao = new TaiKhoanDao();
         var res = dao.login(collection.UserName, Encryptor.Encrypt(collection.Password, collection.UserName));
         if (res == 1)
         {
             if (collection.RememberMe)
             {
                 HttpCookie Tentaikhoan = RemmemberMe.CreateCookie("Tentaikhoan", collection.UserName);
                 Response.Cookies.Add(Tentaikhoan);
                 HttpCookie Matkhau = RemmemberMe.CreateCookie("Matkhau", collection.Password);
                 Response.Cookies.Add(Matkhau);
                 HttpCookie LuuMatkhau = RemmemberMe.CreateCookie("LuuMatkhau", "true");
                 Response.Cookies.Add(LuuMatkhau);
             }
             else
             {
                 HttpCookie LuuMatkhau = RemmemberMe.CreateCookie("LuuMatkhau", "false");
                 Response.Cookies.Add(LuuMatkhau);
             }
             var user        = dao.GetById(collection.UserName);
             var usersession = new TaiKhoanLogin();
             usersession.UserName = user.Tentaikhoan;
             Session.Add(CommonConstants.USER_SESSION, usersession);
             return(RedirectToAction("Index", "Admin/Home"));
         }
         else
         if (res == -1)
         {
             ModelState.AddModelError("", "Tên đăng nhập không tồn tại");
         }
         else
         if (res == 0)
         {
             ModelState.AddModelError("", "Mật khẩu không đúng");
         }
         else
         if (res == 2)
         {
             ModelState.AddModelError("", "Tài khoản đã bị khóa");
         }
     }
     return(View(collection));
 }
コード例 #5
0
        public int ChangePassWord(int maNhanVien, string passwordOld, string passwordNew)
        {
            TaiKhoanDao _tkDAO = new TaiKhoanDao();

            if (TaiKhoanDao.CheckValidPass(maNhanVien, passwordOld) == false)
            {
                return(0);
            }
            else if (TaiKhoanDao.ChangePassWord(maNhanVien, passwordOld, passwordNew) == true)
            {
                return(1);
            }
            else
            {
                return(2);
            }
        }
コード例 #6
0
        public JsonResult DangNhap(TaiKhoan tk)
        {
            TaiKhoanDao tkd = new TaiKhoanDao();

            if (tkd.KiemTraDangNhap(tk) == true && ModelState.IsValid)
            {
                var userSesstion = new UserLogin();
                userSesstion.TenDangNhap = tk.TenDangNhap;
                Session.Add(CommonConstants.USER_SESSION, userSesstion);
                return(Json(new {
                    status = true
                }));
            }
            return(Json(new {
                status = false
            }));
        }
コード例 #7
0
ファイル: CategoryController.cs プロジェクト: tho2503/CDIO4
        public ActionResult Edit(TaiKhoan acc)
        {
            if (ModelState.IsValid)
            {
                var dao = new TaiKhoanDao();

                var res = dao.Update(acc);
                if (res)
                {
                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "Sửa thành công");
                }
            }
            return(View("Index"));
        }
コード例 #8
0
ファイル: AccountController.cs プロジェクト: tho2503/CDIO4
        public ActionResult Create(TaiKhoan acc)
        {
            if (ModelState.IsValid)
            {
                var dao = new TaiKhoanDao();

                var res = dao.Insert(acc);
                if (res != null)
                {
                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm thành công");
                }
            }
            return(View("Index"));
        }
コード例 #9
0
        public bool CreateStaffAndAccount(string _staffName, string _staffShortName, bool _staffGender, DateTime _staffBirthday, int _staffJobtitle, int _staffPaymentStore, int _staffPermission, string _staffAddress, string _staffEmail, string _staffPhoneNumber, out string Message)
        {
            NhanVienDto _nhanVien = new NhanVienDto();

            _nhanVien.TenNhanVien = _staffName;
            _nhanVien.GioiTinh    = _staffGender;
            _nhanVien.NgaySinh    = _staffBirthday;
            _nhanVien.ChucVu      = _staffJobtitle;
            _nhanVien.MaQGD       = _staffPaymentStore;
            _nhanVien.DoiMatKhau  = false;
            _nhanVien.TrangThai   = true;
            _nhanVien.DiaChi      = _staffAddress;
            _nhanVien.Email       = _staffEmail;
            _nhanVien.SoDT        = _staffPhoneNumber;

            if (CreateNewStaff(_nhanVien))
            {
                TaiKhoanDto _taiKhoan = new TaiKhoanDto();
                _taiKhoan.TenDangNhap = TaiKhoanDao.GetAccountName(_staffShortName);
                _taiKhoan.MatKhau     = Helpers.EncryptMD5("123456a@", true);
                _taiKhoan.MaNhomTK    = _staffPermission;
                _taiKhoan.MaNhanVien  = _nhanVien.MaNV;
                _taiKhoan.TrangThai   = true;
                TaiKhoanBus _tkBUS = new TaiKhoanBus();
                if (_tkBUS.CreateNewAccount(_taiKhoan))
                {
                    Message = "Tạo tài khoản thành công.\nVui lòng đăng nhập với tên: " + _taiKhoan.TenDangNhap;
                    return(true);
                }
                else
                {
                    Message = "Có lỗi trong lúc tạo tài khoản cho nhân viên";
                    return(false);
                }
            }
            else
            {
                Message = "Có lỗi trong quá trình tạo nhâ viên mới";
                return(false);
            }
        }
コード例 #10
0
ファイル: UserController.cs プロジェクト: AnhTu512/dat_tour
        public ActionResult Create(TaiKhoan user)
        {
            if (ModelState.IsValid)
            {
                var dao = new TaiKhoanDao();

                var encryptedMD5Pas = Encryptor.MD5Hash(user.UserPass);
                user.UserPass = encryptedMD5Pas;

                long id = dao.Them(user);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm user không thành công !");
                }
            }
            return(View("Index"));
        }
コード例 #11
0
ファイル: UserController.cs プロジェクト: AnhTu512/dat_tour
        public ActionResult Edit(TaiKhoan user)
        {
            if (ModelState.IsValid)
            {
                var dao = new TaiKhoanDao();
                if (!string.IsNullOrEmpty(user.UserPass))
                {
                    var encryptedMD5Pas = Encryptor.MD5Hash(user.UserPass);
                    user.UserPass = encryptedMD5Pas;
                }
                var result = dao.CapNhat(user);

                if (result)
                {
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật user không thành công !");
                }
            }
            return(View("Index"));
        }
コード例 #12
0
        public JsonResult DangKy(ThongTinDangKyTaiKhoan tk)
        {
            TaiKhoanDao tkd = new TaiKhoanDao();

            if (tkd.DangKyTaiKhoan(tk.TenDangNhap, tk.MatKhau) == true && ModelState.IsValid)
            {
                KhachHangDao khd = new KhachHangDao();
                if (khd.ThemKhachHang(tk) == true)
                {
                    return(Json(new
                    {
                        status = true
                    }));
                }
            }
            else
            {
                ModelState.AddModelError("", "Tài khoản đã tồn tại");
            }
            return(Json(new
            {
                status = false
            }));
        }
コード例 #13
0
 public bool CreateNewAccount(TaiKhoanDto _taiKhoan)
 {
     return(TaiKhoanDao.CreateNewAccount(_taiKhoan));
 }
コード例 #14
0
ファイル: UserController.cs プロジェクト: AnhTu512/dat_tour
        public ActionResult Edit(int id)
        {
            var user = new TaiKhoanDao().ViewDetail(id);

            return(View(user));
        }
コード例 #15
0
 public TaiKhoanDto Login(string username, string password)
 {
     return(TaiKhoanDao.Login(username, password));
 }
コード例 #16
0
 public bool Delete(int id)
 {
     return(TaiKhoanDao.Delete(id));
 }
コード例 #17
0
ファイル: AccountController.cs プロジェクト: tho2503/CDIO4
        public ActionResult Edit(string tendn)
        {
            var acc = new TaiKhoanDao().GetByUserName(tendn);

            return(View(acc));
        }