private void PopulateGeneralInfoSection(EmployeeDC emp) { this.gFirstName.Text = emp.FirstName; this.gFirstName.Modified = false; this.gLastName.Text = emp.LastName; this.gLastName.Modified = false; this.gEmail.Text = emp.Email; this.gEmail.Modified = false; this.gGender.SelectedValue = emp.Gender; this.gOnboard.Value = emp.OnboardDate; this.gTitleDisplay.Text = emp.CurrentTitle.GetDisplayName(); this.gLevelDisplay.Text = emp.CurrentLevel.GetDisplayName(); this.gSalaryDisplay.Text = emp.CurrentSalary.ToString("C0"); this.gManagerDisplay.Text = emp.ManagerName; this.YofEmpValue.Text = emp.YearOfEmployment.ToString(); if (emp.ResignDate == null) { this.ReviewInfo.Text = '\u26a0' + " Next performance review on " + ((DateTime)emp.NextReviewDate).ToShortDateString(); this.ReviewInfo.ForeColor = Color.Black; } else { this.ReviewInfo.Text = "Resigned on " + ((DateTime)emp.ResignDate).ToShortDateString(); this.ReviewInfo.ForeColor = Color.Red; } }
/// <summary> /// Revert changes from general info section /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GeneralInfoRevertBtnClickedHandler(object sender, EventArgs e) { if (initializationCompleted) { Guid id = (Guid)this.employeeListContainer.FocusedItem.Tag; EmployeeDC emp = empRepo.GetEmployee(id); PopulateGeneralInfoSection(emp); DisableGeneralInfoBtns(); } }
/// <summary> /// Create new employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateBtnClickedHandler(object sender, EventArgs e) { Gender newGender = (Gender)this.gender.SelectedValue; Title newTitle = (Title)this.title.SelectedValue; Level newLevel = (Level)this.level.SelectedValue; EmployeeDC newEmployee = empRepo.CreateEmployee((Guid)this.manager.SelectedValue, this.frstName.Text, this.lastName.Text, newGender, this.email.Text, newTitle, newLevel, this.salary.Value, this.bonus.Value, this.onboard.Value); newEmployeeId = newEmployee.Id; newEmployeeTitle = newEmployee.CurrentTitle; this.Close(); }
/// <summary> /// Populate employee general info when selected from the list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CurrentEmployeeSelectionChangedHandler(object sender, ListViewItemSelectionChangedEventArgs e) { if (initializationCompleted) { UnlockGeneralInfoSection(); Guid id = (Guid)e.Item.Tag; EmployeeDC emp = empRepo.GetEmployee(id); PopulateGeneralInfoSection(emp); PopulateHistorySection(emp); DisableGeneralInfoBtns(); UnlockHistory(); } }
public NewHistoryWindow(EmployeeDC emp) { empRepo = new EmployeeRepository(); viewHelper = new ViewGeneratorHelper(empRepo); InitializeComponent(); InitializeState(); this.currentEmployeeId = emp.Id; this.title.SelectedItem = emp.CurrentTitle; this.level.SelectedItem = emp.CurrentLevel; this.salary.Value = emp.CurrentSalary; this.bonus.Value = 0; this.manager.SelectedValue = emp.CurrentManager.Id; }
public EmployeeDC ConvertToDataContract(EmployeeRepository empRepo) { var ret = new EmployeeDC(); // Safe check since the conversion relies on info in DB if (Id == Guid.Empty) { throw new Exception("Employee must be already persisted in db."); } ret.Id = Id; ret.FirstName = FirstName; ret.LastName = LastName; ret.Gender = Gender; ret.Email = Email; ret.OnboardDate = OnboardDate; IEnumerable <StatusChangeHistory> histories = empRepo.GetEmployeeHistoryRaw(Id); var HistoryList = new List <StatusChangeHistoryDC>(); foreach (var his in histories) { HistoryList.Add(his.ConvertToDataContract(empRepo)); } ret.History = HistoryList; Guid managerId = ret.History.OrderBy(his => his.Date).Last().ManagerId; ret.CurrentManager = managerId == Guid.Empty ? new Employee() { Id = Guid.Empty } : empRepo.GetEmployeeRaw(managerId); ret.CurrentTitle = ret.History.OrderBy(his => his.Date).Last().Title; ret.CurrentLevel = ret.History.OrderBy(his => his.Date).Last().Level; ret.CurrentSalary = ret.History.OrderBy(his => his.Date).Last().Salary; ret.ResignDate = ret.History.LastOrDefault(his => his.Action == ActionType.RESIGN)?.Date; ret.NextReviewDate = GlobalPolicyContainer.AnnualPerformanceReviewPolicy.GetMyNextReviewDate(ret); if (ret.ResignDate == null) { ret.YearOfEmployment = (int)(DateTime.Now - this.OnboardDate).TotalDays / 365 + 1; } else { ret.YearOfEmployment = (int)((DateTime)ret.ResignDate - this.OnboardDate).TotalDays / 365 + 1; } return(ret); }
public ListViewItem[] GetHistoryFromEmployeeView(EmployeeDC emp) { List <ListViewItem> ret = new List <ListViewItem>(); foreach (var his in emp.History) { string title = his.Title.GetDisplayName(); string level = his.Level.GetDisplayName(); string salary = his.Salary.ToString("C0"); string bonus = his.Bonus.ToString("C0"); string manager = his.ManagerName; var item = new ListViewItem(new string[] { his.Date.ToShortDateString(), title, level, salary, bonus, manager, his.Action.GetDisplayName() }); item.Tag = his.Id; ret.Add(item); } return(ret.ToArray()); }
private void CreateHistoryBtnClickedHandler(object sender, EventArgs e) { if (initializationCompleted) { Guid id = (Guid)this.employeeListContainer.FocusedItem.Tag; EmployeeDC emp = empRepo.GetEmployee((Guid)id); using (var newHistoryDlg = new NewHistoryWindow(emp)) { if (newHistoryDlg.ShowDialog() == DialogResult.OK) { EnsureChecked(newHistoryDlg.currentEmployeeTitle); UpdateMainListing(); Guid tmp = newHistoryDlg.currentEmployeeId; SelectEmployee(tmp.ToString()); } } } }
public AnalyticsDC GetAnaltyics(EmployeeRepository empRepo) { IEnumerable <Employee> employees = PersistenceStore.Current.GetEmployeeStore().FindAll(); List <EmployeeDC> source = new List <EmployeeDC>(); foreach (var emp in employees) { EmployeeDC DC = emp.ConvertToDataContract(empRepo); if (DC.ResignDate == null) { source.Add(DC); } } AnalyticsDC ret = new AnalyticsDC(); ret.TotalActiveEmployeeStatistic = (StatisticDC)GetStatisticByTitle(null, source); ret.DEVStatistic = GetStatisticByTitle("DEV", source); ret.QAStatistic = GetStatisticByTitle("QA", source); ret.TPMStatistic = GetStatisticByTitle("TPM", source); ret.UEStatistic = GetStatisticByTitle("UE", source); return(ret); }
public DateTime?GetMyNextReviewDate(EmployeeDC emp) { if (emp.ResignDate != null) { return(null); } StatusChangeHistoryDC lastPerformanceReview = emp.History.LastOrDefault(his => his.Action == Entities.ActionType.ANNUAL_PERFORMANCE_REVIEW); if (lastPerformanceReview == null) { if (emp.OnboardDate.Month <= 6) { return(GetNextReviewDate()); } else { return(GetNextReviewDate().AddYears(1)); } } else { return(GetNextReviewDate()); } }
/// <summary> /// It takes the baseline from the onboard date or the previous review date, to calculate the next review date based on the policy. /// </summary> /// <param name="emp"></param> /// <returns></returns> public DateTime?GetMyNextReviewDate(EmployeeDC emp) { if (emp.ResignDate != null) { return(null); } StatusChangeHistoryDC lastPerformanceReview = emp.History.LastOrDefault(his => his.Action == Entities.ActionType.ANNUAL_PERFORMANCE_REVIEW); if (lastPerformanceReview == null) { // New employee int reviewMonth = 1; int reviewYear = emp.OnboardDate.Year + 1; switch (emp.OnboardDate.Month) { case 1: case 2: case 3: reviewMonth = 4; break; case 4: case 5: case 6: reviewMonth = 7; break; case 7: case 8: case 9: reviewMonth = 10; break; case 10: case 11: case 12: reviewMonth = 1; reviewYear++; break; } return(new DateTime(reviewYear, reviewMonth, 1)); } else { // Employee with at least one previous annual performance review. if (new int[] { 1, 4, 7, 10 }.Contains(lastPerformanceReview.Date.Month)) { // The review was conducted on time last year return(new DateTime(lastPerformanceReview.Date.Year + 1, lastPerformanceReview.Date.Month, 1)); } else { // The review wasn't on time, so that we have to calculate the next review based on onboard date. int reviewMonth = 1; int reviewYear = lastPerformanceReview.Date.Year + 1; switch (emp.OnboardDate.Month) { case 1: case 2: case 3: reviewMonth = 4; break; case 4: case 5: case 6: reviewMonth = 7; break; case 7: case 8: case 9: reviewMonth = 10; break; case 10: case 11: case 12: reviewMonth = 1; break; } return(new DateTime(reviewYear, reviewMonth, 1)); } } }
private void PopulateHistorySection(EmployeeDC emp) { this.historyListContainer.Items.Clear(); this.historyListContainer.Items.AddRange(viewHelper.GetHistoryFromEmployeeView(emp)); this.historyListContainer.Items[this.historyListContainer.Items.Count - 1].EnsureVisible(); }