public static bool DeletePhylum(Phylum SelectedPhylum) { try { DataAccessLayer.DeleteObject(SelectedPhylum); DataAccessLayer.SaveChanges(System.Data.Objects.SaveOptions.None); } catch (Exception ex) { string s = ex.ToString(); DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedPhylum); return false; } DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedPhylum); return true; }
private void btnDelete_Click(object sender, EventArgs e) { if (PhylumDataAccess.DeletePhylum(SelectedPhylum) == false) { MessageBox.Show("Cannot delete, child nodes still exist", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SelectedPhylum = null; LoadData(); try { dgPhylums.CurrentCell = dgPhylums.Rows[0].Cells[0]; dgPhylums.Rows[0].Selected = true; } catch { btnClasses.Enabled = false; txtPhylumId.Text = ""; txtPhylumName.Text = ""; } }
/// <summary> /// Deprecated Method for adding a new object to the Phyla EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPhyla(Phylum phylum) { base.AddObject("Phyla", phylum); }
/// <summary> /// Create a new Phylum object. /// </summary> /// <param name="phylumId">Initial value of the PhylumId property.</param> public static Phylum CreatePhylum(global::System.Int32 phylumId) { Phylum phylum = new Phylum(); phylum.PhylumId = phylumId; return phylum; }
public static int SavePhylum(Phylum SelectedPhylum) { return DataAccessLayer.SaveChanges(); }
private void SelectPhylum(int id) { try { SelectedPhylum = PhylumDataAccess.GetPhylumById(id); txtPhylumName.Text = SelectedPhylum.PhylumName; txtPhylumId.Text = SelectedPhylum.PhylumId.ToString(); btnClasses.Enabled = true; } catch { } }