public ActionResult Login(string email = "", string password = "")
        {
            if (Request.HttpMethod == "GET")
            {
                return(View());
            }
            else
            {
                var userAccount = UserAccountBLL.Authorize(email, ConvertMD5.GetMD5(password), UserAccountTypes.Employee);
                if (userAccount != null)
                {
                    WebUserData cookieData = new Admin.WebUserData()
                    {
                        UserID    = userAccount.UserID,
                        FullName  = userAccount.FullName,
                        GroupName = userAccount.GroupName,
                        LoginTime = DateTime.Now,
                        SessionID = Session.SessionID,
                        ClientIP  = Request.UserHostAddress,
                        Photo     = userAccount.Photo
                    };
                    FormsAuthentication.SetAuthCookie(cookieData.ToCookieString(), false);
                    return(RedirectToAction("Index", "Dashboard"));
                }
                else
                {
                    ModelState.AddModelError("", "Đăng nhập thất bại!");
                    ViewBag.Email = email;

                    return(View());
                }
            }
        }
        public ActionResult ChangePwd(string oldpass, string newpass, string confirmpass)
        {
            WebUserData userData = User.GetUserData();
            Account     account  = AccountBLL.GetPassByEmail(userData.UserID);

            if (string.IsNullOrEmpty(oldpass))
            {
                ModelState.AddModelError("old", "Old Password is required");
                return(View());
            }
            if (string.IsNullOrEmpty(newpass))
            {
                ModelState.AddModelError("new", "New Password is required");
                return(View());
            }
            if (string.IsNullOrEmpty(oldpass))
            {
                ModelState.AddModelError("confirm", "Confirm Password is required");
                return(View());
            }


            if (string.Equals(account.Password, ConvertMD5.GetMD5(oldpass)))
            {
                if (newpass.Equals(confirmpass))
                {
                    bool updateResult = AccountBLL.UpdatePass(ConvertMD5.GetMD5(newpass), userData.UserID);
                    if (updateResult)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("check", "The passwords do not match");
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("oldfalse", "The Old passwords incorrect");
                return(View());
            }
        }
        public ActionResult Input(Employee model, HttpPostedFileBase uploadPhoto)
        {
            try
            {
                //kiem tra tinh hop le
                if (string.IsNullOrEmpty(model.FirstName))
                {
                    ModelState.AddModelError("FirstName", "First Name is required");
                }
                if (string.IsNullOrEmpty(model.LastName))
                {
                    ModelState.AddModelError("LastName", "Last Name is required");
                }
                if (string.IsNullOrEmpty(model.Password))
                {
                    ModelState.AddModelError("Password", "Password is required");
                }
                if (string.IsNullOrEmpty(model.City))
                {
                    ModelState.AddModelError("City", "City is required");
                }
                if (string.IsNullOrEmpty(model.Country))
                {
                    ModelState.AddModelError("Country", "Country is required");
                }
                if (string.IsNullOrEmpty(model.Email))
                {
                    ModelState.AddModelError("Email", "Email is required");
                }
                if (string.IsNullOrEmpty(model.Address))
                {
                    model.Address = "";
                }
                if (string.IsNullOrEmpty(model.HomePhone))
                {
                    model.HomePhone = "";
                }
                if (string.IsNullOrEmpty(model.Title))
                {
                    model.Title = "";
                }
                if (string.IsNullOrEmpty(model.Notes))
                {
                    model.Notes = "";
                }
                if (string.IsNullOrEmpty(model.PhotoPath))
                {
                    model.PhotoPath = "";
                }

                if (!ConvertMD5.IsMD5(model.Password))
                {
                    model.Password = ConvertMD5.GetMD5(model.Password);
                }
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                if (model.EmployeeID == 0)
                {
                    if (uploadPhoto != null)
                    {
                        string filePath = Path.Combine(Server.MapPath("~/Images"), uploadPhoto.FileName);
                        model.PhotoPath = uploadPhoto.FileName;
                        uploadPhoto.SaveAs(filePath);
                        int employeeID = HumanResourceBLL.Employee_Add(model);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        model.PhotoPath = "";
                        int employeeID = HumanResourceBLL.Employee_Add(model);
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    if (uploadPhoto != null)
                    {
                        string filePath = Path.Combine(Server.MapPath("~/Images"), uploadPhoto.FileName);
                        model.PhotoPath = uploadPhoto.FileName;
                        uploadPhoto.SaveAs(filePath);
                        bool rs = HumanResourceBLL.Employee_Update(model);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        Employee employee = HumanResourceBLL.Employee_Get(model.EmployeeID);
                        model.PhotoPath = employee.PhotoPath;
                        bool rs = HumanResourceBLL.Employee_Update(model);
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace);
                return(View(model));
            }
        }