/// <summary> /// Salir del proceso de matrícula y devolver los cupos /// </summary> /// <param name="abort"></param> /// <returns></returns> public int LiberarCuposMatricula(EMatriculaPres abort) { SqlCommand comando = CrearComandoProc("MAT_PresencialLiberarCupos"); comando.Parameters.AddWithValue("@Codigo", abort.Codigo); comando.Parameters.AddWithValue("@Cupos", abort.Cupos); return EjecutarComando(comando); }
/// <summary> /// Reservar la cantidad de cupos si es posible, para /// el curso seleccionado por el Encargado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReservar_Click(object sender, EventArgs e) { try { if (GridCursos.SelectedRows.Count != 0) { DataGridViewRow row = GridCursos.SelectedRows[0]; string codCurso = row.Cells["Cod"].Value.ToString(); string nomCurso = row.Cells["Nombre"].Value.ToString(); int cupos = Convert.ToInt16(nudAReservar.Value); bool aceptaPresencial = Convert.ToBoolean(row.Cells["Presencial"].Value.ToString()); bool aceptaTelefonica = Convert.ToBoolean(row.Cells["Telefonica"].Value.ToString()); bool aceptaEspera = Convert.ToBoolean(row.Cells["ListaEspera"].Value.ToString()); EMatriculaPres reserva = new EMatriculaPres(); reserva.Codigo = codCurso; reserva.Cupos = cupos; // Verificar si el curso acepta el tipo de matrícula elegido if (cmbTipoMat.Text == "Presencial" && aceptaPresencial || cmbTipoMat.Text == "Telefónica" && aceptaTelefonica) { // Comprobar si la matrícula fue aceptada por el servidor if (new MatriculaNeg().ReservarCupos(reserva) && Convert.ToInt16(txtbCupos.Text) >= cupos) { MainForm.panel.Controls.Clear(); EMatriculaPres infoMatricula = new EMatriculaPres(); infoMatricula.Codigo = codCurso; infoMatricula.NombreCurso = nomCurso; infoMatricula.IdTipoMatricula = Convert.ToInt16(cmbTipoMat.SelectedValue); infoMatricula.Cupos = cupos; infoMatricula.AceptaEspera = aceptaEspera; ControlMatriculaPres2 paso2 = new ControlMatriculaPres2(infoMatricula); MainForm.panel.Controls.Add(paso2); paso2.BloquearBotones(); } else { MessageBox.Show("Acción no válida. Reintente más tarde.", "Imposible continuar"); } } else { MessageBox.Show("El curso no acepta el tipo de matrícula seleccionado.", "Imposible continuar"); } } } catch (Exception ex) { MainForm.NotificarExcepcion("MAT011", ex); } }
public ControlMatriculaPres2(EMatriculaPres detalles) { InitializeComponent(); this.sesion = MainForm.sesion; this.codCurso = detalles.Codigo; this.nomCurso = detalles.NombreCurso; this.idTipoMat = detalles.IdTipoMatricula; this.numParticipantes = detalles.Cupos; this.aceptaListaEspera = detalles.AceptaEspera; // Inicia la cuenta regresiva IniciarTemporizador(); }
/// <summary> /// Abortar el proceso de matrícula y regresar los cupos /// </summary> /// <param name="abort"></param> /// <returns></returns> public bool LiberarCuposMatricula(EMatriculaPres abort) { try { if (matriculaDAL.LiberarCuposMatricula(abort) != 0) { // Notificar registro a bitácora return true; } else { return false; } } catch { return false; } }
/// <summary> /// Reservar cupos con control de concurrencia /// </summary> /// <returns>true - si hubo éxito al reservar</returns> public bool ReservarCupos(EMatriculaPres res) { try { if (matriculaDAL.ReservarCupos(res) != 0) { return true; } else { return false; } } catch { return false; } }
/// <summary> /// Reservar cupos si no hay error de concurrencia en la base de /// datos /// </summary> /// <param name="res"></param> /// <returns></returns> public int ReservarCupos(EMatriculaPres res) { SqlCommand comando = CrearComandoProc("MAT_PresencialReservar"); comando.Parameters.AddWithValue("@Codigo", res.Codigo); comando.Parameters.AddWithValue("@Cupos", res.Cupos); var returnParameter = comando.Parameters.Add("@ReturnVal", SqlDbType.Int); returnParameter.Direction = ParameterDirection.ReturnValue; EjecutarComando(comando); return Convert.ToInt16(returnParameter.Value); }
/// <summary> /// Abortar la sesión completamente si se acaba el tiempo o bien, /// si el matriculador decide salir del proceso. /// </summary> private void AbortarSesionMat() { try { // Crear entidad de matrícula EMatriculaPres abort = new EMatriculaPres(); abort.Codigo = codCurso; abort.Cupos = numParticipantes; // 'Devolver' los cupos tomados new MatriculaNeg().LiberarCuposMatricula(abort); MainForm par = (MainForm)this.ParentForm; par.UnlockButtons(); MainForm.panel.Controls.Clear(); MainForm.panel.Controls.Add(new ControlMatriculaPres1()); } catch { } }
private void GridCupos_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (e.RowIndex != -1) { switch (e.ColumnIndex) { case 0: var EditarPart = new EditarParticipante(); DataGridViewRow fila = GridCupos.Rows[e.RowIndex]; List<string> info = new List<string>(); info.Add((fila.Cells["TipoIdentificacion"].Value ?? "").ToString()); info.Add((fila.Cells["Identificacion"].Value ?? "").ToString()); info.Add((fila.Cells["Nombre"].Value ?? "").ToString()); info.Add((fila.Cells["Apellidos"].Value ?? "").ToString()); info.Add((fila.Cells["Telefono"].Value ?? "").ToString()); info.Add((fila.Cells["Correo"].Value ?? "").ToString()); info.Add((fila.Cells["Observaciones"].Value ?? "").ToString()); info.Add((fila.Cells["TipoApoyo"].Value ?? "").ToString()); EditarPart.SetData(info); EditarPart.ShowDialog(); info = EditarPart.GetData(); fila.Cells["TipoIdentificacion"].Value = info[0]; fila.Cells["Identificacion"].Value = info[1]; fila.Cells["Nombre"].Value = info[2]; fila.Cells["Apellidos"].Value = info[3]; fila.Cells["Telefono"].Value = info[4]; fila.Cells["Correo"].Value = info[5]; fila.Cells["Observaciones"].Value = info[6]; fila.Cells["TipoApoyo"].Value = info[7]; EditarPart.Close(); break; case 1: DialogResult dialogResult = MessageBox.Show("¿Está seguro de eliminar " + "la información del participante? Esto liberará el cupo reservado " + "para el curso respectivo.", "Eliminar participante", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { GridCupos.Rows.RemoveAt(e.RowIndex); numParticipantes -= 1; // Crear entidad de matrícula EMatriculaPres abort = new EMatriculaPres(); abort.Codigo = codCurso; abort.Cupos = 1; // 'Devolver' el cupo new MatriculaNeg().LiberarCuposMatricula(abort); } break; } } } catch (Exception ex) { MainForm.NotificarExcepcion("MAT011", ex); } }
/// <summary> /// Limpiar todos los cupos reservados /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLimpiar_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show("¿Está seguro de limpiar " + "la información actual de matrícula? Esto liberará todos los cupos " + "reservados.", "Limpiar matrícula", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { GridCupos.Rows.Clear(); // Crear entidad de matrícula EMatriculaPres abort = new EMatriculaPres(); abort.Codigo = codCurso; abort.Cupos = numParticipantes; // 'Devolver' los cupos new MatriculaNeg().LiberarCuposMatricula(abort); numParticipantes = 0; } } catch { } }