public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }
            if (txtUser.Text == "")
            {
                ErrorEB.SetError(txtUser, "Ingrese su Usuario");


                noError = false;
            }


            if (txtPwd.Text == "")
            {
                ErrorEB.SetError(txtPwd, "Ingrese su Contraseña");


                noError = false;
            }



            return(noError);
        }
 private void radioButtonReingresoContinuo_CheckedChanged(object sender, EventArgs e)
 {
     ErrorEB.Clear();
     textBoxProcedenciaReingreso.Enabled = false;
     checkBoxConducta.Enabled            = false;
     checkBoxNotas.Enabled = false;
 }
        public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }

            if (textBoxIdClienteFact.Text == "")
            {
                ErrorEB.SetError(textBoxIdClienteFact, "Ingrese el ID");


                noError = false;
            }

            if (textBoxNombreClienteFact.Text == "")
            {
                ErrorEB.SetError(textBoxNombreClienteFact, "Ingrese el el nombre");


                noError = false;
            }

            return(noError);
        }
 private void buttonLimpiarPrimerIngreso_Click(object sender, EventArgs e)
 {
     ErrorEB.Clear();
     textBoxIdPrimer.Clear();
     textBoxNombrePrimer.Clear();
     textBoxLugarPrimer.Clear();
     textBoxDireccionPrimer.Clear();
     textBoxTelefonoAlumno.Clear();
     textBoxTPA.Clear();
     textBoxRetrasada.Clear();
     textBoxInstituto.Clear();
     textBoxIdEncargado.Clear();
     textBoxIdEncargado2.Clear();
     textBoxNombreEncargado.Clear();
     textBoxNombreEncargado2.Clear();
     textBoxDireccionEncargado.Clear();
     textBoxDireccionEncargado2.Clear();
     textBoxCelularEncargado.Clear();
     textBoxCelularEncargado2.Clear();
     textBoxTelefonoEncargado.Clear();
     textBoxTelefonoEncargado2.Clear();
     textBoxCorreoEncargado.Clear();
     textBoxCorreoEncargado2.Clear();
     textBoxTrabajoEncargado.Clear();
     textBoxTrabajoEncargado2.Clear();
     radioButton2.Checked = true;
     radioButton4.Checked = true;
     checkBox1.Checked    = false;
     checkBox2.Checked    = false;
     checkBox3.Checked    = false;
     checkBox4.Checked    = false;
 }
示例#5
0
        public bool validarEBc()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }

            if (textBoxCodigoRbuscar.Text == "")
            {
                ErrorEB.SetError(textBoxCodigoRbuscar, "Ingrese el codigo de Ruta");


                noError = false;
            }

            if (textBox1.Text == "")
            {
                ErrorEB.SetError(textBox1, "Ingrese el ID Alumno");


                noError = false;
            }


            if (textBox3.Text == "")
            {
                ErrorEB.SetError(textBox3, "Ingrese el Nombre del Alumno");


                noError = false;
            }



            return(noError);
        }
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            if (validarEB())
            {
                ErrorEB.Clear();
                DataClasses1DataContext db = new DataClasses1DataContext();
                string            caption  = "Error";
                MessageBoxButtons buttons  = MessageBoxButtons.OK;
                Class1            enc      = new Class1();
                conexion          cn       = new conexion();
                int estado   = 0;
                var Dencrypt = enc.Decrypt("AOyiDa6ltbbIAgLDzicDuQ==");
                var encrypt  = enc.Encrypt(txtPwd.Text);


                //MessageBox.Show("El usuario no tiene un puesto asignado", Dencrypt);


                conn.Open();
                string qryIntentos = string.Format("select intentos from Empleado where usr_empleado = '{0}'", txtUser.Text);

                SqlCommand    cmdint = new SqlCommand(qryIntentos, conexion.con());
                SqlDataReader drint  = cmdint.ExecuteReader();

                if (drint.Read())
                {
                    conteo = Convert.ToInt32(drint["intentos"]); //cuantos intentos tiene el usuario?
                }
                conn.Close();
                drint.Close();
                if (conteo >= 2 || estado == 2)
                {
                    string qryBloq = "update Empleado set codigo_estado = 2 where usr_empleado = '" + txtUser.Text + "'";
                    conn.Open();
                    SqlCommand cmdbloq = new SqlCommand(qryBloq, conn);

                    cmdbloq.ExecuteNonQuery();
                    conn.Close();
                    MessageBox.Show("Su cuenta ha sido bloqueada consulte mas informacion en administracion ", caption, buttons);
                }

                else
                {
                    conn.Open();
                    string        qryUsuario = string.Format("select usr_empleado from Empleado where usr_empleado == '{0}' and pwd_empleado = '{1}'", txtUser.Text, encrypt);
                    SqlCommand    cmdUsuario = new SqlCommand(qryIntentos, conn);
                    SqlDataReader drUsuario  = cmdUsuario.ExecuteReader();

                    while (drUsuario.Read())
                    {
                        var algo = drUsuario.GetString(0);

                        MessageBox.Show(algo.ToString());
                    }

                    var user = (from s in db.Empleado where s.usr_empleado == txtUser.Text && s.pwd_empleado == encrypt select s).FirstOrDefault();
                    if (user != null)
                    {
                        if (user.codigo_estado == 3)
                        {
                            cambioContraseña irnueva = new cambioContraseña();
                            irnueva.Show();
                            this.Hide();
                        }
                        else
                        {
                            switch (user.codigo_estado)
                            {
                            case 1:
                            {
                                if (user.codigo_estado == 3)
                                {
                                    //db.EX_estado(1, txtUser.Text);

                                    user.codigo_estado = 1;
                                    this.Hide();
                                    cambioContraseña m = new cambioContraseña();
                                    m.Show();
                                }
                                else
                                {
                                    this.Hide();
                                    maestro m = new maestro();
                                    m.Show();
                                }
                                break;
                            }

                            case 2:
                            {
                                if (user.codigo_estado == 3)
                                {
                                    user.codigo_estado = 1;
                                    this.Hide();
                                    cambioContraseña m = new cambioContraseña();
                                    m.Show();
                                }
                                else
                                {
                                    this.Hide();
                                    secretaria s = new secretaria();
                                    s.Show();
                                }
                                break;
                            }

                            case 3:
                            {
                                if (user.codigo_estado == 3)
                                {
                                    user.codigo_estado = 1;
                                    this.Hide();
                                    cambioContraseña m = new cambioContraseña();
                                    m.Show();
                                }
                                else
                                {
                                    this.Hide();
                                    admin a = new admin();
                                    a.Show();
                                    MessageBox.Show(cont.ToString());
                                }
                                break;
                            }

                            default:
                            {
                                MessageBox.Show("El usuario no tiene un puesto asignado", caption, buttons);
                                break;
                            }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuario o contraseña invalido", caption, buttons);
                        conn.Close();
                        conn.Open();
                        string        usuario  = txtUser.Text;
                        string        intentos = string.Format("select intentos from Empleado where usr_empleado = '{0}'", usuario);
                        SqlCommand    cmd2     = new SqlCommand(intentos, conn);
                        SqlDataReader dr       = cmd2.ExecuteReader();

                        if (dr.Read())
                        {
                            cont = Convert.ToInt32(dr["intentos"]) + 1;
                        }

                        conn.Close();
                        dr.Close();

                        conn.Open();
                        string     qry = string.Format("update Empleado set [intentos] = {0} where usr_empleado = '{1}'", cont, usuario);
                        SqlCommand cmd = new SqlCommand(qry, conn);

                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            }
        }
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            conexion cn                = new conexion();
            bool     respuesta         = true;
            DataClasses1DataContext db = new DataClasses1DataContext();
            Class1 enc = new Class1();

            Int32 puesto;
            //respuesta = cn.ExistenciasE(int.Parse(textBoxId.Text));



            bool r = true;

            if (validarEB())
            {
                bool respuestaU = true;

                respuestaU = cn.ExistenciasU(textBoxUsuario.Text);
                if (respuestaU != true)
                {
                    MessageBox.Show("Ese nommbre de Usuario ya existe. ", "Mensaje", MessageBoxButtons.OK);
                    textBoxUsuario.SelectAll();
                    textBoxUsuario.Focus();
                }
                else
                {
                    if (textBoxContrasena.TextLength < 8 || textBoxContrasena.TextLength < 8)
                    {
                        MessageBox.Show("La contraseña debe contener al menos 8 caracteres");
                    }
                    else
                    {
                        r = validaciones.Correo(textBoxCorreo.Text);
                        if (r != true)
                        {
                            MessageBox.Show("Correo Electronico invalido, el correo debe tener el formato [email protected] ", "Mensaje", MessageBoxButtons.OK);
                            textBoxCorreo.SelectAll();
                            textBoxCorreo.Focus();
                        }
                        else
                        {
                            ErrorEB.Clear();
                            respuesta = cn.ExistenciasE(textBoxId.Text);
                            if (respuesta != true)
                            {
                                puesto = Int32.Parse(textBoxPuesto.Text);

                                db.ingresarEmpleados(textBoxId.Text, textBoxNombre.Text, puesto, 3, textBoxCorreo.Text, textBoxtelefono.Text, textBoxEmergencia.Text, textBoxDireccion.Text, textBoxUsuario.Text, enc.Encrypt(textBoxContrasena.Text));
                                MessageBox.Show("Se ha guardado correctamente", "Mensaje", MessageBoxButtons.OK);
                            }
                            else
                            {
                                MessageBox.Show("El ID ya existe ", "Mensaje", MessageBoxButtons.OK);
                                textBoxId.Clear();
                                textBoxId.Focus();
                            }
                        }
                    }
                }
            }
        }
        public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }

            if (textBoxNombre.Text == "")
            {
                ErrorEB.SetError(textBoxNombre, "Ingrese  el Nombre");

                noError = false;
            }

            if (textBoxId.Text == "")
            {
                ErrorEB.SetError(textBoxId, "Ingrese  el ID");
                noError = false;
            }

            if (textBoxtelefono.Text == "")
            {
                ErrorEB.SetError(textBoxtelefono, "Ingrese  el telefono");
                noError = false;
            }
            if (textBoxEmergencia.Text == "")
            {
                ErrorEB.SetError(textBoxEmergencia, "Ingrese  el  Numero de Emergencia");
                noError = false;
            }
            if (textBoxCorreo.Text == "")
            {
                ErrorEB.SetError(textBoxCorreo, "Ingrese  el Correo");
                noError = false;
            }
            if (textBoxDireccion.Text == "")
            {
                ErrorEB.SetError(textBoxDireccion, "Ingrese   la direccion");
                noError = false;
            }



            if (comboBox1.Text == "")
            {
                ErrorEB.SetError(comboBox1, "Elija   el Puesto");
                noError = false;
            }

            if (textBoxPuesto.Text == "")
            {
                ErrorEB.SetError(textBoxPuesto, "Elija el puesto");
                noError = false;
            }

            if (radioButtonSi.Checked == true)
            {
                if (textBoxUsuario.Text == "")
                {
                    ErrorEB.SetError(textBoxUsuario, "Ingrese el Usuario");
                }

                if (textBoxContrasena.Text == "")
                {
                    ErrorEB.SetError(textBoxContrasena, "Ingrese la Contraseña");
                }
            }


            return(noError);
        }
        public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }

            if (textBoxIdEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxIdEmpleadoMod, "Ingrese el ID");


                noError = false;
            }

            if (textBoxNombreEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxNombreEmpleadoMod, "Ingrese el  Nombre ");


                noError = false;
            }

            if (textBoxDireccionEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxDireccionEmpleadoMod, "Ingrese la Direccion ");


                noError = false;
            }

            if (textBoxCorreoEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxCorreoEmpleadoMod, "Ingrese el Correo ");


                noError = false;
            }

            if (textBoxUsuarioEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxUsuarioEmpleadoMod, "Ingrese el Usuario ");


                noError = false;
            }

            if (textBoxTelefonoEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxTelefonoEmpleadoMod, "Ingrese el Telefono ");


                noError = false;
            }

            if (textBoxTelefonoEmergenciaEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(textBoxTelefonoEmergenciaEmpleadoMod, "Ingrese el Telefono de Emergencia ");


                noError = false;
            }

            if (comboBoxPuestoEmpleadoMod.Text == "")
            {
                ErrorEB.SetError(comboBoxPuestoEmpleadoMod, "Ingrese elija el Puesto ");


                noError = false;
            }



            return(noError);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool r  = true;
            bool r2 = true;



            if (validarEB())
            {
                ErrorEB.Clear();



                if (comboBoxGrado.Text == "1er grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "1";
                }
                if (comboBoxGrado.Text == "2do grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "2";
                }
                if (comboBoxGrado.Text == "3er grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "3";
                }
                if (comboBoxGrado.Text == "4to grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "4";
                }
                if (comboBoxGrado.Text == "5to grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "5";
                }
                if (comboBoxGrado.Text == "6to grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "6";
                }
                if (comboBoxGrado.Text == "7mo grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "7";
                }
                if (comboBoxGrado.Text == "8vo grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "8";
                }
                if (comboBoxGrado.Text == "9no grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "9";
                }
                if (comboBoxGrado.Text == "10mo grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "10";
                }
                if (comboBoxGrado.Text == "11vo grado")
                {
                    textBoxGrado.Clear();
                    textBoxGrado.Text = "11";
                }
                if (comboBoxSeccion.Text == "A")
                {
                    textBoxSeccion.Clear();
                    textBoxSeccion.Text = "1";
                }
                if (comboBoxSeccion.Text == "B")
                {
                    textBoxSeccion.Clear();
                    textBoxSeccion.Text = "2";
                }
                if (comboBoxSeccion.Text == "C")
                {
                    textBoxSeccion.Clear();
                    textBoxSeccion.Text = "3";
                }

                DataClasses1DataContext db = new DataClasses1DataContext();

                string fechaNac = dateTimePicker1.Text;

                bool respuesta = true;

                respuesta = con.Existencias(int.Parse(textBoxIdPrimer.Text));


                r = validaciones.Correo(textBoxCorreoEncargado.Text);


                if (r == false || r2 == false)
                {
                    if (r == false)
                    {
                        MessageBox.Show("Correo Electronico invalido, el correo debe tener el formato [email protected] ", "Mensaje", MessageBoxButtons.OK);
                        textBoxCorreoEncargado.SelectAll();
                        textBoxCorreoEncargado.Focus();
                    }


                    if (r2 == false)
                    {
                        MessageBox.Show("Correo Electronico invalido, el correo debe tener el formato [email protected] ", "Mensaje", MessageBoxButtons.OK);
                        textBoxCorreoEncargado2.SelectAll();
                        textBoxCorreoEncargado2.Focus();
                    }
                }
                else
                {
                    r2 = validaciones.Correo(textBoxCorreoEncargado.Text);



                    if (respuesta != true)
                    {
                        int grado;
                        grado = Int32.Parse(textBoxGrado.Text);
                        int seccion;
                        seccion = Int32.Parse(textBoxSeccion.Text);
                        string año = dateTimePicker2.Text;

                        conexion      xl   = new conexion();
                        SqlConnection conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=Inst_JoseCelilioValle;Integrated Security=True");

                        conn.Open();
                        string     comando = string.Format("select count(a.codigo_alumno) from  [dbo].[Alumno] a inner join [dbo].[grado_alumno] b on a.codigo_alumno = b.codigo_alumno inner join [dbo].[Periodos_Grado] c on b.codigo_periodoGrado = c.codigo_periodoGrado inner join [dbo].[Grado] d on c.codigo_grado= d.codigo_grado inner join [dbo].[Seccion] e on c.codigo_seccion = e.codigo_seccion where c.codigo_grado = {0} AND c.codigo_seccion = {1}", comboBoxGrado.SelectedIndex + 1, comboBoxSeccion.SelectedIndex + 1);
                        SqlCommand cmd     = new SqlCommand(comando, conn);

                        Int32 count = (Int32)cmd.ExecuteScalar();
                        conn.Close();

                        //Int32 count = (Int32) db.ExecuteCommand("select count(a.codigo_alumno) from  [dbo].[Alumno] a inner join [dbo].[grado_alumno] b on a.codigo_alumno = b.codigo_alumno inner join [dbo].[Periodos_Grado] c on b.codigo_periodoGrado = c.codigo_periodoGrado inner join [dbo].[Grado] d on c.codigo_grado= d.codigo_grado inner join [dbo].[Seccion] e on c.codigo_seccion = e.codigo_seccion where c.codigo_grado = {0} AND c.codigo_seccion = {1}",Convert.ToInt32(comboBoxGrado.SelectedIndex),Convert.ToInt32(comboBoxSeccion.SelectedIndex));
                        if (count <= 10)
                        {
                            string cursoInicial = comboBoxGrado.Text;

                            db.ingresarAlumnos(textBoxIdPrimer.Text, textBoxNombrePrimer.Text, 1, fechaNac, textBoxDireccionPrimer.Text, textBoxLugarPrimer.Text, comboBoxGenero.Text, textBoxTelefonoAlumno.Text, cursoInicial, textBoxInstituto.Text, textBoxRetrasada.Text, textBoxTPA.Text);
                            db.ingresarEncargado(textBoxIdEncargado.Text, textBoxNombreEncargado.Text, textBoxTrabajoEncargado.Text, textBoxTelefonoEncargado.Text, textBoxCelularEncargado.Text, textBoxCorreoEncargado.Text, textBoxDireccionEncargado.Text);
                            db.insertarAlumnoEncargado();
                            db.ingresarEncargado2(textBoxIdEncargado2.Text, textBoxNombreEncargado2.Text, textBoxTrabajoEncargado2.Text, textBoxTelefonoEncargado2.Text, textBoxCelularEncargado2.Text, textBoxCorreoEncargado2.Text, textBoxDireccionEncargado2.Text);

                            db.insertarAlumnoEncargado2();

                            if (comboBoxGrado.Text == "1er grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "1";
                            }
                            if (comboBoxGrado.Text == "1er grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "2";
                            }
                            if (comboBoxGrado.Text == "1er grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "3";
                            }
                            if (comboBoxGrado.Text == "2do grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "4";
                            }
                            if (comboBoxGrado.Text == "2do grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "5";
                            }
                            if (comboBoxGrado.Text == "2do grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "6";
                            }
                            if (comboBoxGrado.Text == "3er grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "7";
                            }
                            if (comboBoxGrado.Text == "3er grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "8";
                            }
                            if (comboBoxGrado.Text == "3er grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "9";
                            }
                            if (comboBoxGrado.Text == "4to grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "10";
                            }
                            if (comboBoxGrado.Text == "4to grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "11";
                            }
                            if (comboBoxGrado.Text == "4to grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "12";
                            }
                            if (comboBoxGrado.Text == "5to grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "13";
                            }
                            if (comboBoxGrado.Text == "5to grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "14";
                            }
                            if (comboBoxGrado.Text == "5to grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "15";
                            }
                            if (comboBoxGrado.Text == "6to grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "16";
                            }
                            if (comboBoxGrado.Text == "6to grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "17";
                            }
                            if (comboBoxGrado.Text == "6to grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "18";
                            }
                            if (comboBoxGrado.Text == "7mo grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "19";
                            }
                            if (comboBoxGrado.Text == "7mo grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "20";
                            }
                            if (comboBoxGrado.Text == "7mo grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "21";
                            }
                            if (comboBoxGrado.Text == "8vo grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "22";
                            }
                            if (comboBoxGrado.Text == "8vo grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "23";
                            }
                            if (comboBoxGrado.Text == "8vo grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "24";
                            }
                            if (comboBoxGrado.Text == "9no grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "25";
                            }
                            if (comboBoxGrado.Text == "9no grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "26";
                            }
                            if (comboBoxGrado.Text == "9no grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "27";
                            }
                            if (comboBoxGrado.Text == "10mo grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "28";
                            }
                            if (comboBoxGrado.Text == "10mo grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "29";
                            }
                            if (comboBoxGrado.Text == "10mo grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "30";
                            }
                            if (comboBoxGrado.Text == "11vo grado" && comboBoxSeccion.Text == "A")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "31";
                            }
                            if (comboBoxGrado.Text == "11vo grado" && comboBoxSeccion.Text == "B")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "32";
                            }
                            if (comboBoxGrado.Text == "11vo grado" && comboBoxSeccion.Text == "C")
                            {
                                textBoxGrado.Clear(); textBoxAula.Text = "33";
                            }

                            int aula;
                            aula = Int32.Parse(textBoxAula.Text);

                            db.ingresarPeriodosGrados(dateTimePicker2.Text, grado, seccion, aula);
                            db.insertarGradoAlumno();
                            MessageBox.Show("Se ha guardado correctamente", "Mensaje", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Seccion ya contiene mas de 30 alumnos");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El ID del Alumno ya Existe", "Mensaje", MessageBoxButtons.OK);
                        textBoxIdPrimer.Clear();
                        textBoxIdPrimer.Focus();
                    }
                }
            }
        }
        public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }

            if (checkBox1.Checked == false)
            {
                ErrorEB.SetError(checkBox1, "Debe entregar sertificado de notas");


                noError = false;
            }

            if (checkBox2.Checked == false)
            {
                ErrorEB.SetError(checkBox2, "Debe entregar sertificado de notas");


                noError = false;
            }

            if (checkBox3.Checked == false)
            {
                ErrorEB.SetError(checkBox3, "Debe entregar constancia de conducta");


                noError = false;
            }

            if (checkBox4.Checked == false)
            {
                ErrorEB.SetError(checkBox4, "Debe entregar Fotografia");


                noError = false;
            }



            if (textBoxIdPrimer.Text == "")
            {
                ErrorEB.SetError(textBoxIdPrimer, "Ingrese  el ID");


                noError = false;
            }

            if (textBoxNombrePrimer.Text == "")
            {
                ErrorEB.SetError(textBoxNombrePrimer, "Ingrese  el Nombre");

                noError = false;
            }

            if (textBoxLugarPrimer.Text == "")
            {
                ErrorEB.SetError(textBoxLugarPrimer, "Ingrese  lugar de Nacimiento");

                noError = false;
            }

            if (textBoxTelefonoAlumno.Text == "")
            {
            }

            if (textBoxDireccionPrimer.Text == "")
            {
                ErrorEB.SetError(textBoxDireccionPrimer, "Ingrese  la Direccion");

                noError = false;
            }

            if (comboBoxGenero.Text == "")
            {
                ErrorEB.SetError(comboBoxGenero, "Elija Genero");

                noError = false;
            }

            if (textBoxRetrasada.Text == "" && radioButton1.Checked == true)
            {
                ErrorEB.SetError(textBoxRetrasada, "Ingrese Materia Retrasada");

                noError = false;
            }

            if (textBoxTPA.Text == "" && radioButton3.Checked == true)
            {
                ErrorEB.SetError(textBoxTPA, "Ingrese Materia de TPA");

                noError = false;
            }

            if (textBoxIdEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxIdEncargado, "Ingrese ID del Primer Encargado");

                noError = false;
            }

            if (textBoxNombreEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxNombreEncargado, "Ingrese Nombre del Primer encargado");

                noError = false;
            }

            if (textBoxDireccionEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxDireccionEncargado, "Ingrese la Direccion del Encargado ");

                noError = false;
            }

            if (textBoxCelularEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxCelularEncargado, "Ingrese el Celular de Encargado ");

                noError = false;
            }

            if (textBoxTelefonoEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxTelefonoEncargado, "Ingrese el Telefono de Encargado ");

                noError = false;
            }

            if (textBoxCorreoEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxCorreoEncargado, "Ingrese el Correo de Encargado ");



                noError = false;
            }

            if (textBoxTelefonoAlumno.Text == "")
            {
                ErrorEB.SetError(textBoxTelefonoAlumno, "Ingrese telefono del Alumno ");



                noError = false;
            }



            if (textBoxTrabajoEncargado.Text == "")
            {
                ErrorEB.SetError(textBoxTrabajoEncargado, "Ingrese el el lugar de trabajo Encargado ");

                noError = false;
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (textBoxIdEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxIdEncargado2, "Ingrese ID del Primer Encargado");

                noError = false;
            }

            if (textBoxNombreEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxNombreEncargado2, "Ingrese Nombre del segundo encargado");

                noError = false;
            }

            if (textBoxDireccionEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxDireccionEncargado2, "Ingrese la Direccion del Encargado ");

                noError = false;
            }

            if (textBoxCelularEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxCelularEncargado2, "Ingrese el Celular de Encargado ");

                noError = false;
            }

            if (textBoxTelefonoEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxTelefonoEncargado2, "Ingrese el Telefono de Encargado ");

                noError = false;
            }

            if (textBoxCorreoEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxCorreoEncargado2, "Ingrese el Correo de Encargado ");

                noError = false;
            }

            if (textBoxTrabajoEncargado2.Text == "")
            {
                ErrorEB.SetError(textBoxTrabajoEncargado2, "Ingrese el el lugar de trabajo Encargado ");

                noError = false;
            }

            if (comboBoxGrado.Text == "")
            {
                ErrorEB.SetError(comboBoxGrado, "Ingrese el Grado ");

                noError = false;
            }

            if (comboBoxSeccion.Text == "")
            {
                ErrorEB.SetError(comboBoxSeccion, "Ingrese la Seccion ");

                noError = false;
            }

            if (textBoxInstituto.Text == "")
            {
                ErrorEB.SetError(textBoxInstituto, "Ingrese la Seccion ");

                noError = false;
            }



            return(noError);
        }
        public bool validarEB()
        {
            bool noError = true;
            int  count   = 0;


            count = count + 1;

            if (count != 0)
            {
                ErrorEB.Clear();
            }
            if (checkBoxNotas.Checked == false && radioButtonTraslado.Checked == true)
            {
                ErrorEB.SetError(checkBoxNotas, "Verifique que entrego Notas");


                noError = false;
            }

            if (checkBoxConducta.Checked == false && radioButtonTraslado.Checked == true)
            {
                ErrorEB.SetError(checkBoxConducta, "Verifique que  entrego Constancia de Conducta");


                noError = false;
            }

            if (checkBoxFoto.Checked == false)
            {
                ErrorEB.SetError(checkBoxFoto, "Verifique que  entrego  Foto");


                noError = false;
            }

            if (checkBoxFoto.Checked == false)
            {
                ErrorEB.SetError(textBoxProcedenciaReingreso, "");


                noError = false;
            }


            if (textBoxIdAlumnoReingreso.Text == "")
            {
                ErrorEB.SetError(textBoxIdAlumnoReingreso, "Ingrese  el ID del Alumno");


                noError = false;
            }

            if (comboBoxGrado2.Text == "")
            {
                ErrorEB.SetError(comboBoxGrado2, "Ingrese el Grado a Matricular");


                noError = false;
            }

            if (comboBoxSeccion2.Text == "")
            {
                ErrorEB.SetError(comboBoxSeccion2, "Ingrese la Seccion");


                noError = false;
            }

            if (textBoxRetrasadaReingreso.Text == "" && radioButtonMateriaSi.Checked == true)
            {
                ErrorEB.SetError(textBoxRetrasadaReingreso, "Ingrese la Materia Retrasada");


                noError = false;
            }

            if (textBoxTPAreingreso.Text == "" && radioButtonTPAsi.Checked == true)
            {
                ErrorEB.SetError(textBoxTPAreingreso, "Ingrese TPA");


                noError = false;
            }

            if (textBoxProcedenciaReingreso.Text == "" && radioButtonTraslado.Checked == true)
            {
                ErrorEB.SetError(textBoxProcedenciaReingreso, "Ingrese Instituto de Precedencia");


                noError = false;
            }



            return(noError);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            conexion cn        = new conexion();
            bool     respuesta = true;



            if (validarEB())
            {
                respuesta = cn.NoExistenciasA(Convert.ToString(textBoxIdAlumnoReingreso.Text));
                ErrorEB.Clear();

                if (respuesta != true)
                {
                    string año2 = dateTimePickerReingreso.Text;

                    DataClasses1DataContext db = new DataClasses1DataContext();

                    int           codigo = Convert.ToInt32(textBoxIdAlumnoReingreso.Text);
                    conexion      xl     = new conexion();
                    SqlConnection conn   = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=Inst_JoseCelilioValle;Integrated Security=True");

                    conn.Open();
                    string     comando = string.Format("select count(a.codigo_alumno) from  [dbo].[Alumno] a inner join [dbo].[grado_alumno] b on a.codigo_alumno = b.codigo_alumno inner join [dbo].[Periodos_Grado] c on b.codigo_periodoGrado = c.codigo_periodoGrado inner join [dbo].[Grado] d on c.codigo_grado= d.codigo_grado inner join [dbo].[Seccion] e on c.codigo_seccion = e.codigo_seccion where c.codigo_grado = {0} AND c.codigo_seccion = {1}", comboBoxGrado2.SelectedIndex + 1, comboBoxSeccion2.SelectedIndex + 1);
                    SqlCommand cmd     = new SqlCommand(comando, conn);

                    Int32 count = (Int32)cmd.ExecuteScalar();
                    conn.Close();

                    if (count <= 30)
                    {
                        string actualizar = "materiaRetrasada ='" + textBoxRetrasadaReingreso.Text + "',materiaTPA ='" + textBoxTPAreingreso + "', instituto_procedencia ='" + textBoxProcedenciaReingreso.Text + "'";
                        if (cn.actualizar("Alumno", actualizar, "id_alumno=" + textBoxIdAlumnoReingreso.Text))
                        {
                            MessageBox.Show("Datos Actualizados", "Mensaje", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Error al actualizar el Registro", "Mensaje", MessageBoxButtons.OK);
                        }
                        if (comboBoxGrado2.Text == "1er grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "1";
                        }
                        if (comboBoxGrado2.Text == "2do grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "2";
                        }
                        if (comboBoxGrado2.Text == "3er grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "3";
                        }
                        if (comboBoxGrado2.Text == "4to grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "4";
                        }
                        if (comboBoxGrado2.Text == "5to grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "5";
                        }
                        if (comboBoxGrado2.Text == "6to grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "6";
                        }
                        if (comboBoxGrado2.Text == "7mo grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "7";
                        }
                        if (comboBoxGrado2.Text == "8vo grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "8";
                        }
                        if (comboBoxGrado2.Text == "9no grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "9";
                        }
                        if (comboBoxGrado2.Text == "10mo grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "10";
                        }
                        if (comboBoxGrado2.Text == "11vo grado")
                        {
                            textBoxGrado2.Clear();
                            textBoxGrado2.Text = "11";
                        }
                        int grado2;
                        grado2 = Int32.Parse(textBoxGrado2.Text);

                        if (comboBoxSeccion2.Text == "A")
                        {
                            textBoxSeccion2.Clear();
                            textBoxSeccion2.Text = "1";
                        }
                        if (comboBoxSeccion2.Text == "B")
                        {
                            textBoxSeccion2.Clear();
                            textBoxSeccion2.Text = "2";
                        }
                        if (comboBoxSeccion2.Text == "C")
                        {
                            textBoxSeccion2.Clear();
                            textBoxSeccion2.Text = "3";
                        }

                        int seccion2;
                        seccion2 = Int32.Parse(textBoxSeccion2.Text);

                        if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "1";
                        }
                        if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "2";
                        }
                        if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "3";
                        }
                        if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "4";
                        }
                        if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "5";
                        }
                        if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "6";
                        }
                        if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "7";
                        }
                        if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "8";
                        }
                        if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "9";
                        }
                        if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "10";
                        }
                        if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "11";
                        }
                        if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "12";
                        }
                        if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "13";
                        }
                        if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "14";
                        }
                        if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "15";
                        }
                        if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "16";
                        }
                        if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "17";
                        }
                        if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "18";
                        }
                        if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "19";
                        }
                        if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "20";
                        }
                        if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "21";
                        }
                        if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "22";
                        }
                        if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "23";
                        }
                        if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "24";
                        }
                        if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "25";
                        }
                        if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "26";
                        }
                        if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "27";
                        }
                        if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "28";
                        }
                        if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "29";
                        }
                        if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "30";
                        }
                        if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "A")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "31";
                        }
                        if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "B")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "32";
                        }
                        if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "C")
                        {
                            textBoxGrado2.Clear(); textBoxAula2.Text = "33";
                        }

                        int aula2;
                        aula2 = Int32.Parse(textBoxAula2.Text);


                        db.ingresarPeriodosGrados(dateTimePickerReingreso.Text, grado2, seccion2, aula2);
                        db.insertarGradoAlumno();
                        MessageBox.Show("Datos Guardados correctamente", "Mensaje", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Seccion ya tiene 30 alumnos");
                    }
                }
                else
                {
                    MessageBox.Show("El id NO Existe", "Mensaje", MessageBoxButtons.OK);
                }
            }
        }