public void Agregar(DynamicGrid ubicacionCol , DynamicGrid almacen) { int exito=0; if (String.IsNullOrEmpty(CantIngresar)) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Debe ingresar una cantidad")); return; } else if (int.Parse(CantIngresar) <0) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Debe ingresar una cantidad positiva")); return; } if (selectedProduct != null) { if (int.Parse(selectedProduct.CanAtender) < int.Parse(CantIngresar)) { if (accion == 1) _windowManager.ShowDialog(new AlertViewModel(_windowManager, "La cantidad que se intenta ingresar es mayor a la cantidad pendiente")); else _windowManager.ShowDialog(new AlertViewModel(_windowManager, "La cantidad que se intenta retirar es mayor a la cantidad pendiente")); } else { if (String.IsNullOrEmpty(VolIngresar)) VolIngresar = "0"; if (accion == 1) exito = ubicacionCol.AgregarProductos(int.Parse(CantIngresar), int.Parse(VolIngresar), SelectedProduct.IdProducto); else exito=ubicacionCol.DisminuirProductos(int.Parse(CantIngresar), SelectedProduct.IdProducto); if (exito > 0) selectedProduct.CanAtender = (int.Parse(selectedProduct.CanAtender) - int.Parse(CantIngresar)).ToString(); LstProductos = new List<ProductoCant>(LstProductos); } } VolIngresar = ""; CantIngresar = ""; }
public void Disminuir(DynamicGrid ubicacionCol, DynamicGrid almacen) { Evaluador eva = new Evaluador(); int exito = 0; if (String.IsNullOrEmpty(TxtCantidad)) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Debe ingresar una cantidad")); return; } else if (!eva.esNumeroEntero(TxtCantidad)) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Debe ingresar un número")); return; } else if (int.Parse(TxtCantidad) < 0) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Debe ingresar una cantidad mayor a cero")); return; } else if (ubicacionCol.SelectedProduct != null) { exito = ubicacionCol.DisminuirProductos(int.Parse(TxtCantidad), ubicacionCol.SelectedProduct.IdProducto); if (exito == 1) { int index = LstProductos.FindIndex(x => x.IdProducto == ubicacionCol.SelectedProduct.IdProducto); if (index >= 0) { LstProductos[index].CanAtender = "" + (int.Parse(LstProductos[index].CanAtender) + int.Parse(TxtCantidad)); } else { ubicacionCol.SelectedProduct.CanAtender = TxtCantidad; LstProductos.Add(ubicacionCol.SelectedProduct); } LstProductos = new List<ProductoCant>(LstProductos); } } }