Ejemplo n.º 1
0
        private void btn_del_Click(object sender, EventArgs e)
        {
            int key = int.Parse(this.txt_id.Text);

            using (CatBaseEntities context = new CatBaseEntities())
            {
                cat mew_cat = context.cats.FirstOrDefault(input => input.catID == key);

                context.cats.Remove(mew_cat);
                context.SaveChanges();
                loadgrid();
            }
        }
Ejemplo n.º 2
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            int key = int.Parse(this.txt_id.Text);

            using (CatBaseEntities context = new CatBaseEntities())
            {
                cat mew_cat = context.cats.FirstOrDefault(input => input.catID == key);

                mew_cat.catName = this.txt_name.Text;
                mew_cat.catAge  = int.Parse(this.txt_id.Text);
                mew_cat.ownerID = 1;

                context.SaveChanges();
                loadgrid();
            }
        }
Ejemplo n.º 3
0
 private void btn_create_Click(object sender, EventArgs e)
 {
     using (CatBaseEntities context = new CatBaseEntities())
     {
         int nextID  = context.cats.Last().catID;
         cat mew_cat = new cat
         {
             catID   = nextID,
             catName = this.txt_name.Text,
             catAge  = int.Parse(this.txt_age.Text),
             ownerID = 1
         };
         context.cats.Add(mew_cat);
         context.SaveChanges();
         loadgrid();
     }
 }