Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
        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;
                }
            }
        }