Beispiel #1
0
        private void SaveChanges_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ClientServerController.SaveChangesEvents(list);
                db.SaveChanges();
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    exception.Message + "\n" +
                    "Can't add data. Hint:\n \"UserId\" and \"Username\" fields must be unique and not empty\n \"Status\" field must be filled",
                    "Error");
                return;
            }

            MessageBox.Show("Data was added!");
        }
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Experts item = (Experts)DataGrid.SelectedItem;

            if (item != null)
            {
                dbEntities.Experts.Remove(item);
            }

            try
            {
                ClientServerController.SaveChangesExperts(list);
                dbEntities.SaveChanges();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }