예제 #1
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new AccountDao();
                var result = dao.loginAccount(model.username, Encryptor.MD5Hash(model.password));
                switch (result)
                {
                //Đăng nhập quyền admin
                case 1:
                {
                    var user        = dao.GetByID(model.username);
                    var userSession = new UserInfo();
                    userSession.Username = user.TenTaiKhoan;
                    userSession.UserID   = user.IDTaiKhoan;
                    Session.Add(Common.CommonConstant.ADMIN_SESSION, userSession);
                    Session["USER_ID"] = userSession.UserID;
                    return(RedirectToAction("Index", "AdminHome"));
                }

                //Đăng nhập quyền người đăng
                case 2:
                {
                    var userId      = dao.GetByID(model.username);
                    var userSession = new UserInfo();
                    userSession.Username = userId.TenTaiKhoan;
                    userSession.UserID   = userId.IDTaiKhoan;
                    Session.Add(Common.CommonConstant.USER_SESSION, userSession);
                    Session["USER_ID"] = userSession.UserID;
                    return(RedirectToAction("Index", "UserHome"));
                }

                //Đăng nhập trường hợp tài khoản bị khóa
                case -1:
                {
                    ModelState.AddModelError("", "Tài khoản này đã bị khóa!");
                    break;
                }

                //Đăng nhập trường hợp sai mật khẩu
                case -2:
                {
                    ModelState.AddModelError("", "Mật khẩu không đúng!");
                    break;
                }

                //Đăng nhập trường hợp sai tên tài khoản
                case 0:
                {
                    ModelState.AddModelError("", "Tài khoản không tồn tại.");
                    break;
                }
                }
            }
            return(View("Index"));
        }
        public ActionResult loginAccount(LoginUserModel model)
        {
            var dao = new AccountDao();

            if (ModelState.IsValid)
            {
                var res = dao.Login(model.UserID.Trim(), model.PassWord);
                if (res == 1)
                {
                    var userSession = new UserLogin();
                    //var checkAu = dao.Login2(tes);

                    var user = dao.GetByID(model.UserID.Trim());
                    userSession.UserID   = user.UserID.Trim();
                    userSession.UserName = user.Username;
                    string idUser = user.UserID.Trim();


                    PostmanService.PostmanServiceSoapClient postman = new PostmanService.PostmanServiceSoapClient();
                    DataTable tb = new DataTable();
                    tb = postman.GetEmpInfomation(idUser);
                    string   depart     = tb.Rows[0]["CURRENT_OU_NAME"].ToString();
                    string   costCode   = tb.Rows[0]["CURRENT_OU_CODE"].ToString();
                    string   mailUs     = tb.Rows[0]["NOTES_ID"].ToString();
                    DateTime checkLeave = DateTime.Parse(tb.Rows[0]["LEAVEDAY"].ToString());
                    DateTime timeCheck  = DateTime.Now;
                    if (timeCheck > checkLeave.AddMinutes(5))
                    {
                        string kq = " da nghi";
                    }
                    userSession.Department = depart;
                    userSession.CostCode   = costCode;
                    userSession.Mail       = mailUs;

                    Session.Add(CommonConstants.USER_SESSION, userSession);

                    return(RedirectToAction("WaitingForYourApproval", "APP_ESIGN", new { area = "Employee" }));
                }
                else
                {
                    var checkAu = dao.Login2(model.UserID.Trim());
                    if (checkAu == 0)
                    {
                        Session["errorLog"] = "Ban khong co quyen vao he thong vui long lien he IT!";
                        return(RedirectToAction("Index", "ErrorPage", new { area = "" }));
                    }
                }
            }
            return(View("Index"));
        }
예제 #3
0
 public AccountObject GetByID(Guid AccountID)
 {
     return(ModelAccont.GetByID(AccountID));
 }
예제 #4
0
 public Account GetByID(int ID)
 {
     return(accountDao.GetByID(ID));
 }