Exemplo n.º 1
0
        public void SaveChanges()
        {
            if (!ValidateForm())
            {
                return;
            }

            CustomerDataBindingSource.EndEdit();
            _customer = (Customer)CustomerDataBindingSource.DataSource;
            AddDefaultContract();
            try
            {
                _context.Customers.AddObject(_customer);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                ViewHelper.ShowSaveError();
                ErrorLogger.LogError(this, e);
            }
            if (_saveAndNew)
            {
                _customer = new Customer();
                CustomerDataBindingSource.DataSource = _customer;
                LoadLookups();
            }
            else
            {
                var cdv = new CustomerDetailView();
                cdv.ShowObject(_customer);
                cdv.MdiParent = this.MainForm;
                cdv.Show();
                this.Close();
            }
        }
Exemplo n.º 2
0
 public void SaveChanges()
 {
     if (!ValidateForm())
     {
         return;
     }
     CustomerDataBindingSource.EndEdit();
     try
     {
         if (newMode)
         {
             _context.Customers.AddObject(_customer);
         }
         _context.SaveChanges();
         btnSave.Enabled = false;
     }
     catch (Exception ex)
     {
         ViewHelper.ShowErrorMessage("Error occured while saving the current customer.", ex);
         ErrorLogger.LogError(this, ex);
     }
 }