Esempio n. 1
0
        private void lbxEmployees_SelectionChanged(object sender, SelectionChangedEventArgs e) //Change of selection in listbox
        {
            Employee selectedEmployee = lbxEmployees.SelectedItem as Employee;                 //Saving the Data of selected Employee in another employee object

            if (selectedEmployee != null)                                                      //Making sure an employee is selected
            {
                //Setting the fields on the right of the display to the selected employee's data
                tbxFirstName.Text = selectedEmployee.FirstName;
                tbxLastName.Text  = selectedEmployee.LastName;
                //Reseting Backgrounds to White, in case they are not
                tbxFirstName.Background = Brushes.White;
                tbxLastName.Background  = Brushes.White;
                rbtnFullTime.Background = Brushes.White;
                rbtnPartTime.Background = Brushes.White;
                if (selectedEmployee is FullTimeEmployee)
                {
                    FullTimeEmployee temp = (FullTimeEmployee)selectedEmployee;
                    rbtnFullTime.IsChecked = true;
                    tbxSalary.Text         = temp.Salary.ToString();
                    tbxHoursWorked.Text    = "";
                    tbxHourlyRate.Text     = "";
                    tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
                }
                else
                {
                    PartTimeEmployee temp = (PartTimeEmployee)selectedEmployee;
                    rbtnPartTime.IsChecked = true;
                    tbxSalary.Text         = "";
                    tbxHoursWorked.Text    = temp.HoursWorked.ToString();
                    tbxHourlyRate.Text     = temp.HourlyRate.ToString();
                    tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
                }
            }
        }
Esempio n. 2
0
 private void ResetData(Employee selectedEmployee)//Resetting back to old Data
 {
     tbxFirstName.Text = selectedEmployee.FirstName;
     tbxLastName.Text  = selectedEmployee.LastName;
     if (selectedEmployee is FullTimeEmployee)
     {
         FullTimeEmployee temp = (FullTimeEmployee)selectedEmployee;
         rbtnFullTime.IsChecked = true;
         tbxSalary.Text         = temp.Salary.ToString();
         tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
     }
     else
     {
         PartTimeEmployee temp = (PartTimeEmployee)selectedEmployee;
         rbtnPartTime.IsChecked = true;
         tbxHoursWorked.Text    = temp.HoursWorked.ToString();
         tbxHourlyRate.Text     = temp.HourlyRate.ToString();
         tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
     }
 }
Esempio n. 3
0
 private void UpdatePTEmployee(FullTimeEmployee tempFT, PartTimeEmployee tempPT, Employee selectedEmployee)//Updating PT Employee
 {
     //Updating employee with inputted data
     tempPT = (PartTimeEmployee)selectedEmployee;
     if (tbxHoursWorked.Text != "Hours Worked..." && tbxHoursWorked.Text != "" &&
         tbxHourlyRate.Text != "Hourly Rate..." && tbxHourlyRate.Text != "")
     {
         tempPT.FirstName   = tbxFirstName.Text;
         tempPT.LastName    = tbxLastName.Text;
         tempPT.HoursWorked = Convert.ToDouble(tbxHoursWorked.Text);
         tempPT.HourlyRate  = Convert.ToDecimal(tbxHourlyRate.Text);
         UpdateEmployees(tempFT, tempPT, selectedEmployee);
     }
     else//Display error message
     {
         MessageBox.Show("To Update an Employee, You Must Enter All Relevant Data!");
         tbxHoursWorked.Text = tempPT.HoursWorked.ToString();
         tbxHourlyRate.Text  = tempPT.HourlyRate.ToString();
         tblkMonthlyPay.Text = tempPT.CalculateMonthlyPay().ToString("€0.00");
     }
 }