private void TxtBxCedula_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { int lim = 10; int res; string Cedula = TxtBxCedula.Text; char[] num = Cedula.ToArray(); if (num.Length == 10) { ClCedula objVerificar = new ClCedula(num, lim); res = objVerificar.Verificar(); if (res > 0) { TxtBxCedula.ReadOnly = true; TxtBxNombre.Focus(); } else { MessageBox.Show("Cédula Incorrecta"); TxtBxCedula.Text = ""; } } else { MessageBox.Show("Cedula con mayor a 10 dígitos, INCORRECTO"); TxtBxCedula.Text = ""; } } }
private void TxtBxNombreUsuario_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { int lim = 10; int res; string Cedula = TxtBxCedula.Text; char[] num = Cedula.ToArray(); if (num.Length == 10) { ClCedula objVerificar = new ClCedula(num, lim); res = objVerificar.Verificar(); if (res > 0) { matSeg1.TblEmpleados.ReadXml(Application.StartupPath + "\\ArchEmpleados.xml"); System.Data.DataRow[] mats; mats = matSeg1.TblEmpleados.Select("Cedula='" + TxtBxCedula.Text + "'"); if (mats.Length > 0) { LblNombre.Text = mats[0]["Nombre"].ToString(); LblApellido.Text = mats[0]["Apellido"].ToString(); cant = int.Parse(LblCExis.Text); if (cant == 0) { MessageBox.Show("No existe ningún material de seguridad", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCantidad.Enabled = false; Bttguardar.Enabled = false; this.Close(); } TxtBxCantidad.Focus(); } else { MessageBox.Show("La cédula del responsable no existe en la empresa", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBxCedula.Text = ""; } } else { MessageBox.Show("Cédula Incorrecta"); TxtBxCedula.Text = ""; } } else { MessageBox.Show("Cedula con mayor a 10 dígitos, INCORRECTO"); TxtBxCedula.Text = ""; } } }