示例#1
0
        // press add button to add new Employee
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            //first name and surname are are in both lists
            string NewFirstName = FirstNameTBox.Text;
            string NewLastName  = SurnameTBox.Text;

            if (FtRBtn.IsChecked != false)
            {
                //if fulltime ratio is clicked they will will be in fullime class
                string           NewShift         = "Full Time";                                                          //declaring full time
                decimal          NewSalary        = decimal.Parse(SalaryTBox.Text);                                       //takes in salary
                FullTimeEmployee fullTimeEmployee = new FullTimeEmployee(NewFirstName, NewLastName, NewShift, NewSalary); //take into full time employee
                fullTimeEmployees.Add(fullTimeEmployee);                                                                  // add to fullTimeEmployees list
                employees.Add(fullTimeEmployee);                                                                          // add to employees list
            }
            else if (PtRBtn.IsChecked != false)
            {
                //if parttime ratio is clicked they will will be in partime class
                string           NewShift         = "Part Time";                                                                               //declaring part time
                decimal          NewHourlyRate    = decimal.Parse(HourlyRateTBox.Text);                                                        //takes in hour rate
                decimal          NewHourlyWorked  = decimal.Parse(HoursWorkedTBox.Text);                                                       //takes in hour work
                PartTimeEmployee partTimeEmployee = new PartTimeEmployee(NewFirstName, NewLastName, NewShift, NewHourlyRate, NewHourlyWorked); //take into part time emplyee
                partTimeEmployees.Add(partTimeEmployee);                                                                                       // add to partTimeEmployees list
                employees.Add(partTimeEmployee);                                                                                               // add to employees list
            }

            //reloads the listBox to that new inputs will appear automatic
            EmployeeLB.ItemsSource = null;
            EmployeeLB.ItemsSource = employees;
        }
示例#2
0
        }   //clears text boxes for hourly rate input

        //Listbox
        private void lbxNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Employee         selectedEmployee   = lbxNames.SelectedItem as Employee;
            FullTimeEmployee selectedEmployeeFT = lbxNames.SelectedItem as FullTimeEmployee;
            PartTimeEmployee selectedEmployeePT = lbxNames.SelectedItem as PartTimeEmployee;

            if (selectedEmployee != null)
            {
                tbxFirstName.Text = selectedEmployee.FirstName;
                tbxSurname.Text   = selectedEmployee.Surname;

                if (selectedEmployee.WorkType == "Full Time")
                {
                    tbxSalary.Text      = selectedEmployeeFT.Salary.ToString();
                    tblkMonthlyPay.Text = selectedEmployeeFT.CalculateMonthlyPay().ToString();
                    rbtnFT.IsChecked    = true;
                    tbxHourlyRate.Clear();
                    tbxHoursWorked.Clear();
                }
                else if (selectedEmployee.WorkType == "Part Time")
                {
                    rbtnPT.IsChecked    = true;
                    tbxHourlyRate.Text  = selectedEmployeePT.HourlyRate.ToString();
                    tbxHoursWorked.Text = selectedEmployeePT.HoursWorked.ToString();
                    tblkMonthlyPay.Text = selectedEmployeePT.CalculateMonthlyPay().ToString();
                    tbxSalary.Clear();
                }
            }
        }   //Select employees from listbox
示例#3
0
        private void EmployeeLB_Loaded(object sender, RoutedEventArgs e)
        {
            // creating employess
            PartTimeEmployee e1 = new PartTimeEmployee("Jane", "Jones", "Part Time", 5, 88);
            FullTimeEmployee e2 = new FullTimeEmployee("Joe", "Murphy", "Full Time", 5000);
            PartTimeEmployee e3 = new PartTimeEmployee("John", "Smith", "Part Time", 8, 9);
            FullTimeEmployee e4 = new FullTimeEmployee("Jess", "Walsh", "Full Time", 99050);
            // creating 2 FullTimeEmployee and 2 PartTimeEmployee objects
            PartTimeEmployee e5 = new PartTimeEmployee("Max", "Cooper", "Part Time", 100, 9);
            FullTimeEmployee e6 = new FullTimeEmployee("Toby", "Ross", "Full Time", 88000);
            PartTimeEmployee e7 = new PartTimeEmployee("Rex", "Brown", "Part Time", 20, 10);
            FullTimeEmployee e8 = new FullTimeEmployee("Steven", "Thomson", "Full Time", 40040);

            //adding all employees to employess list
            employees.Add(e1);
            employees.Add(e2);
            employees.Add(e3);
            employees.Add(e4);
            employees.Add(e5);
            employees.Add(e6);
            employees.Add(e7);
            employees.Add(e8);

            //adding partTime Employees partTime Employees list
            partTimeEmployees.Add(e1);
            partTimeEmployees.Add(e3);
            partTimeEmployees.Add(e5);
            partTimeEmployees.Add(e7);
            //adding fullTime Employees to fullTime Employees list
            fullTimeEmployees.Add(e2);
            fullTimeEmployees.Add(e4);
            fullTimeEmployees.Add(e6);
            fullTimeEmployees.Add(e8);
        }
示例#4
0
        }   //Unchecked checkbox to show all employees again

        //Buttons
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string firstname = tbxFirstName.Text;
            string surname   = tbxSurname.Text;

            if (rbtnFT.IsChecked == true)
            {
                string           worktype   = "Full Time";
                decimal          salary     = Convert.ToDecimal(tbxSalary.Text);
                FullTimeEmployee employeeFT = new FullTimeEmployee(firstname, surname, worktype, salary);
                Employee         employee   = new FullTimeEmployee(firstname, surname, worktype, salary);
                employees.Add(employee);
                fullTimeEmployees.Add(employeeFT);
            }
            else if (rbtnPT.IsChecked == true)
            {
                string           worktype    = "Part Time";
                decimal          hourlyrate  = Convert.ToDecimal(tbxHourlyRate.Text);
                double           hoursworked = Convert.ToDouble(tbxHoursWorked.Text);
                PartTimeEmployee employeePT  = new PartTimeEmployee(firstname, surname, worktype, hourlyrate, hoursworked);
                Employee         employee    = new PartTimeEmployee(firstname, surname, worktype, hourlyrate, hoursworked);
                employees.Add(employee);
                partTimeEmployees.Add(employeePT);
            }
        }   //Add button to add emplyees
示例#5
0
        }   //Update button to update employee details

        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Employee         selectedEmployee   = lbxNames.SelectedItem as Employee;
            FullTimeEmployee selectedEmployeeFT = lbxNames.SelectedItem as FullTimeEmployee;
            PartTimeEmployee selectedEmployeePT = lbxNames.SelectedItem as PartTimeEmployee;

            employees.Remove(selectedEmployee);
            fullTimeEmployees.Remove(selectedEmployeeFT);
            partTimeEmployees.Remove(selectedEmployeePT);
        }   //Delete button to delete employees
示例#6
0
        private void lbxNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            FullTimeEmployee selectedWorker = lbxNames.SelectedItem as FullTimeEmployee;

            if (selectedWorker != null)
            {
                //update the display
                tbxFirstName.Text = selectedWorker.FirstName;
                tbxSurname.Text   = selectedWorker.LastName.ToUpper();
                tbxSalary.Text    = selectedWorker.Salary.ToString();
            }
        }
示例#7
0
        private void UpdateBtn_Click(object sender, RoutedEventArgs e)
        {
            //changing employee info
            //select from list
            FullTimeEmployee changeFullTimeEmp = EmployeeLB.SelectedItem as FullTimeEmployee;
            PartTimeEmployee changePartTimeEmp = EmployeeLB.SelectedItem as PartTimeEmployee;

            //looping through all fulltime employees
            for (int x = 0; x < fullTimeEmployees.Count; x++)
            {
                //if employee selected to change is in fulltime employee list
                if (changeFullTimeEmp == fullTimeEmployees[x])
                {
                    //takes in first name , surname and salary
                    string  changedFullTime = FirstNameTBox.Text;
                    string  changedPartTime = SurnameTBox.Text;
                    decimal changedSalary   = decimal.Parse(SalaryTBox.Text);

                    //sets the new figures to the slected full employee
                    fullTimeEmployees[x].FirstName = changedFullTime;
                    fullTimeEmployees[x].LastName  = changedPartTime;
                    fullTimeEmployees[x].Salary    = changedSalary;

                    //refresh listbox
                    EmployeeLB.ItemsSource = null;
                    EmployeeLB.ItemsSource = fullTimeEmployees;
                }
            }
            //loops through part employee
            for (int z = 0; z < partTimeEmployees.Count; z++)
            {
                //if selected employee is part time
                if (changePartTimeEmp == partTimeEmployees[z])
                {
                    //takes in new first name , surname, hours rate , hours worked
                    string  changedFullTime    = FirstNameTBox.Text;
                    string  changedPartTime    = SurnameTBox.Text;
                    decimal changedHourlyRate  = decimal.Parse(HourlyRateTBox.Text);
                    decimal changedHoursWorked = decimal.Parse(HoursWorkedTBox.Text);

                    //sets new details
                    partTimeEmployees[z].FirstName   = changedFullTime;
                    partTimeEmployees[z].LastName    = changedPartTime;
                    partTimeEmployees[z].HourlyRate  = changedHourlyRate;
                    partTimeEmployees[z].HoursWorked = changedHoursWorked;

                    //refresh list box
                    EmployeeLB.ItemsSource = null;
                    EmployeeLB.ItemsSource = partTimeEmployees;
                }
            }
        }
示例#8
0
        private void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            //select from list
            Employee         delSelecetEmpl         = EmployeeLB.SelectedItem as Employee;
            FullTimeEmployee delSelecetFullTimeEmpl = EmployeeLB.SelectedItem as FullTimeEmployee;
            PartTimeEmployee delSelecetPartTimeEmpl = EmployeeLB.SelectedItem as PartTimeEmployee;


            //loops through full time employee
            for (int z = 0; z < fullTimeEmployees.Count; z++)
            {
                //if selected employee is fulltime
                if (delSelecetFullTimeEmpl == fullTimeEmployees[z])
                {
                    //delete it
                    fullTimeEmployees.RemoveAt(z);
                }
                //refresh list
                EmployeeLB.ItemsSource = null;
                EmployeeLB.ItemsSource = fullTimeEmployees;
            }
            //loop thorugh parttime employees
            for (int x = 0; x < partTimeEmployees.Count; x++)
            {
                // selected employee
                if (delSelecetPartTimeEmpl == partTimeEmployees[x])
                {
                    //delete it
                    partTimeEmployees.RemoveAt(x);

                    //refresh listbox
                    EmployeeLB.ItemsSource = null;
                    EmployeeLB.ItemsSource = partTimeEmployees;
                }
            }
            //loop through employee
            for (int Q = 0; Q < employees.Count; Q++)
            {
                if (delSelecetEmpl == employees[Q])
                {
                    //delete employee
                    employees.RemoveAt(Q);
                    //refresh page
                    EmployeeLB.ItemsSource = null;
                    EmployeeLB.ItemsSource = employees;
                }
            }
        }
示例#9
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string  firstName = tbxFirstName.Text;
            string  lastName  = tbxSurname.Text.ToUpper();     //ToUpper() converts a user input string into capital letters
            decimal salary    = Convert.ToInt32(tbxSalary.Text);


            FullTimeEmployee e1 = new FullTimeEmployee(firstName, lastName, salary);


            //adds to observable collection
            fullTimeEmployees.Add(e1);

            //Add to listbox
            lbxNames.ItemsSource = fullTimeEmployees;
        }
示例#10
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            FullTimeEmployee e1 = new FullTimeEmployee("John", "Munnelly", 15000);
            FullTimeEmployee e2 = new FullTimeEmployee("Robert", "Butler", 22250);
            PartTimeEmployee e3 = new PartTimeEmployee("Lenny", "Mcgourthy", 2000, 1000);
            PartTimeEmployee e4 = new PartTimeEmployee("Brian", "Hagan", 2000, 1200);

            //adds to observable collection
            fullTimeEmployees.Add(e1);
            fullTimeEmployees.Add(e2);

            //Add to Listbox
            lbxNames.ItemsSource = fullTimeEmployees;

            //adds to observable collection
            partTimeEmployees.Add(e3);
            partTimeEmployees.Add(e4);

            //Add to listbox
            lbxNames.ItemsSource = partTimeEmployees;
        }
示例#11
0
        //Window Loads
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Employee         e1  = new PartTimeEmployee("Jane", "Jones", "Part Time", 10, 25);
            PartTimeEmployee pt1 = new PartTimeEmployee("Jane", "Jones", "Part Time", 10, 25);
            Employee         e2  = new FullTimeEmployee("Joe", "Murphy", "Full Time", 52000);
            FullTimeEmployee ft1 = new FullTimeEmployee("Joe", "Murphy", "Full Time", 52000);
            Employee         e3  = new PartTimeEmployee("John", "Smith", "Part Time", 12, 18);
            PartTimeEmployee pt2 = new PartTimeEmployee("John", "Smith", "Part Time", 12, 18);
            Employee         e4  = new FullTimeEmployee("Jess", "Walsh", "Full Time", 78000);
            FullTimeEmployee ft2 = new FullTimeEmployee("Jess", "Walsh", "Full Time", 78000);

            employees.Add(e1);
            partTimeEmployees.Add(pt1);
            employees.Add(e2);
            fullTimeEmployees.Add(ft1);
            employees.Add(e3);
            partTimeEmployees.Add(pt2);
            employees.Add(e4);
            fullTimeEmployees.Add(ft2);
            lbxNames.ItemsSource = employees;
        }   //Adds employees to list when the window loads
示例#12
0
        }   //Clear button to clear all text boxes

        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Employee         Employee         = lbxNames.SelectedItem as Employee;
            FullTimeEmployee FullTimeEmployee = lbxNames.SelectedItem as FullTimeEmployee;
            PartTimeEmployee PartTimeEmployee = lbxNames.SelectedItem as PartTimeEmployee;
            string           FirstName        = tbxFirstName.Text;
            string           Surname          = tbxSurname.Text;
            string           WorkType;

            if (rbtnFT.IsChecked == true)
            {
                decimal Salary = Convert.ToDecimal(tbxSalary.Text);
                WorkType = "FullTime";
            }
            else if (rbtnPT.IsChecked == true)
            {
                string HoursWorked = tbxHoursWorked.Text;
                string HourlyRate  = tbxHourlyRate.Text;
                WorkType = "PartTime";
            }
        }   //Update button to update employee details
示例#13
0
        //seleted employee will display their information right
        private void EmployeeLB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //take list to display from employee , full time and part time to be slected
            Employee         selecetedEmployee = EmployeeLB.SelectedItem as Employee;
            PartTimeEmployee selecetedPartTime = EmployeeLB.SelectedItem as PartTimeEmployee;
            FullTimeEmployee selecetedFullTime = EmployeeLB.SelectedItem as FullTimeEmployee;

            //if a employee is selected
            if (selecetedEmployee != null)
            {
                //takes in first & last names
                FirstNameTBox.Text = selecetedEmployee.FirstName;
                SurnameTBox.Text   = selecetedEmployee.LastName;

                if (selecetedEmployee.Shift == "Full Time")
                {
                    // if full time needs to dispaly salary
                    //clear hours worked and hour rate to not display anything
                    HoursWorkedTBox.Clear();
                    HourlyRateTBox.Clear();

                    //dispaly salary in salaryTBox
                    SalaryTBox.Text = selecetedFullTime.Salary.ToString();
                }
                else
                {
                    // else they will be part time
                    //dont need salary so clear
                    SalaryTBox.Clear();
                    HoursWorkedTBox.Text = selecetedPartTime.HourlyRate.ToString();  //display hours worked
                    HourlyRateTBox.Text  = selecetedPartTime.HoursWorked.ToString(); //display hours rate
                }

                // display Monthly Pay in textblock rounded up
                monthlyPayTxtBlock.Text = Decimal.Round(selecetedEmployee.CalculateMonthlyPay()).ToString();
            }
        }