public static bool DeleteStatus(SpeciesStatu SelectedStatus) { try { DataAccessLayer.DeleteObject(SelectedStatus); DataAccessLayer.SaveChanges(System.Data.Objects.SaveOptions.None); } catch (Exception ex) { string s = ex.ToString(); DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedStatus); return false; } DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedStatus); return true; }
private void btnDelete_Click(object sender, EventArgs e) { if (StatusDataAccess.DeleteStatus(SelectedStatus) == false) { MessageBox.Show("Cannot delete, child nodes still exist", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SelectedStatus = null; LoadData(); try { dgStatus.CurrentCell = dgStatus.Rows[0].Cells[0]; dgStatus.Rows[0].Selected = true; } catch { txtStatusId.Text = ""; txtStatusName.Text = ""; } }
/// <summary> /// Deprecated Method for adding a new object to the SpeciesStatus EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSpeciesStatus(SpeciesStatu speciesStatu) { base.AddObject("SpeciesStatus", speciesStatu); }
/// <summary> /// Create a new SpeciesStatu object. /// </summary> /// <param name="statusId">Initial value of the StatusId property.</param> public static SpeciesStatu CreateSpeciesStatu(global::System.Int32 statusId) { SpeciesStatu speciesStatu = new SpeciesStatu(); speciesStatu.StatusId = statusId; return speciesStatu; }
public static int SaveStatus(SpeciesStatu SpeciesStatus) { return DataAccessLayer.SaveChanges(); }
private void SelectStatus(int id) { try { SelectedStatus = StatusDataAccess.GetStatusById(id); txtStatusName.Text = SelectedStatus.StatusText; txtStatusId.Text = SelectedStatus.StatusId.ToString(); } catch { } }