示例#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");
                }
            }
        }
示例#2
0
 private void UpdateFTEmployee(FullTimeEmployee tempFT, PartTimeEmployee tempPT, Employee selectedEmployee)//Updating FT Employee
 {
     //Updating employee with inputted data
     tempFT = (FullTimeEmployee)selectedEmployee;
     if (tbxSalary.Text != "Salary..." && tbxSalary.Text != "")
     {
         tempFT.FirstName = tbxFirstName.Text;
         tempFT.LastName  = tbxLastName.Text;
         tempFT.Salary    = Convert.ToDecimal(tbxSalary.Text);
         UpdateEmployees(tempFT, tempPT, selectedEmployee);
     }
     else//Display error message
     {
         MessageBox.Show("To Update an Employee, You Must Enter All Relevant Data!");
         tbxSalary.Text      = tempFT.Salary.ToString();
         tblkMonthlyPay.Text = tempFT.CalculateMonthlyPay().ToString("€0.00");
     }
 }
示例#3
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");
     }
 }