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();
                    }
                }
            }
        }
Пример #2
0
        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();
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            conexion cn        = new conexion();
            bool     respuesta = true;
            bool     r         = true;

            if (validarEB())
            {
                r = validaciones.Correo(textBoxCorreoEmpleadoMod.Text);
                if (r != true)
                {
                    MessageBox.Show("Correo Electronico invalido, el correo debe tener el formato [email protected] ", "Mensaje", MessageBoxButtons.OK);
                    textBoxCorreoEmpleadoMod.SelectAll();
                    textBoxCorreoEmpleadoMod.Focus();
                }
                else
                {
                    if (comboBoxPuestoEmpleadoMod.Text == "Profesor")
                    {
                        textBoxPuestoEmpleadoMod.Clear();
                        textBoxPuestoEmpleadoMod.Text = "1";
                    }
                    if (comboBoxPuestoEmpleadoMod.Text == "Secretaria")
                    {
                        textBoxPuestoEmpleadoMod.Clear();
                        textBoxPuestoEmpleadoMod.Text = "2";
                    }
                    if (comboBoxPuestoEmpleadoMod.Text == "Administrador")
                    {
                        textBoxPuestoEmpleadoMod.Clear();
                        textBoxPuestoEmpleadoMod.Text = "3";
                    }
                    if (comboBoxPuestoEmpleadoMod.Text == "Chofer")
                    {
                        textBoxPuestoEmpleadoMod.Clear();
                        textBoxPuestoEmpleadoMod.Text = "4";
                    }
                    if (comboBoxPuestoEmpleadoMod.Text == "Personal Limpieza")
                    {
                        textBoxPuestoEmpleadoMod.Clear();
                        textBoxPuestoEmpleadoMod.Text = "5";
                    }

                    int puestoMod;
                    puestoMod = Int32.Parse(textBoxPuestoEmpleadoMod.Text);

                    respuesta = cn.NoExistencias(Convert.ToString(textBoxIdEmpleadoMod.Text));



                    if (respuesta != true)
                    {
                        string actualizar = "codigo_puestoEmpleado ='" + puestoMod + "',nombre_empleado ='" + textBoxNombreEmpleadoMod.Text + "', direccion_empleado ='" + textBoxDireccionEmpleadoMod.Text + "', telefono_empleado ='" + textBoxTelefonoEmpleadoMod.Text + "', telefono_emplaedoEmergencia ='" + textBoxTelefonoEmergenciaEmpleadoMod.Text + "', email_empleado ='" + textBoxCorreoEmpleadoMod.Text + "', usr_empleado ='" + textBoxUsuarioEmpleadoMod.Text + "'";
                        if (cn.actualizar("Empleado", actualizar, "id_empleado=" + Convert.ToString(textBoxIdEmpleadoMod.Text)))
                        {
                            MessageBox.Show("Datos Actualizados", "Mensaje", MessageBoxButtons.OK);
                            cn.consulta("select codigo_empleado, id_empleado,codigo_puestoEmpleado, nombre_empleado, direccion_empleado, telefono_empleado, telefono_emplaedoEmergencia, email_empleado, usr_empleado from Empleado", "Empleado");
                            dataGridViewEmpleado.DataSource = cn.ds.Tables["Empleado"];
                        }
                        else
                        {
                            MessageBox.Show("Error al actualizar el Registro", "Mensaje", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show("EL ID NO Existe", "Mensaje", MessageBoxButtons.OK);
                        textBoxIdEmpleadoMod.Clear();
                        textBoxIdEmpleadoMod.Focus();
                    }
                }
            }
        }
        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();
                    }
                }
            }
        }
        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);
                }
            }
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            conexion cn         = new conexion();
            bool     respuesta  = true;
            bool     respuesta2 = true;
            bool     respuesta3 = true;

            if (validarEB())
            {
                respuesta  = cn.ExistenciasB(int.Parse(textBox2.Text));
                respuesta2 = cn.ExistenciasNB(int.Parse(textBoxNumeroBusE.Text));
                respuesta3 = cn.ExistenciasPB(Convert.ToString(textBoxPlacaBusE.Text));


                if (respuesta3 != true)
                {
                    if (respuesta2 != true)
                    {
                        if (respuesta != true)
                        {
                            if (textBox2.Text == " ")
                            {
                                MessageBox.Show("Debe seleccionar un Chofer");
                            }
                            else
                            {
                                int num;
                                int num2;
                                num  = int.Parse(textBoxNumeroBusE.Text);
                                num2 = int.Parse(textBox2.Text);


                                db.insertarruta(textBoxDescripcioE.Text);
                                db.insertarbuses(1, null, num2, num, textBoxPlacaBusE.Text);

                                MessageBox.Show("la ruta se guardo");

                                cn.consulta("select * from Buses", "Buses");
                                dataGridAgrarR.DataSource = cn.ds.Tables["Buses"];
                            }
                        }
                        else
                        {
                            MessageBox.Show("Este Chofer ya tiene Ruta Asignada", "Mensaje", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Este Numero de Bus ya esta Asignado", "Mensaje", MessageBoxButtons.OK);
                        textBoxNumeroBusE.Clear();
                        textBoxNumeroBusE.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Esta placa ya Existe", "Mensaje", MessageBoxButtons.OK);
                    textBoxPlacaBusE.Clear();
                    textBoxPlacaBusE.Focus();
                }
            }
        }