public bool Update(Producto o)
        {
            try
            {
                using (var db = new DymContext())
                {
                    db.Entry(o).State = EntityState.Modified;

                    foreach (var item in db.ProductoSustancia.Where(x => x.ProductoId == o.ProductoId).ToList())
                    {
                        db.Remove(item);
                    }

                    db.SaveChanges();

                    foreach (var sustancia in o.ProductoSustancia)
                    {
                        db.Add(sustancia);
                    }

                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
            }
            return(false);
        }
 public bool Update(CMetodopago o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             return(db.SaveChanges() > 0 ? true : false);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje("Algo salio mal con: " + MethodBase.GetCurrentMethod().Name + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
Example #3
0
 public bool Update(InformeCategoria o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Update(Actualizacion o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Algo salio mal @ " + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Update(CambiosPrecio o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Entry(o).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Delete(Impuesto o)
 {
     try
     {
         using (var db = new DymContext())
         {
             o.IsDeleted       = true;
             db.Entry(o).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Algo salio mal @" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }