private void btxaddname_Click(object sender, RoutedEventArgs e) { //read details from screen string firstName = tbxfirstname.Text; string lastName = tbxlastname.Text; decimal hourlyrate = Convert.ToDecimal(tbxhrinput.Text); double hoursworked = Convert.ToDouble(tbxHWinput1.Text); //create employees object //add to obervable collection //check which radio button is selected //if radiobutton full time then create full time employee if (rbfulltime.IsChecked == true) { //create a full time employee Employee e1 = new FullTimeEmployees(firstName, lastName, hourlyrate, hoursworked); salary = e1.CalculateMonthlyPay(); employees.Add(e1); } //else if pt rb then create part time employee else if (rbparttime.IsChecked == true) { Employee e1 = new PartTimeEmployees(firstName, lastName, hourlyrate, hoursworked); salary = e1.CalculateMonthlyPay(); employees.Add(e1); } //refresh display manually //lbxNames.ItemsSource = null; //lbxNames.ItemsSource = names; }
private void Window_Loaded(object sender, RoutedEventArgs e) { //string [] names= {"jane","joe","jones","jess"}; Employee e1 = new PartTimeEmployees("Jane", "Jones", Convert.ToDecimal(9.50), 10); Employee e2 = new FullTimeEmployees("Joe", "Murphy", Convert.ToDecimal(10.50), 10); Employee e3 = new FullTimeEmployees("John", "Smith", Convert.ToDecimal(11.50), 10); Employee e4 = new PartTimeEmployees("Jess", "Walsh", Convert.ToDecimal(12.50), 10); employees.Add(e1); employees.Add(e2); employees.Add(e3); employees.Add(e4); lbxName.ItemsSource = employees; }