public void nunnyIDComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { id = nunnyIDComboBox.SelectedValue.ToString(); // if (e.AddedItems[0].ToString()=="") // return; nanny = this.bl.GetNannyByID(id); MessageBox.Show(nanny.ToString()); contract.NunnyID = id; contract.RateforHour = nanny.RateforHour; contract.RateforMonth = nanny.RateforMonth; /*if (monthPayment) * { * contract.RateforHour = 0; * contract.RateforMonth =nanny.RateforMonth; * } * else * { * contract.RateforHour = nanny.RateforHour; * contract.RateforMonth = 0; * }*/ DataContext = contract; } catch (FormatException) { MessageBox.Show("Incorrect input"); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void nunnyIDComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { id = nunnyIDComboBox.SelectedValue.ToString(); nanny = this.bl.GetNannyByID(id); MessageBox.Show(nanny.ToString()); contract.NunnyID = id; if (monthPayment) { contract.RateforHour = 0; contract.RateforMonth = nanny.RateforMonth; } else { contract.RateforHour = nanny.RateforHour; contract.RateforMonth = 0; } } catch (FormatException) { MessageBox.Show("Incorrect input"); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
// event when select nanny private void SelectNanny(object sender, EventArgs e) { if (list.Text != null) { // get the nanny and bind to all fields nanny = bl.CloneNannyList().FirstOrDefault(nanny => nanny.ToString() == list.Text); NannyToDelete.DataContext = nanny; addressTextBox.Text = nanny.Address; } }
private void UpdateNannyButton_Click(object sender, RoutedEventArgs e) { try { BL.FactoryBL.getBL().UpdateNanny(nanny); MessageBox.Show(nanny.ToString()); nanny = new BE.Nanny(); DataContext = nanny; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
// nanny selected event private void SelectNanny(object sender, EventArgs e) { if (list.Text != null) { // get nanny nanny = bl.CloneNannyList().FirstOrDefault(nanny => nanny.ToString() == list.Text); // bind to nanny NannyToUpdate.DataContext = nanny; addressTextBox.Text = nanny.Address; minAgeTextBox.DataContext = minAgeList; if (nanny.MinAge != null && nanny.MinAge != null) { minAgeTextBox.SelectedIndex = minAgeList.IndexOf((int)nanny.MinAge); maxAgeTextBox.SelectedIndex = maxAgeList.IndexOf((int)nanny.MaxAge); } } }
private void Button_Click(object sender, RoutedEventArgs e) { try { nanny.PersonAddress = new Address() { City = this.cityTextBox.Text, Country = countryTextBox.Text, Number = Int32.Parse(numberTextBox.Text) }; nanny.range = minChildrensAgeTextBox.Text + "-" + maxChildrensAgeTextBox.Text; myBL.UpdateNanny(nanny); MessageBox.Show(nanny.ToString()); nanny = new Nanny(); DataContext = nanny; } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }
private void AddNannybutton_Click_1(object sender, RoutedEventArgs e) { this.nanny.NannyDaysOfWork = UserControOfTheWeek.daysOfWork1.DeepClone(); this.nanny.NannyTableOfWork = UserControOfTheWeek.tableOfWork1.DeepClone(); this.nanny.NannyAddress = nannyAddressTextBox.Text; try { // nanny.NannyId = int.Parse(this.nannyIdTextBox.Text); this.grid1.DataContext = nanny; string str = "Are you sure you want to add?\n" + "nanny with this details:\n"; if (UpdateFlag) { str = "Are you sure you Update?\n" + "nanny with this details:\n"; } if (MessageBox.Show(str + nanny.ToString(), " message to user ", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { if (this.UpdateFlag) { bl.UpdateNanny(nanny); } else { bl.AddNanny(nanny); } } // grid1.DataContext = bl.GetNannyIEnumerable(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, " message to user ", MessageBoxButton.OK, MessageBoxImage.Information); } //UserControOfTheWeek.DaysOfWork1 = null; //UserControOfTheWeek.TableOfWork1 = null; }
// item selected in combobox event private void ItemSelected(object sender, EventArgs e) { Entity entity = (Entity)EntityList.SelectedItem; if (searchList.Text != null) { // make frame visible selectedAction.Visibility = Visibility.Visible; // for each item selected, get the item // and open the frame with the item switch (entity) { case Entity.nanny: nanny = bl.CloneNannyList().FirstOrDefault(nanny => nanny.ToString() == searchList.Text); selectedAction.Content = new SearchNanny(bl, nanny); break; case Entity.mother: mother = bl.CloneMotherList().FirstOrDefault(mother => mother.ToString() == searchList.Text); selectedAction.Content = new SearchMother(bl, mother); break; case Entity.child: child = bl.CloneChildList().FirstOrDefault(child => child.ToString() == searchList.Text); selectedAction.Content = new SearchChild(bl, child); break; case Entity.contract: contract = bl.CloneContractList().FirstOrDefault(contract => contract.ToString() == searchList.Text); selectedAction.Content = new SearchContract(bl, contract); break; default: break; } } }