private void Execute_ActualizarCommand() { RegistrarClienteView registrarClienteView = new RegistrarClienteView(true, CurrentCliente); registrarClienteView.ShowDialog(); if (registrarClienteView.isUpdated) { try { if (TransporteDR.ClienteBO.Actualizar(CurrentCliente)) { MessageBox.Show($"{CurrentCliente.Ruc} Actualizado con exito"); } else { registrarClienteView.ToDefaultCliente(CurrentCliente); MessageBox.Show("Algo ha ocurrido con el proceso de actualizacion, por favor intentar de nuevo o reiniciar el computador.\nSi el problema persiste, contactar con el encargado del Sistema"); } } catch (Exception ex) { MessageBox.Show(ex.Message); if (!(ex.InnerException is null)) { MessageBox.Show(ex.InnerException.Message); } } //Primero se lo paso a la capa negocio para que lo registre, si lo registra, lo pongo en la capa Presentacion } }
private void Execute_AgregarCommand() { RegistrarClienteView registrarClienteView = new RegistrarClienteView(); registrarClienteView.ShowDialog(); if (registrarClienteView.isRegistered) { var newCliente = registrarClienteView.GetCliente(); try { if (TransporteDR.ClienteBO.Registrar(newCliente)) { LoadData(); CurrentCliente = ListaClientes.FirstOrDefault(x => x.Ruc == newCliente.Ruc); /*ListaClientes.Add(newCliente); * CurrentCliente = newCliente;*/ MessageBox.Show($"{newCliente.Ruc} Registrado con exito"); } else { MessageBox.Show("Algo ha ocurrido con el proceso de registro, por favor intentar de nuevo o reiniciar el computador.\nSi el problema persiste, contactar con el encargado del Sistema"); } } catch (Exception ex) { MessageBox.Show(ex.Message); if (!(ex.InnerException is null)) { MessageBox.Show(ex.InnerException.Message); } } } /*if (registrarPersonaView.isRegistered) * { * listaPersonas.Add(registrarPersonaView.GetPersona()); * }*/ //MessageBox.Show("Agregar persona View"); }