private void Execute_AgregarCommand() { RegistrarHistorialView registrarHistorialView = new RegistrarHistorialView(false, null, ConductoresViewModel.Instance.ListaConductores, UnidadVehicularViewModel.Instance.ListaUnidadesVehiculares); registrarHistorialView.ShowDialog(); if (registrarHistorialView.isRegistered) { var newHistorial = registrarHistorialView.GetHistorial(); //newHistorial.Id = ListaHistoriales. try { //Primero se lo paso a la capa negocio para que lo registre, si lo registra, lo pongo en la capa Presentacion if (TransporteDR.HistorialBO.Registrar(newHistorial)) { LoadData(); CurrentHistorial = ListaHistoriales.FirstOrDefault(x => x.Id == newHistorial.Id); MessageBox.Show($"{newHistorial.Id} 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");*/ }
private void Execute_ActualizarCommand() { RegistrarHistorialView registrarHistorialView = new RegistrarHistorialView(true, CurrentHistorial, ConductoresViewModel.Instance.ListaConductores, UnidadVehicularViewModel.Instance.ListaUnidadesVehiculares); registrarHistorialView.ShowDialog(); if (registrarHistorialView.isUpdated) { try { //Primero se lo paso a la capa negocio para que lo registre, si lo registra, lo pongo en la capa Presentacion if (TransporteDR.HistorialBO.Actualizar(CurrentHistorial)) { int id = CurrentHistorial.Id; MessageBox.Show($"{CurrentHistorial.Id} Actualizado con exito"); LoadData(); CurrentHistorial = ListaHistoriales.FirstOrDefault(x => x.Id == id); } else { registrarHistorialView.ToDefaultHistorial(CurrentHistorial); 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); } } } }