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 Delete(CMetodopago o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Remove(o);
             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 Delete(InformeCategoria o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Remove(o);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Delete(Actualizacion o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Remove(o);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Algo salio mal @ " + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Delete(string Id)
 {
     try
     {
         using (var db = new DymContext())
         {
             var temp = db.CMetodopago.FirstOrDefault(x => x.MetodoPagoId == Id);
             if (temp != null)
             {
                 db.Remove(temp);
                 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);
 }
 public bool DeleteOne(int Id)
 {
     try
     {
         using (var db = new DymContext())
         {
             var temp = db.Cxp.FirstOrDefault(x => x.CxpId == Id);
             if (temp != null)
             {
                 db.Remove(temp);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool Delete(int Id)
 {
     try
     {
         using (var db = new DymContext())
         {
             var temp = db.Actualizacion.FirstOrDefault(x => x.ActualizacionId == Id);
             if (temp != null)
             {
                 db.Remove(temp);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Algo salio mal @ " + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }
 public bool DeleteOne(Venta o)
 {
     try
     {
         using (var db = new DymContext())
         {
             db.Remove(o);
             if (db.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         Ambiente.Mensaje(Ambiente.CatalgoMensajes[-1] + "@" + GetType().Name + "\n" + ex.ToString());
     }
     return(false);
 }