Esempio n. 1
0
 private void buttonMakeManager_Click(object sender, EventArgs e)
 {
     if (objectListViewEmployee.SelectedObjects.Count == 1)
     {
         Employee     employee      = (Employee)objectListViewEmployee.SelectedObject;
         Team         team          = (Team)comboBoxBeforeTeam.SelectedItem;
         DialogResult confirmResult = MessageBox.Show("Are you sure you want to make " + employee.FirstName + " the manager of team " + team.TeamName + "?", "Confirm Manager Change", MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             Database.UpdateTeamManager(employee.ID, team.ID);
             Database.ReadAllTeams();
             Database.FillTeams();
             Database.ReadAllTickets();
             SelectedBeforeTeamIndex = comboBoxBeforeTeam.SelectedIndex;
             RefreshComboBoxBeforeTeamDataSource();
             RefreshCurrentManagerLabel();
             ObjectListViewTicket.SetObjects(Database.tickets);
         }
     }
     else if (objectListViewEmployee.SelectedObjects.Count > 1)
     {
         MessageBox.Show("You can only make one employee the team manager.");
     }
     else
     {
         MessageBox.Show("You must select an employee before making him/her the team manager.");
     }
 }
Esempio n. 2
0
        public void RefreshControls()
        {
            ObjectListViewTicket.SetObjects(Database.tickets);
            ComboBoxBeforeTeam.DataSource = Database.teams;
            List <Team> afterTeamDataSource = new List <Team>();

            afterTeamDataSource.AddRange(Database.teams);
            afterTeamDataSource.RemoveAt(ComboBoxBeforeTeam.SelectedIndex);
            ComboBoxAfterTeam.DataSource = afterTeamDataSource;
        }
Esempio n. 3
0
 private void buttonEditEmployee_Click(object sender, EventArgs e)
 {
     EditedEmployee.FirstName = textBoxFirstName.Text;
     EditedEmployee.LastName  = textBoxLastName.Text;
     EditedEmployee.TeamID    = (string)comboBoxTeam.SelectedValue;
     Database.UpdateEmployee(EditedEmployee);
     Database.ReadAllEmployees();
     Database.FillTeams();
     Database.ReadAllTickets();
     ObjectListViewEmployee.SetObjects(Database.sortedEmployees.ElementAt(Convert.ToInt32(ComboBoxBeforeTeam.SelectedValue) - 1));
     ObjectListViewTicket.SetObjects(Database.tickets);
     Hide();
 }
Esempio n. 4
0
        private void buttonMoveEmployee_Click(object sender, EventArgs e)
        {
            if (objectListViewEmployee.SelectedObjects.Count == 1)
            {
                Team     team     = (Team)comboBoxAfterTeam.SelectedItem;
                Employee employee = (Employee)objectListViewEmployee.SelectedObject;

                DialogResult confirmResult = MessageBox.Show("Are you sure you want to move " + employee.FirstName + " to team " + team.TeamName + "?", "Confirm Team Change", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    Database.ChangeEmployeeTeam(team.ID, employee.ID);
                }
                Database.FillTeams();
                Database.ReadAllTickets();
                objectListViewEmployee.SetObjects(Database.sortedEmployees.ElementAt(Convert.ToInt32(comboBoxBeforeTeam.SelectedValue) - 1));
                ObjectListViewTicket.SetObjects(Database.tickets);
            }
            else if (objectListViewEmployee.SelectedObjects.Count > 1)
            {
                Team            team = (Team)comboBoxAfterTeam.SelectedItem;
                List <Employee> selectedEmployeesList = new List <Employee>();
                foreach (var employeeObject in objectListViewEmployee.SelectedObjects)
                {
                    Employee employee = (Employee)employeeObject;
                    selectedEmployeesList.Add(employee);
                }
                string       selectedEmployeesString = String.Join(", ", selectedEmployeesList);
                DialogResult confirmResult           = MessageBox.Show("Are you sure you want to move " + selectedEmployeesString + " to team " + team.TeamName + "?", "Confirm Team Change", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    foreach (var employeeObject in objectListViewEmployee.SelectedObjects)
                    {
                        Employee employee = (Employee)employeeObject;
                        Database.ChangeEmployeeTeam(team.ID, employee.ID);
                        objectListViewEmployee.RemoveObject(objectListViewEmployee.SelectedObject);
                    }
                    Database.FillTeams();
                    Database.ReadAllTickets();
                    objectListViewEmployee.SetObjects(Database.sortedEmployees.ElementAt(Convert.ToInt32(comboBoxBeforeTeam.SelectedValue) - 1));
                    ObjectListViewTicket.SetObjects(Database.tickets);
                }
            }
            else
            {
                MessageBox.Show("You must select an employee to move.");
            }
        }