private void btnGuardar_Click(object sender, EventArgs e) { if (puedeGuardar()) { if (diaPuede()) { if (horaPuede() == 0) { tn.turno.Especialidad = ((KeyValuePair <int, String>)cbxEspecialidades.SelectedItem).Value; tn.turno.idEspecialidad = Convert.ToString(((KeyValuePair <int, String>)cbxEspecialidades.SelectedItem).Key); tn.turno.idPaciente = tbxIdPaciente.Text; tn.turno.ApellidoPaciente = tbxApellido.Text; tn.turno.ApellidoProfesional = ((KeyValuePair <int, String>)cbxProfesionales.SelectedItem).Value; tn.turno.idProfesional = Convert.ToString(((KeyValuePair <int, String>)cbxProfesionales.SelectedItem).Key); tn.turno.FechaTurno = diaDeTurno; int res = tn.guardarNuevoTurno(false); MessageBox.Show("Se guardo con exito " + res + "Registro/s"); Close(); } else if (horaPuede() == 1) { if (MessageBox.Show("la hora seleccionada del truno ya fue tomada\n¿Desea Reservar un sobreturno?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { tn.turno.Especialidad = (String)cbxEspecialidades.SelectedItem; tn.turno.idPaciente = tbxIdPaciente.Text; tn.turno.ApellidoPaciente = tbxApellido.Text; tn.turno.ApellidoProfesional = (String)cbxProfesionales.SelectedItem; tn.turno.FechaTurno = diaDeTurno; int res = tn.guardarNuevoTurno(true); MessageBox.Show("Se guardo con exito " + res + "Registro/s"); Close(); } } else { MessageBox.Show("No pueden tomarse mas turnos para el horario seleccionado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("El profesional no atiende el dia seleccionado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Faltan campos por completar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }