示例#1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            if (Validar.Validate(txtBuscar.Text, letras: true))
            {
                lblError.Visible = false;
            }
            else
            {
                lblError.Visible = true; lblError.Text = "¡Error! Solo letras en el campo de texto."; return;
            }
            ds = Conexion.MySQL("SELECT Matrícula, Alumno FROM (SELECT matricula as Matrícula, CONCAT(nombre, ' ', apellidop, ' ', apellidom) AS Alumno, status FROM alumnos) AS Tabla WHERE status = 1 AND Alumno LIKE '%" + txtBuscar.Text + "%';");
            dataGridView1.DataSource = ds.Tables["tabla"];

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                switch (dataGridView1.Columns[i].Name)
                {
                case "Matrícula": dataGridView1.Columns[i].Width = TextRenderer.MeasureText("000000000", dataGridView1.Columns[i].DefaultCellStyle.Font).Width; break;
                }
            }

            dataGridView1.ClearSelection();
        }
        public bool DatosCompletos()
        {
            //Matrícula
            if (!Validar.Validate(txtMatricula.Text, numeros: true))
            {
                return(false);
            }
            if (txtMatricula.Text.Length < 8 || txtMatricula.Text.Length > 8)
            {
                return(false);
            }
            ds = Conexion.MySQL("SELECT id FROM alumnos WHERE matricula = " + txtMatricula.Text + " AND id != " + id + ";");
            if (ds.Tables["tabla"].Rows.Count > 0)
            {
                return(false);
            }

            //Nombre
            if (!Validar.Validate(txtNombre.Text, letras: true, caracteres: " "))
            {
                return(false);
            }
            if (txtNombre.Text.Length == 0)
            {
                return(false);
            }
            if (txtNombre.Text.Length > 60)
            {
                return(false);
            }

            //Paterno
            if (!Validar.Validate(txtPaterno.Text, letras: true))
            {
                return(false);
            }
            if (txtPaterno.Text.Length == 0)
            {
                return(false);
            }
            if (txtPaterno.Text.Length > 60)
            {
                return(false);
            }

            //Materno
            if (!Validar.Validate(txtMaterno.Text, letras: true))
            {
                return(false);
            }
            if (txtMaterno.Text.Length == 0)
            {
                return(false);
            }
            if (txtMaterno.Text.Length > 60)
            {
                return(false);
            }

            //Correo
            //if (!Validar.Validate(txtCorreo.Text, letras: true, numeros: true, " _-@.!¡¿?/") && !Validar.CorreoValidate(txtCorreo.Text) && txtCorreo.Text != "") return false;
            //if (txtCorreo.Text.Length > 255) return false;

            //Telefono
            if (!Validar.Validate(txtTelefono.Text, numeros: true))
            {
                return(false);
            }
            if (txtTelefono.Text.Length < 10 || txtTelefono.Text.Length > 10)
            {
                return(false);
            }
            ds = Conexion.MySQL("SELECT id FROM alumnos WHERE telefono = " + txtTelefono.Text + " AND id != " + id + ";");
            if (ds.Tables["tabla"].Rows.Count > 0)
            {
                return(false);
            }

            return(true);
        }
 private void txtTelefono_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloNumeros(e);
 }
 private void txtMaterno_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloLetras(e);
 }
 //Validaciones
 private void txtMatricula_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloNumeros(e);
 }
示例#6
0
 private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloLetrasONumeros(e);
 }
示例#7
0
 private void txtContraseñan_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloLetrasONumeros(e);
 }
示例#8
0
 //Validaciones
 private void txtUsuario_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validar.SoloLetrasONumeros(e);
 }