private void txtTelefono_TextChanged(object sender, EventArgs e) { if (!Validar.Validate(txtTelefono.Text, numeros: true)) { lblErrorTelefono.Text = "Solo números"; lblErrorTelefono.Visible = true; } else { lblErrorTelefono.Visible = false; } if (Validar.Validate(txtTelefono.Text, numeros: true) && txtTelefono.Text.Length == 10) { ds = Conexion.MySQL("SELECT id FROM alumnos WHERE telefono = " + txtTelefono.Text + " AND id != " + id + ";"); if (ds.Tables["tabla"].Rows.Count > 0) { lblErrorTelefono.Text = "Teléfono en uso"; lblErrorTelefono.Visible = true; } else { lblErrorTelefono.Visible = false; } } }
private void txtBuscar_TextChanged(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."; } }
private void txtMaterno_TextChanged(object sender, EventArgs e) { if (!Validar.Validate(txtMaterno.Text, letras: true)) { lblErrorMaterno.Text = "Solo letras"; lblErrorMaterno.Visible = true; } else { lblErrorMaterno.Visible = false; } }
private void txtNombre_TextChanged(object sender, EventArgs e) { if (Validar.Validate(txtNombre.Text, letras: true, caracteres: " ")) { lblErrorNombre.Visible = false; } else { lblErrorNombre.Text = "Solo letras"; lblErrorNombre.Visible = true; } }
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); }