public static bool Insertar(Articulos articulo) { bool obtener = false; using (var db = new SistemaVentasDb()) { try { if (Buscar(articulo.ArticuloId) == null) { db.Articulos.Add(articulo); } else { db.Entry(articulo).State = EntityState.Modified; } db.SaveChanges(); obtener = true; } catch (Exception e) { MessageBox.Show(e.ToString()); //throw; } return(obtener); } }
public static void Eliminar(Ventas factura) { using (var conexion = new SistemaVentasDb()) { try { if (factura != null) { conexion.Entry(factura).State = EntityState.Deleted; conexion.SaveChanges(); } } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } } }
public static void Eliminar(Articulos articulo) { using (var db = new SistemaVentasDb()) { try { if (articulo != null) { db.Entry(articulo).State = EntityState.Deleted; db.SaveChanges(); } } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } } }