Subo Cambio 555

This commit is contained in:
Michael Robles
2024-02-03 05:55:59 -07:00
parent e71b7042aa
commit 080e4640be
15 changed files with 107 additions and 4 deletions
+37
View File
@@ -25,6 +25,20 @@ namespace compabetov2.Empleados
this.ventanaPadre = ventanaPadre;
imagePath = Path.Combine(Application.StartupPath, "Resources", "usuarios", empleado.img);
llenarCampos();
txtCp.KeyPress += new KeyPressEventHandler(PermitirSoloNumeros);
// Suscribir al evento KeyPress para el TextBox txtNoExt
txtNoExt.KeyPress += new KeyPressEventHandler(PermitirSoloNumeros);
// Suscribir al evento KeyPress para el TextBox txtNoInt
txtNoInt.KeyPress += new KeyPressEventHandler(PermitirSoloNumeros);
// Suscribir al evento KeyPress para el TextBox txtNombre
txtNombre.KeyPress += new KeyPressEventHandler(PermitirSoloLetras);
// Suscribir al evento KeyPress para el TextBox txtApellido
txtApellido.KeyPress += new KeyPressEventHandler(PermitirSoloLetras);
}
private void llenarCampos()
@@ -102,5 +116,28 @@ namespace compabetov2.Empleados
this.Close();
}
private void PermitirSoloNumeros(object sender, KeyPressEventArgs e)
{
// Verificar si la tecla presionada no es un número o la tecla de retroceso
if (!char.IsDigit(e.KeyChar) && e.KeyChar != 8)
{
e.Handled = true; // Ignorar la tecla presionada
// Mostrar un mensaje indicando que solo se permiten números
MessageBox.Show("Por favor, ingrese solo números.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void PermitirSoloLetras(object sender, KeyPressEventArgs e)
{
// Verificar si la tecla presionada no es una letra o la tecla de retroceso
if (!char.IsLetter(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32)
{
e.Handled = true; // Ignorar la tecla presionada
// Mostrar un mensaje indicando que solo se permiten letras
MessageBox.Show("Por favor, ingrese solo letras.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}