Exemple #1
0
        public static void UpdateProducto(Producto obj)
        {
            if (obj == null)
            {
                throw new ArgumentException("El objeto a insertar no puede ser nulo");
            }

            if (obj.ProductoId <= 0)
            {
                throw new ArgumentException("El productoId no puede ser menor o igual que cero");
            }

            if (string.IsNullOrEmpty(obj.Nombre))
            {
                throw new ArgumentException("El nombre no puede ser nulo o vacio");
            }

            if (obj.Precio <= 0)
            {
                throw new ArgumentException("El precio no puede ser menor o igual que cero");
            }

            if (obj.Stock < 0)
            {
                throw new ArgumentException("El stock no puede ser negativo");
            }

            ProductoDSTableAdapters.ProductoTableAdapter adapter = new ProductoDSTableAdapters.ProductoTableAdapter();
            adapter.Update(obj.Nombre, obj.Precio, obj.Stock, obj.ProductoId);
        }