private void NewButton_Click(object sender, EventArgs e) { if (!Validation.IsAllValid(Detail.Controls)) { return; } var componentType = new ComponentType { Name = NameTextBox.Text, IsVisible = true }; ComponentTypeRepository.InsertComponentType(componentType); ComponentTypeRepository.Commit(); ComponentTypeID = componentType.ID; Close(); }