Esempio n. 1
0
        public void SaveChanges()
        {
            if (!ValidateForm())
            {
                return;
            }
            equipmentBindingSource.EndEdit();

            try
            {
                var equipment = (Equipment)equipmentBindingSource.DataSource;
                _context.Equipments.AddObject(equipment);
                _context.SaveChanges();
                _equipment = equipment;
                if (_saveAndNew)
                {
                    equipmentBindingSource.DataSource = new Equipment();
                    LoadLookUp();
                    if (CustomerView != null)
                    {
                        CustomerView.ReloadEquipments();
                    }
                    if (ContractView != null)
                    {
                        //ContractView.ReloadEquipments();
                    }
                }
                else
                {
                    this.Close();
                    // Redirect to Equipment Detail.
                    ShowEquipmentDetail();
                }
            }
            catch (Exception)
            {
                ViewHelper.ShowErrorMessage(@"Error saving new equipment.");
            }
        }