Beispiel #1
0
 public static bool DeleteGenus(Genus SelectedGenus)
 {
     try
     {
         DataAccessLayer.DeleteObject(SelectedGenus);
         DataAccessLayer.SaveChanges(System.Data.Objects.SaveOptions.None);
     }
     catch (Exception ex)
     {
         string s = ex.ToString();
         DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedGenus);
         return false;
     }
     DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedGenus);
     return true;
 }
Beispiel #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (GenusDataAccess.DeleteGenus(SelectedGenus) == false)
            {
                MessageBox.Show("Cannot delete, child nodes still exist", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            SelectedGenus = null;
            LoadData();
            try
            {
                dgGenus.CurrentCell = dgGenus.Rows[0].Cells[0];
                dgGenus.Rows[0].Selected = true;
            }
            catch
            {
                txtGenusId.Text = "";
                txtGenusName.Text = "";
            }
        }
Beispiel #3
0
 public static int SaveGenus(Genus SelectedGenus)
 {
     return DataAccessLayer.SaveChanges();
 }
Beispiel #4
0
 /// <summary>
 /// Create a new Genus object.
 /// </summary>
 /// <param name="genusId">Initial value of the GenusId property.</param>
 public static Genus CreateGenus(global::System.Int32 genusId)
 {
     Genus genus = new Genus();
     genus.GenusId = genusId;
     return genus;
 }
Beispiel #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Genuss EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGenuss(Genus genus)
 {
     base.AddObject("Genuss", genus);
 }
Beispiel #6
0
 private void SelectGenus(int id)
 {
     try
     {
         SelectedGenus = GenusDataAccess.GetGenusById(id);
         txtGenusName.Text = SelectedGenus.GenusName;
         txtGenusId.Text = SelectedGenus.GenusId.ToString();
     }
     catch { }
 }