/// <summary> /// Insertar, Editar y Eliminar Producto /// </summary> /// <param name="ESGR_Producto">Objecto de la Entidad Producto</param> public void TransProducto(ESGR_Producto ESGR_Producto) { try { var objCmpSql = new CmpSql(SGRVariables.ConectionString); objCmpSql.CommandProcedure("spSGR_SET_Producto"); objCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, ESGR_Producto.Opcion); objCmpSql.AddParameter("@IdProducto", SqlDbType.Int, ESGR_Producto.IdProducto); objCmpSql.AddParameter("@IdSubCategoria", SqlDbType.SmallInt, ESGR_Producto.ESGR_ProductoSubCategoria.IdSubCategoria); objCmpSql.AddParameter("@Producto", SqlDbType.VarChar, ESGR_Producto.Producto); objCmpSql.AddParameter("@Precio", SqlDbType.Decimal, ESGR_Producto.Precio); objCmpSql.AddParameter("@Imagen", SqlDbType.Image, ESGR_Producto.Imagen); objCmpSql.ExecuteNonQuery(); } catch (Exception) { throw; } }
private void MethodAddProduct(ESGR_Producto ESGR_Producto) { bool MsjMostrado = false; if (ESGR_Producto == null) { return; } if (ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.ValidaStock && ESGR_Producto.Stock <= 5 && ESGR_Producto.Stock != 0) { CmpMessageBox.Show(SGRMessage.TitlePedido, "Solo quedan " + ESGR_Producto.Stock + " unidades de " + ESGR_Producto.Producto, CmpButton.Aceptar); MsjMostrado = true; } if (!CollectionMSGR_PedidoDetalle.ToList().Exists(x => x.ESGR_Producto.IdProducto == ESGR_Producto.IdProducto) && ((ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.ValidaStock && ESGR_Producto.Stock > 1) || !ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.ValidaStock)) { var FirstDelete = ListVMSGR_PedidoDetalleDelete.FirstOrDefault(x => x.ESGR_Producto.IdProducto == ESGR_Producto.IdProducto); if (FirstDelete != null) { FirstDelete.Cantidad = 1; FirstDelete.Enviado = (FirstDelete.Cantidad == FirstDelete.CantidadAux); CollectionMSGR_PedidoDetalle.Add(FirstDelete); ListVMSGR_PedidoDetalleDelete.Remove(FirstDelete); } else { CollectionMSGR_PedidoDetalle.Add(new VMSGR_PedidoDetalle() { ESGR_Producto = ESGR_Producto, PrecioDolar = (ESGR_TipoCambio != null) ? ESGR_Producto.Precio / (decimal)ESGR_TipoCambio.SelRate : 0, MsjMostrado = MsjMostrado, Cantidad = 1 }); } MethodCalcularCuenta(); } else if (ESGR_Producto.ESGR_ProductoSubCategoria.ESGR_ProductoCategoria.ValidaStock && ESGR_Producto.Stock < 1) { CmpMessageBox.Show(SGRMessage.TitlePedido, "Stock insuficiente", CmpButton.Aceptar); } }
public VMSGR_PedidoDetalle() { ESGR_Producto = new ESGR_Producto(); PropertyVisibilityComentario = Visibility.Collapsed; }