Example #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                lblError.Text = "";
                clsEstudiante objEstudiante = new clsEstudiante();
                objEstudiante.DocumentoEstudiante = txtDocumentoEstudiante.Text;
                objEstudiante.NombreEstudiante    = txtNombreEstudiante.Text;

                if (objEstudiante.GestionarEstudiante())
                {
                    if (objEstudiante.Error.Equals("0"))
                    {
                        lblError.Text = "Ya existe un registro con el documento ingresado.";
                    }
                    else if (objEstudiante.Error.Equals("1"))
                    {
                        lblError.Text = "Registro guardado correctamente.";
                        objEstudiante.cargarEstudiantes(GridViewEstudiantes);
                    }
                }
                else
                {
                    lblError.Text = "Error! no se pudo agregar el registro " + objEstudiante.Error;
                }
                txtDocumentoEstudiante.Text = "";
                txtNombreEstudiante.Text    = "";
                objEstudiante = null;
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void restart()
        {
            //limpiar los datos Almacenados
            Padre      = null;
            PadreSec   = null;
            Estudiante = null;
            // limpiar controles de Padre o Apoderado
            txtApellidosNombresPadre.Text = "";
            txtCelular.Text         = "";
            txtCorreo.Text          = "";
            txtDirecion.Text        = "";
            txtTrabajo.Text         = "";
            txtNumeroDocumento.Text = "";
            //limpiar controles de Segundo Padre o Apoderado
            txtPadreSecApellidosNombres.Text = "";
            txtPadreSecCelular.Text          = "";
            txtPadreSecCorreo.Text           = "";
            txtPadreSecDireccion.Text        = "";
            txtPadreSecNumeroDocumento.Text  = "";
            txtPadreSecTrabajo.Text          = "";

            //limpiar controles de Estudiante
            txtEstudianteApellidosNombres.Text   = "";
            txtEstudianteCelular.Text            = "";
            txtEstudianteColegioProcedencia.Text = "";
            txtEstudianteCondicionSalud.Text     = "";
            txtEstudianteNumDoc.Text             = "";

            Valores_porDefecto();
        }
        /// <summary>
        /// Este metodo se usa para habilitar o desabilitar los controles del Estudiante
        /// </summary>
        ///
        /// <param name="valor"> true para desactivar controles </param>
        private void controlesEstudiante_desactivar(bool valor)
        {
            dtpEstudianteFechaNac.Enabled = !valor;
            cmbGrado.Enabled   = !valor;
            cmbSeccion.Enabled = !valor;
            txtEstudianteApellidosNombres.Enabled   = !valor;
            txtEstudianteCelular.Enabled            = !valor;
            txtEstudianteColegioProcedencia.Enabled = !valor;
            txtEstudianteCondicionSalud.Enabled     = !valor;
            nudEstudiantePeso.Enabled  = !valor;
            nudEstudianteTalla.Enabled = !valor;

            if (valor && Estudiante != null)
            {
                MessageBox.Show("El estudinte ya existe,\n con el nombre de : "
                                + Estudiante.ApellidosNombres +
                                "\n No Puede Volver a Registrarlo");
                Estudiante = null;
                txtEstudianteNumDoc.Text = "";
                txtEstudianteNumDoc.Focus();
            }
            else
            {
                txtEstudianteApellidosNombres.Text   = "";
                txtEstudianteCelular.Text            = "";
                txtEstudianteColegioProcedencia.Text = "";
                txtEstudianteCondicionSalud.Text     = "";
                dtpEstudianteFechaNac.Value          = dtpEstudianteFechaNac.MaxDate;
                nudEstudiantePeso.Value  = 0;
                nudEstudianteTalla.Value = 0;
            }
        }
Example #4
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            clsEstudiante objConsultaEstudiante = new clsEstudiante();

            objConsultaEstudiante.DocumentoEstudiante = txtDocumentoEstudiante.Text;
            objConsultaEstudiante.consultarEstudiantes(GridViewEstudiantes);

            if (txtDocumentoEstudiante.Text == "")
            {
                objConsultaEstudiante.cargarEstudiantes(GridViewEstudiantes);
            }
            txtDocumentoEstudiante.Clear();
            txtNombreEstudiante.Clear();
        }
Example #5
0
        private void frmEstudiante_Load(object sender, EventArgs e)
        {
            clsEstudiante objEstudiante = new clsEstudiante();

            objEstudiante.cargarEstudiantes(GridViewEstudiantes);
        }
        private void Datos_Si_Existen(ComboBox cmbDatos, TextBox txtNDocumento)
        {
            if (cmbDatos.SelectedIndex == 0 && txtNDocumento.Text.Length != 8 && txtNDocumento.Text != "")
            {
                switch (txtNDocumento.Tag.ToString())
                {
                case "primero":
                    controlespadre1_desactivar(true);
                    break;

                case "estudiante":
                    controlesEstudiante_desactivar(true);
                    break;

                case "secundario":
                    controlespadre2_desactivar(true);
                    break;

                default:
                    break;
                }
            }
            else if (txtNDocumento.Text.Length != 12)
            {
                switch (txtNDocumento.Tag.ToString())
                {
                case "primero":
                    controlespadre1_desactivar(true);
                    break;

                case "estudiante":
                    controlesEstudiante_desactivar(true);
                    break;

                case "secundario":
                    controlespadre2_desactivar(true);
                    break;

                default:
                    break;
                }
            }

            if (cmbDatos.SelectedIndex == 0 && txtNDocumento.Text.Length == 8)
            {
                switch (txtNDocumento.Tag.ToString())
                {
                case "primero":
                    Padre = clsPadre.Padre_Comprobar_siExiste(txtNDocumento.Text);
                    if (Padre != null)
                    {
                        controlespadre1_desactivar(true);
                        txtNumeroDocumento.ReadOnly = true;
                    }
                    else
                    {
                        controlespadre1_desactivar(false);
                    }
                    break;

                case "estudiante":
                    Estudiante = clsEstudiante.Comprobar_siExiste(txtNDocumento.Text);
                    if (Estudiante != null)
                    {
                        controlesEstudiante_desactivar(true);
                    }
                    else
                    {
                        controlesEstudiante_desactivar(false);
                    }
                    break;

                case "secundario":
                    PadreSec = clsPadre.Padre_Comprobar_siExiste(txtNDocumento.Text);
                    if (PadreSec != null)
                    {
                        controlespadre2_desactivar(true);
                        txtPadreSecNumeroDocumento.ReadOnly = true;
                    }
                    else
                    {
                        controlespadre2_desactivar(false);
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (txtNDocumento.Text.Length == 12)
                {
                    switch (txtNDocumento.Tag.ToString())
                    {
                    case "primero":
                        Padre = clsPadre.Padre_Comprobar_siExiste(txtNDocumento.Text);
                        if (Padre != null)
                        {
                            controlespadre1_desactivar(true);
                            txtNumeroDocumento.ReadOnly = true;
                        }
                        else
                        {
                            controlespadre1_desactivar(false);
                        }
                        break;

                    case "estudiante":
                        Estudiante = clsEstudiante.Comprobar_siExiste(txtNDocumento.Text);
                        if (Estudiante != null)
                        {
                            controlesEstudiante_desactivar(true);
                        }
                        else
                        {
                            controlesEstudiante_desactivar(false);
                        }
                        break;

                    case "secundario":
                        PadreSec = clsPadre.Padre_Comprobar_siExiste(txtNDocumento.Text);
                        if (PadreSec != null)
                        {
                            controlespadre2_desactivar(true);
                            txtPadreSecNumeroDocumento.ReadOnly = true;
                        }
                        else
                        {
                            controlespadre2_desactivar(false);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
        private void RegistrarDatos()
        {
            if (txtApellidosNombresPadre.Enabled == false && txtNumeroDocumento.Text.Length == txtNumeroDocumento.MaxLength)
            {
            }
            else if (comprobar_datos_Padre())
            {
                Padre = new clsPadre(
                    tiposidentificaciones[cmbTipoDoc.SelectedIndex],
                    txtNumeroDocumento.Text,
                    txtApellidosNombresPadre.Text,
                    txtDirecion.Text,
                    DistritosPadre[cmbDistrito.SelectedIndex],
                    txtCelular.Text,
                    txtTrabajo.Text,
                    txtCorreo.Text);
                controlespadre1_desactivar(true);
            }
            else
            {
                MessageBox.Show("Compueve los Campos de Padre o Apoderado ...");
            }

            if (chkPadreSecundario.Checked == true)
            {
                if (txtPadreSecApellidosNombres.Enabled == false && txtPadreSecNumeroDocumento.Text.Length == txtPadreSecNumeroDocumento.MaxLength)
                {
                }
                else if (comprobar_datos_Padre2())
                {
                    PadreSec = new clsPadre(
                        tiposidentificaciones[cmbPadreSecTipoDoc.SelectedIndex],
                        txtPadreSecNumeroDocumento.Text,
                        txtPadreSecApellidosNombres.Text,
                        txtPadreSecDireccion.Text,
                        DistritosPadreSec[cmbPadreSecDistrito.SelectedIndex],
                        txtPadreSecCelular.Text,
                        txtPadreSecTrabajo.Text,
                        txtPadreSecCorreo.Text);
                    controlespadre2_desactivar(true);
                }
                else
                {
                    MessageBox.Show("Compueve los Campos de Segundo Padre o Apoderado ...");
                }
            }


            if (txtEstudianteApellidosNombres.Enabled == false && txtEstudianteNumDoc.Text.Length == txtEstudianteNumDoc.MaxLength)
            {
                MessageBox.Show("El estudiante ya existe ...");
                txtEstudianteNumDoc.Text     = "";
                txtEstudianteNumDoc.ReadOnly = false;
                txtEstudianteNumDoc.Focus();
            }
            else if (comprobar_datos_Estudiante())
            {
                Estudiante = new clsEstudiante(
                    tiposidentificaciones[cmbEstudianteTipoDoc.SelectedIndex],
                    txtEstudianteNumDoc.Text,
                    txtEstudianteApellidosNombres.Text,
                    Padre, null,
                    txtEstudianteColegioProcedencia.Text,
                    Convert.ToSingle(nudEstudiantePeso.Value),
                    Convert.ToInt16(nudEstudianteTalla.Value),
                    txtEstudianteCondicionSalud.Text,
                    dtpEstudianteFechaNac.Value, "");
                if (chkPadreSecundario.Checked && txtPadreSecApellidosNombres.Enabled)
                {
                    PadreSec.Insertar();
                }
                if (txtApellidosNombresPadre.Enabled)
                {
                    Padre.Insertar();
                }
                Estudiante.Insertar();

                clsMatricula nueva = new clsMatricula(mdlVariablesAplicacion.PeriodoActual, Estudiante, mdlVariablesAplicacion.UsuarioConectado,
                                                      false, Secciones[cmbSeccion.SelectedIndex], DateTime.Now);

                nueva.RegistrarMatricula();
                this.restart();
                MessageBox.Show("Registro de Datos Satisfactorio");
            }
            else
            {
                MessageBox.Show("Compueve los Campos del Estudiante ...");
            }
        }
        private void MostrarDatos()
        {
            Estudiante = clsEstudiante.MostrarDatos(estudianteseleccionado);
            if (Estudiante != null)
            {
                int cont = 0;
                txtEstudianteNombre.Text             = Estudiante.ApellidosNombres;
                dtpEstudianteFechaNac.Value          = Estudiante.FechaNacimiento;
                txtEstudianteColegioProcedencia.Text = Estudiante.ColegioProcedencia;
                nudEstudiantePeso.Value          = Convert.ToDecimal(Estudiante.Peso);
                nudEstudianteTalla.Value         = Estudiante.Talla;
                txtEstudianteCondicionSalud.Text = Estudiante.CondicionSalud;
                txtEstudianteCelular.Text        = Estudiante.Celular;

                PrimerPadre   = clsPadre.MostrarDatos(Estudiante.PadreApoderado_NumDoc.NumeroDocumento);
                lblpadre.Text = PrimerPadre.NombreCompleto + " - " + PrimerPadre.NumeroDocumento;
                txtApellidosNombresPadre.Text = PrimerPadre.NombreCompleto;
                txtDirecion.Text = PrimerPadre.Direccion;
                txtCelular.Text  = PrimerPadre.NumeroCelular;
                txtTrabajo.Text  = PrimerPadre.Trabajo;
                txtCorreo.Text   = PrimerPadre.Correo;
                #region mostrar departamento del Primer Padre
                Departamentos.Clear();
                cmbDepartamento.Items.Clear();

                cont = 0;
                foreach (clsDepartemento departemento in clsDepartemento.listar())
                {
                    cmbDepartamento.Items.Add(departemento.Nombre);
                    Departamentos.Add(departemento);
                    if (departemento.IdDepartemento == PrimerPadre.Distrito.Provincia.Departamento.IdDepartemento)
                    {
                        cmbDepartamento.SelectedIndex = cont;
                    }
                    cont += 1;
                }
                cont = 0;
                cmbProvincia.Items.Clear();
                ProvinciasPadre.Clear();
                foreach (clsProvincia provincia in clsProvincia.ListarProvincias(PrimerPadre.Distrito.Provincia.Departamento.IdDepartemento))
                {
                    cmbProvincia.Items.Add(provincia.Nombre);
                    ProvinciasPadre.Add(provincia);
                    if (provincia.IdProvincia == PrimerPadre.Distrito.Provincia.IdProvincia)
                    {
                        cmbProvincia.SelectedIndex = cont;
                    }
                    cont += 1;
                }
                cont = 0;
                DistritosPadre.Clear();
                cmbDistrito.Items.Clear();
                foreach (clsDistrito distrito in clsDistrito.listarDistritos(PrimerPadre.Distrito.Provincia.IdProvincia))
                {
                    cmbDistrito.Items.Add(distrito.Nombre);
                    DistritosPadre.Add(distrito);
                    if (distrito.IdDistrito == PrimerPadre.Distrito.IdDistrito)
                    {
                        cmbDistrito.SelectedIndex = cont;
                    }
                    cont += 1;
                }
                #endregion

                if (Estudiante.Padre_NumDoc != null)
                {
                    panelModificarDatos.Height = 1080;
                    Controles_padreSec(true);

                    SegundoPadre = clsPadre.MostrarDatos(Estudiante.Padre_NumDoc.NumeroDocumento);
                    #region mostar combos del Segundo Padre
                    cont = 0;
                    foreach (clsDepartemento item in Departamentos)
                    {
                        cmbPadreSecDepartamento.Items.Add(item.Nombre);
                        if (item.IdDepartemento == SegundoPadre.Distrito.Provincia.Departamento.IdDepartemento)
                        {
                            cmbPadreSecDepartamento.SelectedIndex = cont;
                        }
                        cont += 1;
                    }
                    cont = 0;
                    ProvinciasPadreSec.Clear();
                    cmbPadreSecProvincia.Items.Clear();
                    foreach (clsProvincia item in clsProvincia.ListarProvincias(SegundoPadre.Distrito.Provincia.Departamento.IdDepartemento))
                    {
                        cmbPadreSecProvincia.Items.Add(item.Nombre);
                        ProvinciasPadreSec.Add(item);
                        if (item.IdProvincia == SegundoPadre.Distrito.Provincia.IdProvincia)
                        {
                            cmbPadreSecProvincia.SelectedIndex = cont;
                        }
                        cont += 1;
                    }
                    cont = 0;
                    DistritosPadreSec.Clear();
                    cmbPadreSecDistrito.Items.Clear();
                    foreach (clsDistrito item in clsDistrito.listarDistritos(SegundoPadre.Distrito.Provincia.IdProvincia))
                    {
                        cmbPadreSecDistrito.Items.Add(item.Nombre);
                        DistritosPadreSec.Add(item);
                        if (item.IdDistrito == SegundoPadre.Distrito.IdDistrito)
                        {
                            cmbPadreSecDistrito.SelectedIndex = cont;
                        }
                        cont += 1;
                    }
                    #endregion
                    lblpadresecundario.Text          = SegundoPadre.NombreCompleto + " - " + SegundoPadre.NumeroDocumento;
                    txtPadreSecApellidosNombres.Text = SegundoPadre.NombreCompleto;
                    txtPadreSecCelular.Text          = SegundoPadre.NumeroCelular;
                    txtPadreSecCorreo.Text           = SegundoPadre.Correo;
                    txtPadreSecDireccion.Text        = SegundoPadre.Direccion;
                    txtPadreSecTrabajo.Text          = SegundoPadre.Trabajo;
                }
                else
                {
                    panelModificarDatos.Height = 700;
                    Controles_padreSec(false);
                }
            }
        }