Exemplo n.º 1
0
        private void DeleteBTN_Click(object sender, RoutedEventArgs e)
        {
            Employee         SelectedEmployee     = ListBoxEmployeeBOX.SelectedItem as Employee;                            //getting the selected employee ready to delete
            FullTimeEmployee FullSelectedEmployee = ListBoxEmployeeBOX.SelectedItem as FullTimeEmployee;
            PartTimeEmployee PartSelectedEmployee = ListBoxEmployeeBOX.SelectedItem as PartTimeEmployee;

            employee.Remove(SelectedEmployee);                                                                              //that employee gets removed from the class
            FullTimePeople.Remove(FullSelectedEmployee);
            PartTimePeople.Remove(PartSelectedEmployee);
        }
Exemplo n.º 2
0
        private void UpdateBTN_Click(object sender, RoutedEventArgs e)
        {
            Employee         TheEmployee = ListBoxEmployeeBOX.SelectedItem as Employee;                                     //getting the selected item
            FullTimeEmployee TheFull     = ListBoxEmployeeBOX.SelectedItem as FullTimeEmployee;
            PartTimeEmployee ThePart     = ListBoxEmployeeBOX.SelectedItem as PartTimeEmployee;
            string           newFirst    = FirstNameTBX.Text;                                                               //setting the text in the different boxs as a string
            string           newSur      = SurnameTBX.Text;
            string           newSalary   = SalaryTBX.Text;
            string           newPosition;

            if (FullTimeRAD.IsChecked == true)
            {
                newPosition = "FullTime";
            }
            else
            {
                newPosition = "PartTime";
            }
            string newHours = HoursWorkedTBX.Text;
            string newRate  = HourlyRateTBX.Text;

            for (int i = 0; i < FullTimePeople.Count; i++)                                                                  //for the amount of people in full time people do the following
            {
                if (TheFull == FullTimePeople[i])                                                                           //if the selected person is equal to that of in full time person class
                {
                    FullTimePeople[i].FirstName = newFirst;                                                                 //setting that employee with the new and updated info
                    FullTimePeople[i].SurName   = newSur;
                    FullTimePeople[i].Salary    = Convert.ToDecimal(newSalary);
                    FullTimePeople[i].JobLevel  = newPosition;
                    if (TheEmployee == FullTimePeople[i])                                                                   //backup name for employee
                    {
                        employee[i].FirstName = newFirst;
                        employee[i].SurName   = newSur;
                        employee[i].JobLevel  = newPosition;
                    }
                }
            }
            for (int i = 0; i < PartTimePeople.Count; i++)                                                                  //for the amount of people in part time people do the following
            {
                if (ThePart == PartTimePeople[i])                                                                           //if the selected person is equal to that of in part time person class
                {
                    PartTimePeople[i].FirstName   = newFirst;                                                               //setting that employee with the new and updated info
                    PartTimePeople[i].SurName     = newSur;
                    PartTimePeople[i].HourlyRate  = Convert.ToDecimal(newRate);
                    PartTimePeople[i].HoursWorked = Convert.ToDouble(newHours);
                    PartTimePeople[i].JobLevel    = newPosition;
                    if (TheEmployee == PartTimePeople[i])                                                                   //backup name for employee
                    {
                        employee[i].FirstName = newFirst;
                        employee[i].SurName   = newSur;
                        employee[i].JobLevel  = newPosition;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ListBoxEmployeeBOX_Loaded(object sender, RoutedEventArgs e)
        {
            Employee         e1   = new PartTimeEmployee("Jane", "Jones", "PartTime", 72, 1);                               //making the people in the employee class
            PartTimeEmployee e1v2 = new PartTimeEmployee("John", "Smith", "PartTime", 4, 21);                               //making the people for that group
            Employee         e2   = new FullTimeEmployee("Joe", "Murphy", "FullTime", 54);
            FullTimeEmployee e2v2 = new FullTimeEmployee("Joe", "Murphy", "FullTime", 54);
            Employee         e3   = new PartTimeEmployee("John", "Smith", "PartTime", 4, 21);
            PartTimeEmployee e3v2 = new PartTimeEmployee("John", "Smith", "PartTime", 4, 21);
            Employee         e4   = new FullTimeEmployee("Jess", "Walsh", "FullTime", 83);
            FullTimeEmployee e4v2 = new FullTimeEmployee("Jess", "Walsh", "FullTime", 83);

            employee.Add(e1);                                                                                               //adding people to the list for the employee class
            PartTimePeople.Add(e1v2);                                                                                       //indivisually adding each perosn to ther erespective group at first to help filtering later on
            employee.Add(e2);
            FullTimePeople.Add(e2v2);
            employee.Add(e3);
            PartTimePeople.Add(e3v2);
            employee.Add(e4);
            FullTimePeople.Add(e4v2);
            ListBoxEmployeeBOX.ItemsSource = employee;                                                                      //filling the empty table with just emplyee at first
            employee.OrderBy(x => x.SurName).ToList();                                                                      //Sorts them alphabetically
            FullTimePeople.OrderBy(x => x.SurName).ToList();
            PartTimePeople.OrderBy(x => x.SurName).ToList();
        }