private void UpdateMainListing() { var visibParam = new VisibilityParam() { showDev = this.showDev.Checked, showQa = this.showQa.Checked, showTpm = this.showTpm.Checked, showUe = this.showUe.Checked }; if (this.employeeListContainer.FocusedItem != null) { int selectedIndex = this.employeeListContainer.FocusedItem.Index; Guid id = (Guid)this.employeeListContainer.FocusedItem.Tag; this.employeeListContainer.Items.Clear(); this.employeeListContainer.Items.AddRange(viewHelper.GetMainListView(visibParam)); if (selectedIndex <= this.employeeListContainer.Items.Count - 1 && (Guid)this.employeeListContainer.Items[selectedIndex].Tag == id) { // to make sure we are still focusing at the same item this.employeeListContainer.Items[selectedIndex].Focused = true; this.employeeListContainer.Items[selectedIndex].Selected = true; this.employeeListContainer.Items[selectedIndex].EnsureVisible(); DisableGeneralInfoBtns(); } else { // the original item wasn't there anymore LockGeneralInfoSection(); DisableGeneralInfoBtns(); LockHistory(); } } else { this.employeeListContainer.Items.Clear(); this.employeeListContainer.Items.AddRange(viewHelper.GetMainListView(visibParam)); LockGeneralInfoSection(); DisableGeneralInfoBtns(); LockHistory(); } }
public ListViewItem[] GetMainListView(VisibilityParam visibParam) { IEnumerable <EmployeeDC> allEmp = null; allEmp = empRepo.GetAllEmployees(); List <ListViewItem> ret = new List <ListViewItem>(); foreach (var empDC in allEmp) { var subItems = new string[] { empDC.FullName, empDC.Position, empDC.NextReviewDate?.ToShortDateString(), empDC.OnboardDate.ToShortDateString() }; if (empDC.ResignDate != null) { subItems[0] = subItems[0] + " (Resigned)"; } else if (empDC.NextReviewDate == GlobalPolicyContainer.AnnualPerformanceReviewPolicy.GetNextReviewDate()) { subItems[2] = subItems[2] + " " + '\u26a0'; } var item = new ListViewItem(subItems); if (empDC.ResignDate != null) { item.ForeColor = Color.Red; item.Font = new Font(item.Font, FontStyle.Strikeout); } item.Tag = empDC.Id; item.Name = empDC.Id.ToString(); if ((empDC.CurrentTitle == Title.SOFTWARE_ENGINEER && visibParam.showDev) || ((empDC.CurrentTitle == Title.SOFTWARE_ENGINEER_IN_TEST || empDC.CurrentTitle == Title.SOFTWARE_TEST_ENGINEER) && visibParam.showQa) || (empDC.CurrentTitle == Title.TECHNICAL_PRODUCT_MANAGER && visibParam.showTpm) || (empDC.CurrentTitle == Title.TECHNICAL_WRITER && visibParam.showUe)) { ret.Add(item); } } return(ret.ToArray()); }