private void buttonAceptar_Click(object sender, EventArgs e) { string patente = comboBoxPatente.Text; int estado = Convert.ToInt32(checkBoxEstado.Checked); int chofer = Convert.ToInt32(textBox_chofer_dni.Text); string nombre = textBox_chofer_nombre.Text; var resultado = Mensaje_Pregunta("¿Está seguro que desea modificar el automovil?", "Modificar Automovil"); if (resultado == DialogResult.Yes) { if (modificacionDeEstado == 0) { if (Turno.CheckedItems.Count == 0) { Mensaje_Error("No se ha/n seleccionado turno/s"); return; } } if (DAOAutomovil.choferAsignado(chofer, patente) == true) { Mensaje_Error("El chofer ya posee auto"); return; } if (!(DAOPersona.choferActivo(chofer, nombre))) { Mensaje_Error("El chofer no se encuentra habilitado"); return; } else { DAOAutomovil.modificarAutomovilPorPatente(patente, estado, chofer); this.actualizarTurnosAutomovil(patente); Mensaje_OK("El automovil fue modificado"); this.Close(); } } }
private bool ValidarAutomovil(string patente, int chofer) { int cont = 0; if ((String.IsNullOrEmpty(patente)) || (patente == "")) { Mensaje_Error("Patente del automovil vacia"); cont++; } if (DAOAutomovil.validarPatente(patente)) { Mensaje_Error("La patente ya existe"); cont++; } if (DAOAutomovil.choferAsignado(chofer, patente)) { Mensaje_Error("El chofer ya posee automovil"); cont++; } if (Turno.CheckedItems.Count == 0) { Mensaje_Error("No se ha/n seleccionado turno/s"); cont++; } if (cont == 0) { return(true); } else { return(false); } }