private void btnDelete_Click(object sender, EventArgs e) { if (FamilyDataAccess.DeleteFamily(SelectedFamily) == false) { MessageBox.Show("Cannot delete, child nodes still exist", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SelectedFamily = null; LoadData(); try { dgFamilys.CurrentCell = dgFamilys.Rows[0].Cells[0]; dgFamilys.Rows[0].Selected = true; } catch { btnGenus.Enabled = false; txtFamilyId.Text = ""; txtFamilyName.Text = ""; } }
/// <summary> /// Create a new Family object. /// </summary> /// <param name="familyId">Initial value of the FamilyId property.</param> public static Family CreateFamily(global::System.Int32 familyId) { Family family = new Family(); family.FamilyId = familyId; return family; }
/// <summary> /// Deprecated Method for adding a new object to the Families EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToFamilies(Family family) { base.AddObject("Families", family); }
private void SelectFamily(int id) { try { SelectedFamily = FamilyDataAccess.GetFamilyById(id); txtFamilyName.Text = SelectedFamily.FamilyName; txtFamilyId.Text = SelectedFamily.FamilyId.ToString(); if (SelectedFamily.Notes != null) { txtNotes.Text = SelectedFamily.Notes.ToString(); } else { txtNotes.Text = ""; } btnGenus.Enabled = true; } catch { } }