private void btnSave_Click(object sender, EventArgs e) { var request = new Business.UpdateAccountTreeListRequest( list.GetInsertedItems(), list.GetUpdatedItems(), list.GetDeletedItems()); if (request.IsValid()) { request.Run(); RefreshList(); } else { Validation.ValidationResultBase results = request.GetValidationResult(); if (results.Level == Validation.Level.Empty) { Console.WriteLine("Sin errores"); } else { Console.WriteLine("Máximo error: {0}", results.Level); } Console.WriteLine("Cantidad de propiedades con errores: {0}", results.Length); MessageBox.Show(results.GetResultText()); } }
private void btnSave_Click(object sender, EventArgs e) { var request = new Business.UpdateCompleteAccountTreeRequest(); var createdTrees = new List <AccountTreeListItem>(); var updatedTrees = new List <AccountTreeListItem>(); var updatedAccounts = new List <ContableAccount>(); var createdAccounts = new List <ContableAccount>(); foreach (var tree in accountTreesTreeView1.Trees) { if (tree.IsNew()) { createdTrees.Add(tree); } else if (tree.IsDirty()) { updatedTrees.Add(tree); } } foreach (var account in accountTreesTreeView1.Accounts) { if (account.IsNew()) { createdAccounts.Add(account); } else if (account.IsDirty()) { updatedAccounts.Add(account); } } request.CreatedTrees = createdTrees.ToArray(); request.UpdatedTrees = updatedTrees.ToArray(); request.CreatedAccounts = createdAccounts.ToArray(); request.UpdatedAccounts = updatedAccounts.ToArray(); if (request.IsValid()) { request.Run(); RefreshTree(); } else { Validation.ValidationResultBase results = request.GetValidationResult(); if (results.Level == Validation.Level.Empty) { Console.WriteLine("Sin errores"); } else { Console.WriteLine("Máximo error: {0}", results.Level); } Console.WriteLine("Cantidad de propiedades con errores: {0}", results.Length); MessageBox.Show(results.GetResultText()); } }