public Employee(decimal aEmployeeID, string aFirstName, string aLastName, int aEmployeeType) { ID = aEmployeeID; FirstName = aFirstName; LastName = aLastName; EmployeeType = (EmployeeTypeEnum)aEmployeeType; //Casting the employeetype from an integer -> enum makes it more clear what type of staff this employee is }
protected Employee(int id, string name, EmployeeTypeEnum type, decimal bonus) { ID = id; Name = name; Type = type; Bonus = bonus; }
public async Task DeleteEmployee(string loggedUserId, EmployeeTypeEnum loggedUserType, string employeeId, string employeeConcurrencyToken) { if (loggedUserId == employeeId) { throw new ArgumentException("Cannot delete logged user."); } if (loggedUserType == EmployeeTypeEnum.User) { throw new AdminRoleRequiredException(); } var employee = await _context.Users.FindAsync(employeeId); if (employee == null) { return; } if (employee.EmployeeType == EmployeeTypeEnum.MasterAdmin) { throw new ArgumentException("Master admin cannot be deleted."); } if (employee.ConcurrencyStamp != employeeConcurrencyToken) { throw new ValuesChangedByAnotherUserException(); } _context.Users.Remove(employee); await _context.SaveChangesAsync(); }
private async Task <Employee> addNewUserInfo(EmployeeTypeEnum loggedUserType, NewUserInfoDTO newUserInfoDTO) { if (loggedUserType == EmployeeTypeEnum.User) { throw new AdminRoleRequiredException(); } var newEmployeeInfo = new Employee { UserName = newUserInfoDTO.Email, FirstName = newUserInfoDTO.FirstName, LastName = newUserInfoDTO.LastName, Email = newUserInfoDTO.Email, EmployeeType = newUserInfoDTO.Type }; IdentityResult result = await _userManager.CreateAsync(newEmployeeInfo, newUserInfoDTO.NewPassword); if (result.Succeeded) { await _userManager.AddToRoleAsync(newEmployeeInfo, RoleUtil.GetRoleFromEmployeeType(newEmployeeInfo.EmployeeType)); } else { // this will be duplicate username in this case throw new ArgumentException(result.Errors.FirstOrDefault().Description); } return(newEmployeeInfo); }
public static string EmployeeTypeDisplay(EmployeeTypeEnum employeeType) { switch (employeeType) { case EmployeeTypeEnum.PracticeEmployee: return("实习"); case EmployeeTypeEnum.ProbationEmployee: return("试用"); case EmployeeTypeEnum.NormalEmployee: return("正式"); case EmployeeTypeEnum.PartTimeEmployee: return("兼职"); case EmployeeTypeEnum.DimissionEmployee: return("离职"); case EmployeeTypeEnum.BorrowedEmployee: return("借用"); case EmployeeTypeEnum.Retirement: return("退休"); case EmployeeTypeEnum.RetirementHire: return("退聘"); case EmployeeTypeEnum.WorkEmployee: return("劳务"); default: return(""); } }
/// <summary> /// 根据条件获得员工基本信息列表 /// </summary> /// <returns></returns> public List <Employee> GetEmployeeBasicInfoByBasicCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, int employeestatus, int companyID) { List <Employee> employeeList = GetEmployeeBasicInfoByBasicCondition(employeeName, employeeType, positionID, departmentID, recursionDepartment, employeestatus, null); if (companyID != -1) { for (int i = 0; i < employeeList.Count; i++) { if (employeeList[i] != null && employeeList[i].EmployeeDetails != null && employeeList[i].EmployeeDetails.Work != null && employeeList[i].EmployeeDetails.Work.Company != null && employeeList[i].EmployeeDetails.Work.Company.Id != companyID) { employeeList.RemoveAt(i); i--; } } } return(employeeList); }
/// <summary> /// 根据条件获得员工基本信息列表 /// </summary> /// <param name="employeeName"></param> /// <param name="employeeType"></param> /// <param name="positionID"></param> /// <param name="departmentID"></param> /// <param name="recursionDepartment"></param> /// <returns></returns> /// <param name="employeestatus"></param> public List <Employee> GetEmployeeBasicInfoByBasicCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, int employeestatus, int?gradeId = null) { List <Employee> employeeList = new List <Employee>(); List <Account> accountList = _IAccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID, gradeId, recursionDepartment, null); foreach (Account account in accountList) { Employee employee = GetEmployeeBasicInfoByAccountID(account.Id); if (employee == null) { continue; } if (employeeType != EmployeeTypeEnum.All && employeeType != employee.EmployeeType) { continue; } if (!employee.IsNeedEmployeeStatusCondition(employeestatus)) { continue; } employeeList.Add(employee); } return(employeeList); }
/// <summary> /// 查询 /// </summary> public void ExecutEvent(string letter) { if (!ValidateFrom() || !ValidateTo()) { } else { try { _View.ErrorMessage = string.Empty; EmployeeTypeEnum employeetype = EmployeeTypeUtility.GetEmployeeTypeByID(Convert.ToInt32(_View.EmployeeType)); //_EmployeeList = // _IEmployeeFacade.GetEmployeeByBasicConditionAndFirstLetter(_View.EmployeeName, employeetype, // _View.PositionId, _View.DepartmentId, // _View.RecursionDepartment, // letter); //20090807 修改查询条件 by liudan _EmployeeList = _IEmployeeFacade.GetEmployeeByBasicConditionWithFirstLetterAndCompanyAge(_View.EmployeeName, employeetype, _View.PositionId, _View.DepartmentId, _View.RecursionDepartment, letter, AgeFrom, AgeTo, Convert.ToInt32(_View.EmployeeStatusId)); _EmployeeList = HrmisUtility.RemoteUnAuthEmployee(_EmployeeList, AuthType.HRMIS, _Operator, HrmisPowers.A401); List <Employee> emplyees = new List <Employee>(); foreach (Employee emplyee in _EmployeeList) { //根据所属公司id,得到所属公司名称 Employee temp = emplyee; if (temp.EmployeeDetails == null || temp.EmployeeDetails.Work == null || temp.EmployeeDetails.Work.Company == null) { } else { //todo noted by wsl transfer waiting for modify temp.EmployeeDetails.Work.Company = _IDepartmentBll.GetDepartmentById( temp.EmployeeDetails.Work.Company.Id, new Account()); } temp.EmployeeDetails = temp.EmployeeDetails ?? new EmployeeDetails(); temp.EmployeeDetails.Work = temp.EmployeeDetails.Work ?? new Work(); temp.EmployeeDetails.Work.Company = temp.EmployeeDetails.Work.Company ?? new Department(); emplyees.Add(temp); } _CardView.Employees = emplyees; _View.ErrorMessage = "<span class='font14b'>共查到 </span>" + "<span class='fontred'>" + _EmployeeList.Count + "</span>" + "<span class='font14b'> 条信息</span>"; } catch (Exception ex) { _View.ErrorMessage = "<span class='fontred'>" + ex.Message + "</span>"; } } }
//public decimal GetAvailableAdjustRestDaysByEmployeeID(int employeeID) //{ // return new GetAdjustRest().GetAvailableAdjustRestDaysByEmployeeID(employeeID); //} public List <AdjustRest> GetAdjustRestByCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, Account _operator, int?powers, int employeeStatus) { return (new GetAdjustRest().GetAdjustRestByCondition(employeeName, employeeType, positionID, departmentID, recursionDepartment, _operator, powers, employeeStatus)); }
public List <Account> GetAssessActivityForHRApply(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, Account loginUser) { return(new GetAssessActivity().GetAssessActivityForHRApply(employeeName, employeeType, positionID, departmentID, recursionDepartment, loginUser)); }
///<summary> ///</summary> ///<param name="employeeName"></param> ///<param name="departmentID"></param> ///<param name="positionID"></param> ///<param name="EmployeeTypeEnum"></param> ///<param name="loginUser"></param> ///<returns></returns> public List <EmployeeSalary> GetEmployeeAccountSetByCondition(string employeeName, int departmentID, int positionID, EmployeeTypeEnum EmployeeTypeEnum, bool recursionDepartment, Account loginUser, int employeeStatus) { GetEmployeeAccountSet getEmployeeAccountSet = new GetEmployeeAccountSet(); return (getEmployeeAccountSet.GetEmployeeAccountSetByCondition(employeeName, departmentID, positionID, EmployeeTypeEnum, recursionDepartment, loginUser, employeeStatus)); }
/// <summary> /// 员工构造函数 /// </summary> /// <param name="account"></param> /// <param name="email"></param> /// <param name="email2"></param> /// <param name="type"></param> /// <param name="position"></param> /// <param name="department"></param> public Employee(Account account, string email, string email2, EmployeeTypeEnum type, Position position, Department department) { _Account = account; _Account.Email1 = email; _Account.Email2 = email2; _Account.Position = position; _Account.Dept = department; _EmployeeType = type; }
/// <summary> /// 根据条件获得员工基本信息列表 /// </summary> /// <returns></returns> public List <Employee> GetEmployeeBasicInfoByBasicCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, int employeestatus, int companyID) { return(new GetEmployee().GetEmployeeBasicInfoByBasicCondition(employeeName, employeeType, positionID, departmentID, recursionDepartment, employeestatus, companyID)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="employeeName"></param> /// <param name="departmentID"></param> /// <param name="positionID"></param> /// <param name="employeeType"></param> /// <param name="isRecursionDepartment"></param> /// <param name="accountOperator"></param> /// <param name="employeeStatus"></param> public ExportEmployeeAccountSet(string employeeName, int departmentID, int positionID, EmployeeTypeEnum employeeType, bool isRecursionDepartment, Account accountOperator, int employeeStatus) { _EmployeeName = employeeName; _DepartmentID = departmentID; _PositionID = positionID; _IsRecursionDepartment = isRecursionDepartment; _EmployeeTypeEnum = employeeType; _AccountOperator = accountOperator; _EmployeeStatus = employeeStatus; }
public override void BindGridView() { EmployeeTypeEnum employeetype = EmployeeTypeUtility.GetEmployeeTypeByID(Convert.ToInt32(_View.EmployeeType)); var employees = EmployeeLogic.GetEmployeeBasicInfoByBasicConditionRetModel(_View.EmployeeName, employeetype, _View.PositionId, null, _View.DepartmentId, null, _View.RecursionDepartment, HrmisPowers.A703, LoginUser.Id, -1, null, null); _View.Employees = employees.Select(x => x.Account).ToList(); // InstanceFactory.AssessActivityFacade().GetAssessActivityForHRApply(_View.EmployeeName, employeetype, _View.PositionId, _View.DepartmentId, _View.RecursionDepartment, LoginUser); }
private async Task <CalendarEntry> addCalendarEntry(EmployeeTypeEnum loggedUserType, CalendarEntryDTO entryDTO) { var entry = new CalendarEntry { StartDate = entryDTO.StartDate, EndDate = entryDTO.EndDate, VacationType = entryDTO.VacationType, EmployeeId = entryDTO.EmployeeId }; _context.CalendarEntries.Add(entry); return(entry); }
public static List <EmployeeEntity> GetEmployeeBasicInfoByBasicCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int?gradesID, int departmentID, bool recursionDepartment, int?powerID, int?accountID, int employeeStatus, List <int> notInEmployeeType) { return(EmployeeDA.GetEmployeeBasicInfoByBasicCondition(employeeName, (int)employeeType, positionID, gradesID, null, DepartmentLogic.GetDepartmentids(departmentID, recursionDepartment), powerID == null ? null : AccountAuthDA.GetAccountAuthDepartment(accountID.Value, powerID.Value), employeeStatus, notInEmployeeType, null)); }
/// <summary> /// 根据条件获得员工基本信息列表及公司工龄 add by liudan 2009-08-07 /// </summary> public List <Employee> GetEmployeeBasicInfoByBasicConditionWithCompanyAge(string employeeName, EmployeeTypeEnum employeeType, int positionID, int?gradesID, int departmentID, int?CompanyAgeFrom, int?CompanyAgeTo, bool recursionDepartment, int employeeStatus) { List <Employee> employeeList = new List <Employee>(); //List<Account> accountList = // _IAccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID,gradesID, recursionDepartment, null); //foreach (Account account in accountList) //{ // Employee employee = GetEmployeeBasicInfoByAccountID(account.Id); // if (employee == null) // { // continue; // } // if (employeeType != EmployeeTypeEnum.All && employeeType != employee.EmployeeType) // { // continue; // } // if (!employee.IsNeedEmployeeStatusCondition(employeeStatus)) // { // continue; // } // TimeSpan ts = DateTime.Today.Subtract(employee.EmployeeDetails.Work.ComeDate); // int days = Convert.ToInt32(ts.TotalDays); // if ((CompanyAgeFrom != null && days < CompanyAgeFrom)) // { // continue; // } // if ((CompanyAgeTo != null && days > CompanyAgeTo)) // { // continue; // } // employeeList.Add(employee); //} var list = EmployeeLogic.GetEmployeeBasicInfoByBasicConditionWithCompanyAge(employeeName, employeeType, positionID, gradesID, departmentID, CompanyAgeFrom, CompanyAgeTo, recursionDepartment, employeeStatus); foreach (var e in list) { employeeList.Add(EmployeeEntity.Convert(e)); } return(employeeList); }
public async Task DeleteCalendarEntry(string loggedUserId, EmployeeTypeEnum loggedUserType, CalendarEntryDTO entryDTO) { var entry = await _context.CalendarEntries.FindAsync(entryDTO.Id); if (entry == null) { return; } if (entry.EmployeeId != loggedUserId && loggedUserType == EmployeeTypeEnum.User) { throw new AdminRoleRequiredException(); } validateConcurrencyStamp(entryDTO, entry); _context.CalendarEntries.Remove(entry); await _context.SaveChangesAsync(); }
public static string GetRoleFromEmployeeType(EmployeeTypeEnum employeeType) { switch (employeeType) { case EmployeeTypeEnum.User: return(EmployeeRoles.User); case EmployeeTypeEnum.Admin: return(EmployeeRoles.Admin); case EmployeeTypeEnum.MasterAdmin: return(EmployeeRoles.MasterAdmin); default: return(EmployeeRoles.User); } }
private async Task <Employee> updateUserInfo(string loggedUserId, EmployeeTypeEnum loggedUserType, NewUserInfoDTO newUserInfoDTO) { if (newUserInfoDTO.Id != loggedUserId && loggedUserType == EmployeeTypeEnum.User) { throw new AdminRoleRequiredException(); } var oldUserInfo = await _context.Users.FindAsync(newUserInfoDTO.Id); if (oldUserInfo == null) { throw new ArgumentException("User was deleted by someone else."); } if (oldUserInfo.ConcurrencyStamp != newUserInfoDTO.ConcurrencyStamp) { throw new ValuesChangedByAnotherUserException(); } oldUserInfo.FirstName = newUserInfoDTO.FirstName; oldUserInfo.LastName = newUserInfoDTO.LastName; oldUserInfo.UserName = newUserInfoDTO.Email; oldUserInfo.Email = newUserInfoDTO.Email; if (!string.IsNullOrEmpty(newUserInfoDTO.NewPassword)) { var passwordResult = await _userManager.PasswordValidators.FirstOrDefault().ValidateAsync(_userManager, oldUserInfo, newUserInfoDTO.NewPassword); if (!passwordResult.Succeeded) { throw new ArgumentException(passwordResult.Errors.FirstOrDefault()?.Description); } oldUserInfo.PasswordHash = _userManager.PasswordHasher.HashPassword(oldUserInfo, newUserInfoDTO.NewPassword); } IdentityResult result = await _userManager.UpdateAsync(oldUserInfo); if (result.Succeeded) { return(oldUserInfo); } else { // this will be duplicate username in this case throw new ArgumentException(result.Errors.FirstOrDefault().Description); } }
private async Task <CalendarEntry> updateCalendarEntry(string loggedUserId, EmployeeTypeEnum loggedUserType, CalendarEntryDTO entryDTO) { var entry = await _context.CalendarEntries.FindAsync(entryDTO.Id); if (entry == null) { throw new ArgumentException("Entry was deleted by someone else."); } validateConcurrencyStamp(entryDTO, entry); entry.StartDate = entryDTO.StartDate; entry.EndDate = entryDTO.EndDate; entry.VacationType = entryDTO.VacationType; entry.EmployeeId = entryDTO.EmployeeId; return(entry); }
/// <summary> /// 为HR获取可申请考核的员工 /// </summary> public List <Account> GetAssessActivityForHRApply(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, Account loginUser) { List <Account> retaccount = new List <Account>(); Auth myAuth = loginUser.FindAuth(AuthType.HRMIS, HrmisPowers.A703); if (myAuth == null) { throw new ApplicationException("没有权限访问"); } List <Account> accounts = RemoveInvalidationAccount( _AccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID, null, recursionDepartment, null)); foreach (Account account in accounts) { Employee employee = new GetEmployee().GetEmployeeByAccountID(account.Id); if (employee == null) { continue; } if (employeeType == EmployeeTypeEnum.All || employeeType == employee.EmployeeType) { retaccount.Add(account); } } if (myAuth.Departments.Count == 0) { return(retaccount); } for (int i = retaccount.Count - 1; i >= 0; i--) { if (!SEP.Model.Utility.Tools.IsDeptListContainsDept(myAuth.Departments, retaccount[i].Dept)) { retaccount.RemoveAt(i); } } return(retaccount); }
/// <summary> /// 根据条件获取员工所有信息,条件包括:员工首字符筛选 /// </summary> /// <param name="employeeName"></param> /// <param name="employeeType"></param> /// <param name="positionId"></param> /// <param name="departmentId"></param> /// <param name="recursionDepartment"></param> /// <param name="firstLetter"></param> /// <returns></returns> public List <Employee> GetEmployeeByBasicConditionAndFirstLetter(string employeeName, EmployeeTypeEnum employeeType, int positionId, int departmentId, bool recursionDepartment, string firstLetter) { List <Employee> employeeList = new List <Employee>(); List <Account> accountList = _IAccountBll.GetEmployeeByBasicConditionAndFirstLetter(employeeName, positionId, departmentId, recursionDepartment, firstLetter); foreach (Account account in accountList) { Employee employee = GetEmployeeByAccountID(account.Id); if (employee == null) { continue; } if (employeeType == EmployeeTypeEnum.All || employeeType == employee.EmployeeType) { employeeList.Add(employee); } } return(employeeList); }
/// <summary> /// 查询 /// </summary> public void ExecutEvent() { try { _ItsView.ResultMessage = string.Empty; EmployeeTypeEnum employeetype = EmployeeTypeUtility.GetEmployeeTypeByID(Convert.ToInt32(_ItsView.EmployeeType)); _EmployeeSalaryList = _IEmployeeAccountSetFacade.GetEmployeeAccountSetByCondition(_ItsView.EmployeeName, _ItsView.DepartmentId, _ItsView.PositionId, employeetype, _ItsView.RecursionDepartment, _LoginUser, Convert.ToInt32(_ItsView.EmployeeStatusId)); _ItsView.EmployeeAccountSetList = _EmployeeSalaryList; _ItsView.ResultMessage = "<span class='font14b'>共查到 </span>" + "<span class='fontred'>" + _EmployeeSalaryList.Count + "</span>" + "<span class='font14b'> 条信息</span>"; } catch (Exception ex) { _ItsView.ResultMessage = "<span class='fontred'>" + ex.Message + "</span>"; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { EmployeeTypeEnum empType = (EmployeeTypeEnum)value; switch (empType) { case EmployeeTypeEnum.CEO: return(Brushes.Aqua); case EmployeeTypeEnum.EngDirector: return(Brushes.Green); case EmployeeTypeEnum.Engineer: return(Brushes.Red); case EmployeeTypeEnum.VicePres: return(Brushes.Blue); default: return(Brushes.Black); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { EmployeeTypeEnum empType = (EmployeeTypeEnum)value; switch (empType) { case EmployeeTypeEnum.CEO: return(new Uri("/ceo.png", UriKind.Relative)); case EmployeeTypeEnum.EngDirector: return(new Uri("/director.png", UriKind.Relative)); case EmployeeTypeEnum.Engineer: return(new Uri("/engineer.png", UriKind.Relative)); case EmployeeTypeEnum.VicePres: return(new Uri("/vicepres.png", UriKind.Relative)); default: return(null); } }
public static List <Employee> GetEmployeeBasicInfoByBasicConditionRetModel(string employeeName, EmployeeTypeEnum employeeType, int positionID, int?gradesID, int departmentID, int?companyID, bool recursionDepartment, int?powerID, int?accountID, int employeeStatus, List <int> notInEmployeeType, bool?hasPlanDuty = null) { List <EmployeeEntity> list = EmployeeDA.GetEmployeeBasicInfoByBasicCondition(employeeName, (int)employeeType, positionID, gradesID, companyID, DepartmentLogic.GetDepartmentids(departmentID, recursionDepartment), powerID == null ? null : AccountAuthDA.GetAccountAuthDepartment(accountID.Value, powerID.Value), employeeStatus, notInEmployeeType, hasPlanDuty); var employeeList = new List <Employee>(); foreach (EmployeeEntity employeeEntity in list) { employeeList.Add(EmployeeEntity.Convert(employeeEntity)); } return(employeeList); }
/// <summary> /// 根据条件获得员工所有信息列表 /// </summary> /// <param name="employeeName"></param> /// <param name="employeeType"></param> /// <param name="positionID"></param> /// <param name="departmentID"></param> /// <param name="recursionDepartment"></param> /// <returns></returns> public List <Employee> GetEmployeeByBasicCondition(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment) { List <Employee> employeeList = new List <Employee>(); List <Account> accountList = _IAccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID, null, recursionDepartment, null); foreach (Account account in accountList) { Employee employee = GetEmployeeByAccountID(account.Id); if (employee == null) { continue; } if (employeeType == EmployeeTypeEnum.All || employeeType == employee.EmployeeType) { //employee.Account.Dept = _IDepartmentBll.GetDepartmentById(employee.Account.Dept.Id, null); employeeList.Add(employee); } } return(employeeList); }
} //For EF private EmployeeTypes(EmployeeTypeEnum @enum) { this.Id = (long)@enum; this.EmployeeTypeName = @enum.ToString(); }