Пример #1
0
        public void Borrar()
        {
            if (this.Color.Nombre == null)
            {
                MessageBox.Show("No digitó el color a borrar");
                return;
            }

            using (var dbc = new WpfEntityDbContext())
            {
                try
                {
                    var borr = (from p in dbc.Colores
                                where p.Nombre == this.Color.Nombre
                                select p).Single();
                    dbc.Colores.Remove(borr);
                    dbc.SaveChanges();
                    this.ListaC = new ObservableCollection <Color>(dbc.Colores);
                }
                catch (Exception er)
                {
                    MessageBox.Show("Error " + er.Message);
                    if (er.InnerException != null)
                    {
                        MessageBox.Show("Error " + er.InnerException.Message);
                    }
                }
            }
        }
Пример #2
0
 public void Insertar()
 {
     using (var dbc = new WpfEntityDbContext())
     {
         if (this.Color.Nombre == null)
         {
             MessageBox.Show("No digitó el nombre del color a insertar");
             return;
         }
         dbc.Colores.Add(this.Color);
         try
         {
             dbc.SaveChanges();
             this.Consultar();
         }
         catch (Exception er)
         {
             MessageBox.Show("Error " + er.Message);
             if (er.InnerException != null)
             {
                 MessageBox.Show("Error " + er.InnerException.Message);
             }
         }
     }
 }
Пример #3
0
 public void Modifica()
 {
     if (this.Raza.Nombre == null)
     {
         MessageBox.Show("No digitó el nombre de la raza a modificar");
         return;
     }
     using (var dbc = new WpfEntityDbContext())
     {
         var raza = dbc.Razas.Find(this.Raza.RazaID);
         //dbc.Razas.Attach(raza);
         raza.Detalle = this.Raza.Detalle;
         raza.Nombre  = this.Raza.Nombre;
         try
         {
             dbc.SaveChanges();
             this.Consultar();
         }
         catch (Exception er)
         {
             MessageBox.Show("Error " + er.Message);
             if (er.InnerException != null)
             {
                 MessageBox.Show("Error " + er.InnerException.Message);
             }
         }
     }
 }
Пример #4
0
 public void Modifica()
 {
     if (this.Color.Nombre == null)
     {
         MessageBox.Show("No digitó el nombre del color a modificar");
         return;
     }
     using (var dbc = new WpfEntityDbContext())
     {
         var color = dbc.Colores.Find(this.Color.ColorID);
         color.Nombre = this.Color.Nombre;
         try
         {
             dbc.SaveChanges();
             this.Consultar();
         }
         catch (Exception er)
         {
             MessageBox.Show("Error " + er.Message);
             if (er.InnerException != null)
             {
                 MessageBox.Show("Error " + er.InnerException.Message);
             }
         }
     }
 }
Пример #5
0
 public void Modifica()
 {
     if (this.Animal.Nombre == null)
     {
         MessageBox.Show("No digitó el nombre del animal a modificar");
         return;
     }
     using (var dbc = new WpfEntityDbContext())
     {
         var animal = dbc.Animales.Find(this.Animal.AnimalID);
         animal.RazaID   = this.Animal.RazaID;
         animal.Nombre   = this.Animal.Nombre;
         animal.FechaNac = this.Animal.FechaNac;
         animal.ColorID  = this.Animal.ColorID;
         animal.Peso     = this.Animal.Peso;
         animal.Valor    = this.Animal.Valor;
         try
         {
             dbc.SaveChanges();
             this.Consultar();
         }
         catch (Exception er)
         {
             MessageBox.Show("Error " + er.Message);
             if (er.InnerException != null)
             {
                 MessageBox.Show("Error " + er.InnerException.Message);
             }
         }
     }
 }