예제 #1
0
        public bool ActualizarProducto()
        {
            try
            {
                DALC.QueOfrecesEntities ctx  = new DALC.QueOfrecesEntities();
                DALC.PRODUCTO           prod = ctx.PRODUCTO.First(p => p.ID_PRODUCTO == IdProducto);

                prod.RUBRO_ID       = this.IdRubro;
                prod.PRECIO         = this.Precio;
                prod.SKU            = this.Sku;
                prod.CODIGO_INTERNO = this.CodigoInterno;
                prod.NOMBRE         = this.Nombre;
                prod.DESCRIPCION    = this.Descripcion;


                ctx.SaveChanges();
                ctx = null;

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #2
0
        public bool EliminarProducto()
        {
            try
            {
                DALC.QueOfrecesEntities ctx  = new DALC.QueOfrecesEntities();
                DALC.PRODUCTO           prod = ctx.PRODUCTO.First(p => p.ID_PRODUCTO == IdProducto);

                ctx.Entry(prod).State = System.Data.EntityState.Deleted;
                ctx.SaveChanges();
                ctx = null;

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public bool CrearProducto()
        {
            try
            {
                DALC.QueOfrecesEntities ctx  = new DALC.QueOfrecesEntities();
                DALC.PRODUCTO           prod = new DALC.PRODUCTO();

                prod.ID_PRODUCTO    = this.IdProducto;
                prod.RUBRO_ID       = this.IdRubro;
                prod.PRECIO         = this.Precio;
                prod.SKU            = this.Sku;
                prod.CODIGO_INTERNO = this.CodigoInterno;
                prod.NOMBRE         = this.Nombre;
                prod.DESCRIPCION    = this.Descripcion;

                ctx.PRODUCTO.Add(prod);

                ctx.SaveChanges();
                ctx = null;

                return(true);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(false);
            }
        }