public ActionResult ShowSubScreenRegisterOffWork(string sType)
        {
            HomeModels home = new HomeModels();

            ViewData["type"] = sType;
            DataTable dtSource = ADConfigValueUtility.InitConfigValueTable("EmployeeOffWorkShiftType");

            ViewData["ModalTitle"]           = "Thông tin đăng ký nghỉ phép";
            ViewData["lstEmployeeLeaveType"] = home.GetEmployeeLeaveTypes();
            ViewData["objEmployeeOffWork"]   = new HREmployeeOffWorksInfo();
            ViewData["lstShiftTypeCombo"]    = Helpers.HtmlControls.GetDropDownListObjects(dtSource, "Value", "Text");
            HREmployeesInfo objCurrent = GMCWebApp.GetEmployeeByUserName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));

            if (objCurrent != null)
            {
                dtSource = new HREmployeesController().GetDataTableByDataSet(new HREmployeesController().GetAllDataByForeignColumn("FK_HREmployeeManagerID", objCurrent.HREmployeeID));
                if (dtSource == null)
                {
                    dtSource = new DataTable();
                }
                DataRow dr = dtSource.NewRow();
                if (dtSource.Columns.Contains("HREmployeeID"))
                {
                    dr.SetField("HREmployeeID", objCurrent.HREmployeeID);
                }
                if (dtSource.Columns.Contains("HREmployeeFullName"))
                {
                    dr.SetField("HREmployeeFullName", objCurrent.HREmployeeFullName);
                }
                dtSource.Rows.InsertAt(dr, 0);
            }
            ViewData["EmployeeID"]  = objCurrent.HREmployeeID;
            ViewData["lstEmployee"] = Helpers.HtmlControls.GetDropDownListObjects(dtSource, "HREmployeeID", "HREmployeeFullName");
            foreach (KeyValuePair <string, double> item in home.GetTonPhepTheoNhanVien(objCurrent))
            {
                ViewData[item.Key] = item.Value;
            }
            return(PartialView("ShowSubScreenRegisterOffWork"));
        }
Example #2
0
        public static string LogIn(string strSrv, string strUser, string strPassword, System.DateTime dt)
        {
            ConnectionAuth(strSrv);
            if (!SqlDatabaseHelper.TestConnection())
            {
                return("Không kết nối được CSDL! Vui lòng liên hệ người quản trị!");
            }
            ADUsersController ADUserCtrl = new ADUsersController();

            CurrenUserInfo = (ADUsersInfo)ADUserCtrl.GetObjectByName(strUser);
            ADUserConfigsInfo UserCfgInfo = new ADUserConfigsController().GetFirstObject() as ADUserConfigsInfo;

            GMCWebApp.GetLocalMachineInfo();
            if (CurrenUserInfo != null && CurrenUserInfo.ADUserIsLockedCheck)
            {
                return("Tài khoản đăng nhập này đã bị khóa! Vui lòng liên hệ người quản trị!");
            }
            else if (IsUserLoggedIn(strUser))
            {
                GEUserAuditsInfo UserAudisInfo = new GEUserAuditsController().GetGEUserAuditsByADUserName(strUser);
                return(string.Format("Người dùng này đã đăng nhập trên máy {0} với địa chỉ IP {1}!", UserAudisInfo.GEUserAuditPCName, UserAudisInfo.GEUserAuditIP));
            }
            else if (IsAuthenticated(strUser, strPassword))
            {
                if (!new ADUserGroupsController().IsExist(CurrenUserInfo.ADUserGroupID))
                {
                    return(string.Format("Nhóm người dùng của tài khoản {0} không tồn tại trên hệ thống!", strUser));
                }
                else
                {
                    SetCurrentUserLogin(dt);
                    SaveUserAuditLogin("Login");
                    if (UserCfgInfo != null && UserCfgInfo.ADUserConfigPassDayExpires > 0)
                    {
                        if (new ADUserPassHistorysController().IsOldPassExpired(CurrenUserInfo.ADUserID, UserCfgInfo.ADUserConfigPassDayExpires))
                        {
                            return("Mật khẩu đã hết hạn! Vui lòng đổi mật khẩu mới!");
                        }
                    }
                }
            }
            else
            {
                int iCountLoginFail = new GEUserAuditsController().GetCountLoginFail(strUser, "WebHome", dt);
                iCountLoginFail++;
                if (UserCfgInfo != null && (iCountLoginFail >= UserCfgInfo.ADUserConfigMaxLogonCount) && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    SaveUserAuditLogin("LoginFailLock", 0, strUser);
                    if (CurrenUserInfo != null)
                    {
                        CurrenUserInfo.ADUserIsLockedCheck = true;
                        CurrenUserInfo.ADUserLockedInfo    = Environment.MachineName + ", " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                        ADUserCtrl.UpdateObject(CurrenUserInfo, true, "ADUserIsLockedCheck", "ADUserLockedInfo");
                    }
                    return(string.Format("Vượt quá số lần đăng nhập sai cho phép! Tài khoản đăng nhập {0} đã bị khóa", strUser));
                }
                SaveUserAuditLogin("LoginFail", 0, strUser);
                string strError = "Tên đăng nhập/ Mật khẩu không hợp lệ!";
                if (UserCfgInfo != null && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    strError += string.Format(" Còn lại {0} lần thử", UserCfgInfo.ADUserConfigMaxLogonCount - iCountLoginFail);
                }
                return(strError);
            }
            ADConfigValueUtility.InitGlobalConfigValueTables();
            return("");
        }