private async void MethodLoadDetails(ESGR_Pedido ESGR_Pedido) { await Task.Factory.StartNew(() => { try { var vrCollectionMSGR_PedidoDetalle = new BSGR_PedidoDetalle().GetCollectionPedidoDetalle(ESGR_Pedido); Application.Current.Dispatcher.Invoke(() => { CollectionMSGR_PedidoDetalle.Clear(); foreach (var item in vrCollectionMSGR_PedidoDetalle) { CollectionMSGR_PedidoDetalle.Add(new VMSGR_PedidoDetalle() { ESGR_Producto = item.ESGR_Producto, PrecioDolar = (ESGR_TipoCambio != null) ? (item.ESGR_Producto.Precio / (decimal)ESGR_TipoCambio.SelRate) : 0, Cantidad = item.Cantidad, CantidadAux = item.Cantidad, CantidadMesa = item.CantidadMesa, CantidadLlevar = item.CantidadLlevar, Enviado = true }); } MethodCalcularCuenta(); }); } catch (Exception ex) { CmpMessageBox.Show(SGRMessage.TitlePedido, ex.Message, CmpButton.Aceptar); } }); }
private async void MethodCleaningOrder() { await Task.Factory.StartNew(() => { try { Application.Current.Dispatcher.Invoke(() => { CollectionMSGR_PedidoDetalle.Clear(); SelectedESGR_ProductoSubCategoria = null; CollectionESGR_Producto.Clear(); ListVMSGR_PedidoDetalleDelete.Clear(); }); Total = 0; var Opcion = ESGR_Pedido.Opcion; if (Opcion == "I") { var NombreMesa = ESGR_Pedido.Identificador; var NumPersonas = ESGR_Pedido.Cubierto; ESGR_Pedido = new BSGR_Pedido().GetPedido(); ESGR_Pedido.Opcion = Opcion; ESGR_Pedido.Identificador = NombreMesa; ESGR_Pedido.Cubierto = NumPersonas; ESGR_Pedido.ESGR_PedidoTipo = SelectedESGR_PedidoTipo; } } catch (Exception ex) { CmpMessageBox.Show(SGRMessage.TitlePedido, ex.Message, CmpButton.Aceptar); } }); }
private string MethodDetallePedidoXML() { string vrCadena = string.Empty; vrCadena = "<ROOT>"; CollectionMSGR_PedidoDetalle.ToList().ForEach((x) => { vrCadena += "<Listar "; vrCadena += "xIdProducto = \'" + x.ESGR_Producto.IdProducto; vrCadena += "\' xCantidad = \'" + x.Cantidad; vrCadena += "\' xCantidadMesa = \'" + x.CantidadMesa; vrCadena += "\' xCantidadLlevar = \'" + x.CantidadLlevar; vrCadena += "\' xPrecio = \'" + x.ESGR_Producto.Precio; vrCadena += "\' xObservacion = \'" + x.Observacion; vrCadena += "\' xEnviado = \'" + "true"; vrCadena += "\'></Listar>"; }); vrCadena += "</ROOT>"; return(vrCadena); }
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); } }
private void MethodCalcularCuenta() { Total = Convert.ToDecimal(CollectionMSGR_PedidoDetalle.Sum(x => (x.Cantidad * x.ESGR_Producto.Precio))); TotalDolar = Convert.ToDecimal(CollectionMSGR_PedidoDetalle.Sum(x => (x.Cantidad * x.PrecioDolar))); }