private void btnEliminar_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Seguro que desea Eliminar el Estudiante?", "Registro Estudiantil", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { int retorno = EstudianteDB.EliminarEstudiante(EstudianteSeleccionado); if (retorno > 0) { int CantidadEstudiantesNi = GruposDB.ObtenerTotalInscritos(EstudianteSeleccionado.Codigo_Grupo); int NuevaCantidad = CantidadEstudiantesNi - 1; int R0 = GruposDB.ActualizarCantidadEstudiantes(EstudianteSeleccionado.Codigo_Grupo, NuevaCantidad); btnRegistrar.Visible = true; btnEliminar.Visible = false; btnModificar.Visible = false; lblBuscarAlumno.Visible = true; if (R0 > 0) { MessageBox.Show("Estudiante Eliminado Esxitosamente", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } else { MessageBox.Show("No se Pudo Eliminar el Estudiante, Intentelo Nuevamente", "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmBusquedaDeAlumnos_Load(object sender, EventArgs e) { if (state == false) { try { dataGridView1.DataSource = EstudianteDB.TodosEstudiante(); btnModificar.Visible = false; btnEliminar.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { try { dataGridView1.DataSource = EstudianteDB.TodosEstudiante(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } btnSeleccionarAlumno.Visible = false; } }
private void btnBuscarEstudiante_Click(object sender, EventArgs e) { try { dgvEstudiantes.DataSource = EstudianteDB.BuscarEstudiantePorMatrc(int.Parse(txtMatricula.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.SelectedRows.Count == 1) { Int64 ID = Convert.ToInt64(dataGridView1.CurrentRow.Cells[13].Value); EstudianteSeleccionado = EstudianteDB.SeleccionarEstudiante(ID); this.Close(); frmCargaEstudiante pEstudiante = new frmCargaEstudiante(); pEstudiante.Show(); } else { MessageBox.Show("Error, No se ha seleccionado ningun Estudiante, Seleccione otra vez", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void txtMatricula_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { if (txtMatricula.Text == string.Empty) { MessageBox.Show("La Matricula esta vacia, Digite una matricula valida", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { if (EstudianteDB.ObtenerApellido(int.Parse(txtMatricula.Text)) == null) { MessageBox.Show("El Estudiante no Existe, Digite un Estudiante Valido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (rbExamenEscritos.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExmenEscrM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes Escritos"; } else if (rbExamenLectura.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExamenLecM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes de Lectura"; } else if (rbExamenOral.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExamenOralM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes Oral"; } else { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExpM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Exposicion"; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void txtMatricula_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { string nombre, apellido, matricula; try { Estudiante pE = new Estudiante(); if (txtNombre.Text == string.Empty) { nombre = ""; } else { nombre = txtNombre.Text; } if (txtApellido.Text == string.Empty) { apellido = ""; } else { apellido = txtApellido.Text; } if (txtMatricula.Text == string.Empty) { matricula = ""; } else { matricula = txtMatricula.Text; } nombre = txtNombre.Text; apellido = txtApellido.Text; matricula = txtMatricula.Text; dataGridView1.DataSource = EstudianteDB.BuscarEstudiante(nombre, apellido, matricula); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void rbExamenEscritos_CheckedChanged(object sender, EventArgs e) { if (txtMatricula.Text == string.Empty) { } else { if (EstudianteDB.ObtenerApellido(int.Parse(txtMatricula.Text)) == null) { } else { try { if (rbExamenEscritos.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExmenEscrM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes Escritos"; } else if (rbExamenLectura.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExamenLecM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes de Lectura"; } else if (rbExamenOral.Checked == true) { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExamenOralM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Examenes Oral"; } else { dgvListaExamenes.DataSource = NotasDB.TodasLasNotasExpM(int.Parse(txtMatricula.Text), dtpFechaExamen.Value.ToString("yyyy-MM-dd")); lblTitulo.Text = "Exposicion"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnSeleccionarAlumno_Click(object sender, EventArgs e) { try { if (dataGridView1.SelectedRows.Count == 1) { Int64 ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[12].Value); EstudianteSeleccionado = EstudianteDB.SeleccionarEstudiante(ID); this.Close(); } else { MessageBox.Show("Error, No se ha seleccionado ningun Estudiante, Seleccione otra vez", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnBuscar_Click(object sender, EventArgs e) { string nombre, apellido, matricula; try { Estudiante pE = new Estudiante(); if (txtNombre.Text == string.Empty) { nombre = ""; } else { nombre = txtNombre.Text; } if (txtApellido.Text == string.Empty) { apellido = ""; } else { apellido = txtApellido.Text; } if (txtMatricula.Text == string.Empty) { matricula = ""; } else { matricula = txtMatricula.Text; } nombre = txtNombre.Text; apellido = txtApellido.Text; matricula = txtMatricula.Text; dataGridView1.DataSource = EstudianteDB.BuscarEstudiante(nombre, apellido, matricula); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnEliminar_Click(object sender, EventArgs e) { frmRegistro re = new frmRegistro(); if (dataGridView1.SelectedRows.Count == 1) { try { int ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[12].Value); re.GetIDestudiante = EstudianteDB.SeleccionarEstudiante(ID); re.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("No se ha seleccionado un estudiante de la tabla", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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); } }
private void btnRegistrar_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 { Estudiante pE = new Estudiante(); pE.Nombre = txtNombre.Text; pE.Apellido = txtApellido.Text; pE.D_Idioma = cbD_Idioma.Text; pE.Direccion = txtDireccion.Text; pE.E_Mail = txtEmail.Text; pE.Edad = txtEdad.Text; pE.Fecha_Ins = dtpFechaActual.Value.Date.ToString("yyyy-MM-dd"); pE.Fecha_N = dtpFechaNacimiento.Value.Date.ToString("yyyy-MM-dd"); pE.N_Academico = cbN_Academico.Text; pE.Ocupacion = txtOcupacion.Text; pE.Sector = txtSector.Text; pE.Telefono = txtTelefono.Text; pE.NivelA = txtNivel.Text; /* Struct Utilizado para rellenar la Asistencia */ Asistencia pA = new Asistencia(); if (rbMensual.Checked == true) { pE.Modo_Pago = rbMensual.Text; } else { pE.Modo_Pago = rbSemanal.Text; } pE.Codigo_Grupo = pGS.ID; int r = EstudianteDB.RegistrarEstudiante(pE); if (r > 0) { MessageBox.Show("Estudiante Registrado con exito!", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Information); string matricula = EstudianteDB.ObtenerMatricula(pE); if (matricula != null) { MessageBox.Show("La Matricula del nuevo estudiante es: " + matricula, "Registro", MessageBoxButtons.OK, MessageBoxIcon.Information); if (cbVIP.Checked == true) { string res = "Si"; EstudianteDB.UpdateVIPstatus(res, matricula.ToString()); } else { string res = "No"; EstudianteDB.UpdateVIPstatus(res, matricula.ToString()); } string FechaProximoP = FechaPP.ToString("yyyy-MM-dd"); EstudianteDB.ActualizarProximoPago(int.Parse(matricula), FechaProximoP); /* Datos para registrar Asistencia */ pA.Nombre = txtNombre.Text + " " + txtApellido.Text; pA.Matricula = int.Parse(matricula); pA.Fecha_Inicio = DateTime.Today.Date.ToString("yyyy-MM-dd"); pA.CAsistencia = 0; pA.Ultima_Asistencia = DateTime.Today.Date.ToString("yyyy-MM-dd"); AsistenciaDB.RegistrarAsistencia(pA); Limpiar(); int NTotalInscritos = GruposDB.ObtenerTotalInscritos(pID); int NuevaCant = NTotalInscritos + 1; GruposDB.ActualizarCantidadEstudiantes(pID, NuevaCant); } } else { MessageBox.Show("No se pudo registrar el estudiante", "Registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Registro Estudiantil", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("Esta seguro que desea Cancelar el Pago?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { try { if (dgvFactura.SelectedRows.Count == 1) { int ID; ID = Convert.ToInt32(dgvFactura.CurrentRow.Cells[0].Value); if (FacturacionDB.ObtenerCancelacionPago(ID) == "0") { int R = FacturacionDB.CancelarPago(ID, "Cancelado"); DateTime FechaFactura = Convert.ToDateTime(dgvFactura.CurrentRow.Cells[4].Value); int Matricula = Convert.ToInt32(dgvFactura.CurrentRow.Cells[1].Value); Decimal Ganancia = Convert.ToDecimal(GananciasDB.ObtenerCantidad(FechaFactura.Date.ToString("yyyy-MM-dd"))); Decimal Pago = Convert.ToDecimal(dgvFactura.CurrentRow.Cells[3].Value); decimal NuevaGanancia = Ganancia - Pago; int R0 = GananciasDB.ActualizarGananciasF(FechaFactura.Date.ToString("yyyy-MM-dd"), NuevaGanancia); DateTime FP = Convert.ToDateTime(EstudianteDB.ObtenerFechaProximoPago(Matricula)); string Modopago = EstudianteDB.ObtenerModoPago(Matricula); if (Modopago == "Mensual") { DateTime Time = FP; TimeSpan Tiempo = TimeSpan.FromDays(30); Time = Time.Subtract(Tiempo); int R2 = EstudianteDB.ActualizarProximoPago(Matricula, Time.ToString("yyyy-MM-dd")); Retorno = R2; } else if (Modopago == "Semanal") { DateTime Time = FP; TimeSpan Tiempo = TimeSpan.FromDays(7); Time = Time.Subtract(Tiempo); int R2 = EstudianteDB.ActualizarProximoPago(Matricula, Time.ToString("yyyy-MM-dd")); Retorno = R2; } if (R > 0 & R0 > 0 & Retorno > 0) { MessageBox.Show("Pago Cancelado!", "Cancelacion Pago", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ocurrio un Error", "Cancelacion Pago", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("El Pago ya fue Cancelado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Selecciona una factura de la lista", "Cancelacion Pago", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }