public override void ExecuteNewCommand() { IsEnabled = true; SelectedInventoryCount = null; SelectedInventoryCount = new InventoryCount(); SelectedGroupFromDetail = null; FormTitle = "Nuevo Conteo Fisico"; //ForceDetailsRefresh = true; para no mostar la lista de prod. al cargar el control if (DetailsCount != null) { DetailsCount.Clear(); } ShowDialog(new InventoryCountDetailView(), this); }
private bool ValidateChanges() { if (!ConfirmDialog("Desea guardar los cambios", "Guardar")) { return(false); } if (!DetailsCount.Any()) { ShowErrorMessageBox("Verifique los valores ingresados"); return(false); } if (DetailsCount.Any(d => d.Quantity < 0)) { ShowErrorMessageBox("Error Existen valores negativos , verificar!"); return(false); } if (SelectedInventoryCount.IdInventoryCountL != 0) { ForceDetailsRefresh = true; } // Update details var details = DetailsCount.Where(d => d.Quantity.HasValue && d.Quantity.Value >= 0).ToList(); // Agregar si no tiene if (!SelectedInventoryCount.InventoryCountDetail.Any()) { SelectedInventoryCount.InventoryCountDetail.AddRange(details); } else { var newDetails = details .Where(d => SelectedInventoryCount.InventoryCountDetail.All(inv => inv.ItemCode != d.ItemCode)) .ToList(); // add if we have new details. if (newDetails.Any()) { SelectedInventoryCount.InventoryCountDetail.AddRange(newDetails); } } return(true); }