Exemple #1
0
        ///<summary>Fills both grids for currently selected tab.</summary>
        private void FillGrids()
        {
            PhoneEmpSubGroupType    typeCur = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag;
            List <PhoneEmpSubGroup> listEsc = _dictSubGroupsNew[typeCur];

            listEsc = listEsc.OrderBy(x => x.EscalationOrder).ToList();
            //Fill escalation grid.
            gridEscalation.BeginUpdate();
            gridEscalation.Columns.Clear();
            gridEscalation.Columns.Add(new ODGridColumn("Employee", gridEscalation.Width));
            gridEscalation.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < listEsc.Count; i++)
            {
                Employee empCur = Employees.GetEmp(listEsc[i].EmployeeNum);
                if (empCur == null)
                {
                    continue;
                }
                row     = new ODGridRow(empCur.FName + (empCur.IsHidden?"(hidden)":""));
                row.Tag = _listPED.FirstOrDefault(x => x.EmployeeNum == listEsc[i].EmployeeNum);            //can be null
                if (row.Tag == null)
                {
                    row.Tag = _dictSubGroupsNew[typeCur].IndexOf(listEsc[i]);                  //Since we .OrderBy(...) only in FillGrid, pass the index to the tag.
                }
                gridEscalation.Rows.Add(row);
                //Set escalation order for this employee.
                //Must happen after the add in order to keep the Escalation order 1-based.
                listEsc[i].EscalationOrder = gridEscalation.Rows.Count;
            }
            gridEscalation.EndUpdate();
            //Fill employee grid.
            gridEmployees.BeginUpdate();
            gridEmployees.Columns.Clear();
            gridEmployees.Columns.Add(new ODGridColumn("Employee", gridEmployees.Width));
            gridEmployees.Rows.Clear();
            for (int i = 0; i < _listPED.Count; i++)
            {
                row = new ODGridRow();
                //Omit employee who are already included in escalation grid.
                if (listEsc.Any(x => x.EmployeeNum == _listPED[i].EmployeeNum))
                {
                    continue;
                }
                row.Cells.Add(_listPED[i].EmpName.ToString());
                row.Tag = _listPED[i];
                gridEmployees.Rows.Add(row);
            }
            gridEmployees.EndUpdate();
        }
Exemple #2
0
        private void butUp_Click(object sender, EventArgs e)
        {
            if (gridEscalation.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Select 1 item from escalation list");
                return;
            }
            if (gridEscalation.SelectedIndices[0] == 0)
            {
                return;
            }
            //Retain current selection.
            int curSelectedIndex                 = Math.Max(gridEscalation.SelectedIndices[0] - 1, 0);
            PhoneEmpSubGroupType typeCur         = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag;
            List <int>           selectedIndices = new List <int>(gridEscalation.SelectedIndices);

            for (int i = 0; i < gridEscalation.Rows.Count; i++)
            {
                if (gridEscalation.Rows[i].Tag is PhoneEmpDefault)
                {
                    PhoneEmpDefault ped = (PhoneEmpDefault)gridEscalation.Rows[i].Tag;
                    if (selectedIndices[0] == i + 1)
                    {
                        //First should be safe to use here because it must exist in gridescalation to get here.
                        _dictSubGroupsNew[typeCur].First(x => x.EmployeeNum == ped.EmployeeNum).EscalationOrder++;
                    }
                    else if (selectedIndices[0] == i)
                    {
                        _dictSubGroupsNew[typeCur].First(x => x.EmployeeNum == ped.EmployeeNum).EscalationOrder--;
                    }
                }
                else                  //Tag is an index (int)
                {
                    int index = (int)gridEscalation.Rows[i].Tag;
                    if (selectedIndices[0] == i + 1)
                    {
                        //First should be safe to use here because it must exist in gridescalation to get here.
                        _dictSubGroupsNew[typeCur][index].EscalationOrder++;
                    }
                    else if (selectedIndices[0] == i)
                    {
                        _dictSubGroupsNew[typeCur][index].EscalationOrder--;
                    }
                }
            }
            FillGrids();
            //Reset selection so moving up the list rapidly is easier.
            gridEscalation.SetSelected(curSelectedIndex, true);
        }
Exemple #3
0
        private void butRight_Click(object sender, EventArgs e)
        {
            if (gridEmployees.SelectedIndices.Length <= 0)
            {
                return;
            }
            PhoneEmpSubGroupType typeCur = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag;

            foreach (int i in gridEmployees.SelectedIndices)
            {
                PhoneEmpDefault pedKeep = (PhoneEmpDefault)gridEmployees.Rows[i].Tag;
                _dictSubGroupsNew[typeCur].Add(new PhoneEmpSubGroup(pedKeep.EmployeeNum, typeCur, 0));
            }
            FillGrids();
        }
Exemple #4
0
        public FormPhoneEmpDefaultEscalationEdit(PhoneEmpSubGroupType tabDefault = PhoneEmpSubGroupType.Avail)
        {
            InitializeComponent();
            Lan.F(this);
            FillTabs();
            List <PhoneEmpSubGroup> listGroupsAll = PhoneEmpSubGroups.GetAll();

            _dictSubGroupsOld = Enum.GetValues(typeof(PhoneEmpSubGroupType)).Cast <PhoneEmpSubGroupType>().ToDictionary(x => x, x => listGroupsAll.FindAll(y => y.SubGroupType == x));
            _dictSubGroupsNew = _dictSubGroupsOld.ToDictionary(x => x.Key, x => x.Value.Select(y => y.Copy()).ToList());
            //Get all employees.
            _listPED = PhoneEmpDefaults.Refresh();
            //Sort by name.
            _listPED.Sort(new PhoneEmpDefaults.PhoneEmpDefaultComparer(PhoneEmpDefaults.PhoneEmpDefaultComparer.SortBy.name));
            FillGrids();
            //This can change to a switch statement on tabDefault if we ever add custom named tabs.
            tabMain.SelectTab(tabMain.TabPages[tabDefault.ToString()]);
        }
Exemple #5
0
        private void butLeft_Click(object sender, EventArgs e)
        {
            if (gridEscalation.SelectedIndices.Length <= 0)
            {
                return;
            }
            PhoneEmpSubGroupType typeCur = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag;

            foreach (int i in gridEscalation.SelectedIndices)
            {
                if (gridEscalation.Rows[i].Tag is PhoneEmpDefault)
                {
                    PhoneEmpDefault pedCur = (PhoneEmpDefault)gridEscalation.Rows[i].Tag;
                    _dictSubGroupsNew[typeCur].RemoveAll(x => x.EmployeeNum == pedCur.EmployeeNum);
                }
                else                  //Tag is an index (int)
                {
                    int index = (int)gridEscalation.Rows[i].Tag;
                    _dictSubGroupsNew[typeCur].RemoveAt(index);
                }
            }
            FillGrids();
        }
Exemple #6
0
        private void tabMain_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!tabMain.TabPages.ContainsKey(PhoneEmpSubGroupType.Escal.ToString()))             //Control has not been initialized.
            {
                return;
            }
            gridEmployees.ScrollValue  = 0;         //scroll to top
            gridEscalation.ScrollValue = 0;         //scroll to top
            FillGrids();
            PhoneEmpSubGroupType typeCur = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag;

            if (typeCur == PhoneEmpSubGroupType.Avail)
            {
                butUp.Enabled      = false;
                butDown.Enabled    = false;
                labelAvail.Visible = true;
            }
            else
            {
                butUp.Enabled      = true;
                butDown.Enabled    = true;
                labelAvail.Visible = false;
            }
        }
Exemple #7
0
 public PhoneEmpSubGroup(long employeeNum, PhoneEmpSubGroupType subGroupType, int escalationOrder)
 {
     this.EmployeeNum     = employeeNum;
     this.SubGroupType    = subGroupType;
     this.EscalationOrder = escalationOrder;
 }