public static object Agregar_Productos(SPC_GET_PRODUCTO_Result record) { try { using (var DB = new TPVDBEntities()) { DB.SPC_SET_PRODUCTO( null, record.Codigo_Categoria_Producto, record.NombreProducto, null, record.PrecioVenta, record.OrdenProducto, record.Codigo_Tipo_Producto, record.PrecioComoExtra, record.AceptaExtra, record.Impresora, true); } return(new { Result = "OK", Record = record }); } catch { return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de agregar el producto." }); } }
public static object Eliminar_Productos(int Codigo_Producto) { try { using (var DB = new TPVDBEntities()) { DB.SPC_SET_PRODUCTO( Codigo_Producto, null, null, null, null, null, null, null, null, null, false); } return(new { Result = "OK" }); } catch { return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el producto." }); } }
protected void btnGuardarImagen_Click(object sender, EventArgs e) { try { if (_CodigoProducto > 0 && FileFoto.HasFile) { int contentLength = FileFoto.PostedFile.ContentLength; string contentType = FileFoto.PostedFile.ContentType; string fileName = FileFoto.PostedFile.FileName; byte[] pic = new byte[contentLength]; var image = System.Drawing.Image.FromStream(FileFoto.PostedFile.InputStream); var foto = new Bitmap(image.Width, image.Height); var g = Graphics.FromImage(foto); g.Clear(Color.White); var destRect = new Rectangle(0, 0, foto.Width, foto.Height); var srcRect = new Rectangle(0, 0, foto.Width, foto.Height); g.DrawImage(image, destRect, srcRect, GraphicsUnit.Pixel); var MiniFoto = ResizeImage(foto, 86, 114); var miniPic = imageToByteArray(MiniFoto); using (var DB = new TPVDBEntities()) { DB.SPC_SET_PRODUCTO( _CodigoProducto, null, null, miniPic, null, null, null, null, null, null, null); } } //return new { Result = "OK", Record = record }; } catch { //return new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el producto." }; } }