private void AddChildButton_Click(object sender, RoutedEventArgs e)
 {
     BL.FactoryBL.getBL().AddChild(child);
     MessageBox.Show(child.ToString());
     child       = new BE.Child();
     DataContext = child;
     this.Close();
 }
        private void AddChildButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (errorMessages.Any()) //errorMessages.Count > 0
                {
                    string err = "Exception:";
                    foreach (var item in errorMessages)
                    {
                        err += "\n" + item;
                    }

                    MessageBox.Show(err);
                    return;
                }
                else
                {
                    MessageBoxResult result =
                        MessageBox.Show(
                            "Are the details correct?\n\n" + child.ToString(),
                            "Confirm Child Details",
                            MessageBoxButton.OKCancel,
                            MessageBoxImage.Information);

                    if (result == MessageBoxResult.OK)
                    {
                        bl.AddChild(child);
                        MessageBox.Show(
                            child.FirstName + " was added successfully!\n\n" + child.ToString(),
                            "Add New Child");
                        refreshData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void moreDataGridButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.ChildDataGrid.SelectedItem is BE.Child)
         {
             child = (BE.Child) this.ChildDataGrid.SelectedItem;
             MessageBox.Show(
                 child.ToString(),
                 $"{child.FirstName} Details");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #4
0
 private void AddChildButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         BL.FactoryBL.getBL().AddChild(child);
         MessageBox.Show(child.ToString());
         child       = new BE.Child();
         DataContext = child;
         this.Close();
     }
     catch (FormatException)
     {
         MessageBox.Show("Incorrect input");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void UpdateChildButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (errorMessages.Any()) //errorMessages.Count > 0
                {
                    string err = "Exception:";
                    foreach (var item in errorMessages)
                    {
                        err += "\n" + item;
                    }

                    MessageBox.Show(err);
                    return;
                }
                else
                {
                    MessageBoxResult result =
                        MessageBox.Show(
                            "Are you sure?\n\n" + childToBeUpdated.ToString(),
                            "Update Child",
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes)
                    {
                        bl.UpdateChildDetails(childToBeUpdated);
                        MessageBox.Show($"{childToBeUpdated.FirstName} was updated successfully!\n");
                        refreshData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }