예제 #1
0
        private void addressBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            Validate();
            addressBindingSource.EndEdit();

            try
            {
                dbcontext.SaveChanges();
            }
            catch (DbEntityValidationException)
            {
                MessageBox.Show("Columns cannot be empty", "Entity Validation Exception");
            }

            RefreshContacts();
        }
예제 #2
0
        } // end method for loading contacts

        // Click event handler for the Save Button in the
        // BindingNavigator saves the changes made to the data
        private void addressBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            Validate();                     // validate input fields
            addressBindingSource.EndEdit(); // complete current edit, if any

            // try to save changes
            try
            {
                dbcontext.SaveChanges(); // write changes to database file
            } // end try
            catch (DbEntityValidationException)
            {
                MessageBox.Show("Columns cannot be empty", "Entity Validation Exception");
            } // end  catch

            RefreshContacts(); // change back to updated unfiltered data
        } // end method for save button