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 void MethodLoadMesa(ESGR_Pedido ESGR_Pedido) { string[] ParametersList = ESGR_Pedido.CadenaMesa.Split("|".ToCharArray()); CollectionSelectESGR_Mesa.Clear(); for (int x = 1; x < ParametersList.Count(); x++) { CollectionSelectESGR_Mesa.Add(new ESGR_Mesa() { IdMesa = Convert.ToInt16(ParametersList[x]) }); } }
private async void MethodLoadPedido(ESGR_Pedido ESGR_Pedido) { await Task.Factory.StartNew(() => { try { ESGR_VentaCuenta.ESGR_Venta.ESGR_Pedido = ESGR_Pedido; if (CollectionESGR_PedidoDetalle.Count == 0) { PropertyFiltroPedido = string.Empty; } Application.Current.Dispatcher.Invoke(() => { if (ESGR_VentaCuenta.Opcion == "I") { CollectionESGR_VentaDetalle.Clear(); CollectionESGR_PedidoDetalle.ToList().ForEach(x => { CollectionESGR_VentaDetalle.Add(new ESGR_VentaDetalle() { Cantidad = x.Cantidad, ESGR_Producto = x.ESGR_Producto, ESGR_VentaCuenta = this.ESGR_VentaCuenta, Importe = 0 }); }); } }); MethodCalcularTotales(); } catch (Exception ex) { CmpMessageBox.Show(SGRMessage.AdministratorVenta, ex.Message, CmpButton.Aceptar); } }); }
/// <summary> /// Insertar, Editar y Eliminar Pedido /// </summary> /// <param name="ESGR_Pedido">Objecto de la Entidad Pedido</param> public void TransPedido(ESGR_Pedido ESGR_Pedido) { try { var objCmpSql = new CmpSql(SGRVariables.ConectionString); objCmpSql.CommandProcedure("spSGR_SET_Pedido"); objCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, ESGR_Pedido.Opcion); objCmpSql.AddParameter("@IdPedidoTipo", SqlDbType.SmallInt, ESGR_Pedido.ESGR_PedidoTipo.IdPedidoTipo); objCmpSql.AddParameter("@IdEmpSucursal", SqlDbType.SmallInt, SGRVariables.ESGR_Usuario.ESGR_Empresa.IdEmpresa); objCmpSql.AddParameter("@IdUsuarioPedido", SqlDbType.Int, SGRVariables.ESGR_Usuario.IdUsuario); objCmpSql.AddParameter("@CodEstado", SqlDbType.Char, ESGR_Pedido.ESGR_Estado.CodEstado); objCmpSql.AddParameter("@Identificador", SqlDbType.VarChar, ESGR_Pedido.Identificador); objCmpSql.AddParameter("@CadenaMesa", SqlDbType.VarChar, ESGR_Pedido.CadenaMesa); objCmpSql.AddParameter("@Cubierto", SqlDbType.SmallInt, ESGR_Pedido.Cubierto); objCmpSql.AddParameter("@Observacion", SqlDbType.VarChar, ESGR_Pedido.Observacion); objCmpSql.AddParameter("@DetalleXML", SqlDbType.NText, ESGR_Pedido.CadenaDetalleXML); objCmpSql.AddParameter("@PedidoMesaXML", SqlDbType.NText, ESGR_Pedido.ESGR_Mesa.DetalleMesaXML); if (ESGR_Pedido.Opcion == "I") { objCmpSql.AddParameterOut("@IdPedido", SqlDbType.SmallInt, 4); objCmpSql.ExecuteNonQuery(); ESGR_Pedido.IdPedido = Convert.ToInt32(objCmpSql.GetParameterOut("@IdPedido")); } else { objCmpSql.AddParameter("@IdPedido", SqlDbType.SmallInt, ESGR_Pedido.IdPedido); objCmpSql.ExecuteNonQuery(); } } catch (Exception) { throw; } }
/// <summary> /// Lista de Pedido Detalle /// </summary> /// <returns>Colección de las Pedido Detalle</returns> public CmpObservableCollection <ESGR_PedidoDetalle> GetCollectionPedidoDetalle(ESGR_Pedido ESGR_Pedido) { try { var objCmpSql = new CmpSql(SGRVariables.ConectionString); var CollectionPedidoDetalle = new CmpObservableCollection <ESGR_PedidoDetalle>(); objCmpSql.CommandProcedure("spSGR_GET_BusquedaGeneral"); objCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, "AdministrarPedidoDetalle"); objCmpSql.AddParameter("@Filtro", SqlDbType.VarChar, "%"); objCmpSql.AddParameter("@ParameterId", SqlDbType.Int, ESGR_Pedido.IdPedido); DataTable dt = objCmpSql.ExecuteDataTable(); for (int x = 0; x < dt.Rows.Count; x++) { CollectionPedidoDetalle.Add(new ESGR_PedidoDetalle { ESGR_Pedido = new ESGR_Pedido() { IdPedido = (dt.Rows[x]["IdPedido"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdPedido"]) : Convert.ToInt16(0), }, ESGR_Producto = new ESGR_Producto() { IdProducto = (dt.Rows[x]["IdProducto"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["IdProducto"]) : Convert.ToInt16(0), Producto = (dt.Rows[x]["Producto"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Producto"]) : string.Empty, Precio = (dt.Rows[x]["Precio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Precio"]) : Convert.ToDecimal(0), ESGR_ProductoSubCategoria = new ESGR_ProductoSubCategoria() { ESGR_ProductoCategoria = new ESGR_ProductoCategoria() { Impresora = (dt.Rows[x]["Impresora"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Impresora"]) : string.Empty } } }, Cantidad = (dt.Rows[x]["Cantidad"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["Cantidad"]) : Convert.ToInt16(0), CantidadMesa = (dt.Rows[x]["CantidadMesa"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["CantidadMesa"]) : Convert.ToInt16(0), CantidadLlevar = (dt.Rows[x]["CantidadLlevar"] != DBNull.Value) ? Convert.ToInt16(dt.Rows[x]["CantidadLlevar"]) : Convert.ToInt16(0), Enviado = (dt.Rows[x]["Enviado"] != DBNull.Value) ? Convert.ToBoolean(dt.Rows[x]["Enviado"]) : false, }); } return(CollectionPedidoDetalle); } catch (Exception) { throw; } }