Subo Cambio 555
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user