private void btnSeleccionar_Click(object sender, EventArgs e) { try { if (dgvNiveles.SelectedRows.Count == 1) { Int32 ID; ID = Convert.ToInt32(dgvNiveles.CurrentRow.Cells[0].Value); pID = ID; pGS = GruposDB.ObtenerGrupos(ID); // Obtener cantidad Inscritos CantidadInscritos = GruposDB.ObtenerTotalInscritos(ID); DateTime FechaI, FechaA; FechaI = GruposDB.ObtenerFechaInicio(ID); FI = FechaI; FechaA = DateTime.Today; if (rbMensual.Checked == true) { FechaPP = FechaI.AddMonths(1); } else { FechaPP = FechaI.AddDays(7); } if (pGS != null) { txtNivel.Text = pGS.Nivel; txtNivel.Enabled = false; btnRegistrar.Enabled = true; } } else { MessageBox.Show("Seleccione un Nivel de la Lista", "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmRegistrodeGruposyNiveles_Load(object sender, EventArgs e) { if (IDg != null) { btnGuardar.Enabled = false; try { pGS = GruposDB.ObtenerGrupos(int.Parse(IDg)); pHs = HorariosDB.ObtenerHorario(int.Parse(pGS.Horario)); txtHorario.Text = pHs.Dias + " " + pHs.Hora; txtNivel.Text = pGS.Nivel; txtProfesor.Text = pGS.Profesor; dtpFechaInicio.Value = Convert.ToDateTime(pGS.Fecha_Inicio); cbAula.Text = pGS.Aula; dgvNiveles.DataSource = GruposDB.TodosLosGrupos(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { txtProfesor.Enabled = false; txtHorario.Enabled = false; MaximizeBox = false; try { dgvNiveles.DataSource = GruposDB.TodosLosGrupos(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } btnGuardar.Enabled = false; btnEliminar.Enabled = false; btnModificar.Enabled = false; } }
private void btnSeleccionarGrupos_Click(object sender, EventArgs e) { try { if (dgvNiveles.SelectedRows.Count == 1) { Int32 ID; ID = Convert.ToInt32(dgvNiveles.CurrentRow.Cells[0].Value); pGS = GruposDB.ObtenerGrupos(ID); if (pGS != null) { txtProfesor.Text = pGS.Profesor; txtNivel.Text = pGS.Nivel; pHs = HorariosDB.ObtenerHorario(int.Parse(pGS.Horario)); txtHorario.Text = pHs.Dias + " " + pHs.Hora; cbAula.Text = pGS.Aula; string fechaI = dtpFechaInicio.Value.Date.ToString("yyyy-MM-dd"); fechaI = pGS.Fecha_Inicio; btnGuardar.Enabled = false; btnModificar.Enabled = true; btnEliminar.Enabled = true; } else { MessageBox.Show("No se Pudo Cargar el Estudiante, Intentelo Nuevamente", "Registro de Grupos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("No ha seleccionado un Grupo, Seleccione uno de la Tabla", "Registro de Grupos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnModificar_Click(object sender, EventArgs e) { try { if (txtNombre.Text == string.Empty) { MessageBox.Show("Nombre Vacio, Complete El Campo Nombre", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNombre.Focus(); } else if (txtApellido.Text == string.Empty) { MessageBox.Show("Apellido Vacio, Complete El Campo Apellido", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtApellido.Focus(); } else if (txtDireccion.Text == string.Empty) { MessageBox.Show("Direccion Vacia, Complete El Campo Direccion", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDireccion.Focus(); } else if (txtEdad.Text == string.Empty) { MessageBox.Show("Edad Vacia, Complete El Campo Edad", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEdad.Focus(); } else if (dtpFechaNacimiento.Value == DateTime.Today) { MessageBox.Show("Fecha Vacia, Complete El Campo Fecha de Nacimiento Con la fecha de nacimiento", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); dtpFechaNacimiento.Focus(); } else if (txtTelefono.Text == string.Empty) { MessageBox.Show("Telefono Vacio, Complete El Campo Telefono", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtTelefono.Focus(); } else if (txtSector.Text == string.Empty) { MessageBox.Show("Sector Vacio, Complete El Campo Sector", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSector.Focus(); } else if (txtOcupacion.Text == string.Empty) { MessageBox.Show("Ocupacion Vacia, Complete El Campo Ocupacion", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtOcupacion.Focus(); } else if (cbN_Academico.Text == string.Empty) { MessageBox.Show("Nivel Academico Vacio, Complete El Campo Nivel Academico", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); cbN_Academico.Focus(); } else if (cbD_Idioma.Text == string.Empty) { MessageBox.Show("Dominio del Idioma Vacio, Complete El Campo Dominio del Idioma", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); cbD_Idioma.Focus(); } else if (txtNivel.Text == string.Empty) { MessageBox.Show("Nivel Vacio, Complete El Campo Nivel", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNivel.Focus(); } else { // *Actualizar canti Nivel* // Int64 ID = EstudianteSeleccionado.ID; CodigoNivelAnterior = int.Parse(EstudianteDB.ObtenerCodigoNivel(ID)); // ************************ // Estudiante pEstudiante = new Estudiante(); pEstudiante.Nombre = txtNombre.Text; pEstudiante.Apellido = txtApellido.Text; pEstudiante.Direccion = txtDireccion.Text; pEstudiante.Edad = txtEdad.Text; pEstudiante.Fecha_N = dtpFechaNacimiento.Value.Date.ToString("yyyy-MM-dd"); pEstudiante.Telefono = txtTelefono.Text; pEstudiante.Sector = txtSector.Text; pEstudiante.E_Mail = txtEmail.Text; pEstudiante.Ocupacion = txtOcupacion.Text; pEstudiante.Fecha_Ins = dtpFechaActual.Value.Date.ToString("yyyy-MM-dd"); pEstudiante.N_Academico = cbN_Academico.Text; pEstudiante.D_Idioma = cbD_Idioma.Text; pEstudiante.NivelA = txtNivel.Text; pEstudiante.ID = EstudianteSeleccionado.ID; pGS = GruposDB.ObtenerGrupos(pEstudiante.Codigo_Grupo); if (rbMensual.Checked == true) { pEstudiante.Modo_Pago = rbMensual.Text; } else { pEstudiante.Modo_Pago = rbSemanal.Text; } if (pGS.ID > 0 || pGS.Aula != null) { int retorno = EstudianteDB.Modificar(pEstudiante); if (retorno > 0) { if (CodigoNivelAnterior != pGS.ID) { int CantidadEstudiantesGrupoAnt = GruposDB.ObtenerTotalInscritos(CodigoNivelAnterior); int NuevacantGrupoAnt = CantidadEstudiantesGrupoAnt - 1; int R0 = GruposDB.ActualizarCantidadEstudiantes(CodigoNivelAnterior, NuevacantGrupoAnt); int CantEstudiantesNuevoGrupo = GruposDB.ObtenerTotalInscritos(pGS.ID); int NuevaCantNuevoGrupo = CantEstudiantesNuevoGrupo + 1; int R1 = GruposDB.ActualizarCantidadEstudiantes(pGS.ID, NuevaCantNuevoGrupo); if (R1 > 0 & R0 > 0) { MessageBox.Show("Estudiante Modificado con Exito", "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Information); // VIP student if (cbVIP.Checked == true) { EstudianteDB.UpdateVIPstatus("Si", pEstudiante.ID.ToString()); } else { EstudianteDB.UpdateVIPstatus("No", pEstudiante.ID.ToString()); } Limpiar(); btnModificar.Visible = false; btnEliminar.Visible = false; btnRegistrar.Visible = true; lblBuscarAlumno.Visible = true; pGS.ID = 0; } } else { MessageBox.Show("Estudiante Modificado con Exito", "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Information); // VIP student if (cbVIP.Checked == true) { EstudianteDB.UpdateVIPstatus("Si", pEstudiante.ID.ToString()); } else { EstudianteDB.UpdateVIPstatus("No", pEstudiante.ID.ToString()); } Limpiar(); btnModificar.Visible = false; btnEliminar.Visible = false; btnRegistrar.Visible = true; lblBuscarAlumno.Visible = true; } } else { MessageBox.Show("No se Pudo Modificar la informacion", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }; } else { MessageBox.Show("Selecciona un Nivel de la tabla", "Registro de estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }