private void Button_Click(object sender, RoutedEventArgs e) { try { if (allergyCheckBox.IsChecked == false) { myAllergyTextBox.Text = ""; child.MyAllergy = ""; } if (specialNeedsCheckBox.IsChecked == false) { needsTextBox.Text = ""; child.Needs = ""; } myBL.UpdateChild(child); MessageBox.Show(child.ToString()); child = new Child(); DataContext = child; } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }
//private void AddChildbutton_Click(object sender, RoutedEventArgs e) //{ // // child.ChildId = int.Parse(this.childIdTextBox.Text); // this.grid1.DataContext = child; // bl.AddChild(child); //} private void AddChildbutton_Click(object sender, RoutedEventArgs e) { try { // child.ChildId = int.Parse(this.childIdTextBox.Text); this.grid1.DataContext = child; string str = "Are you sure you want to add?\n" + "child with this details:\n"; if (UpdateFlag) { str = "Are you sure you Update?\n" + "child with this details:\n"; } if (MessageBox.Show(str + child.ToString(), " message to user ", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { if (this.UpdateFlag) { bl.UpdateChild(child); } else { bl.AddChild(child); } } // grid1.DataContext = bl.GetChildIEnumerable(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, " message to user ", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void SelectChild(object sender, EventArgs e) { if (list.Text != null) { child = bl.CloneChildList().FirstOrDefault(child => child.ToString() == list.Text); UpdateChild.DataContext = child; } }
// event when select child private void SelectChild(object sender, EventArgs e) { if (list.Text != null) { // get the child and bind to all fields child = bl.CloneChildList().FirstOrDefault(child => child.ToString() == list.Text); DeleteChild.DataContext = child; } }
private void UpdateChildButton_Click(object sender, RoutedEventArgs e) { try { BL.FactoryBL.getBL().UpdateChild(child); MessageBox.Show(child.ToString()); child = new BE.Child(); DataContext = child; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// add child button /// when the button clicked the event call the add child function /// with the child details that received /// </summary> private void Button_Click(object sender, RoutedEventArgs e) { try { myBL.AddChild(child); MessageBox.Show(child.ToString()); child = new Child(); DataContext = child; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// 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; } } }