private void TxtContact_KeyUp(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Enter: { TxtID.SelectAll(); TxtID.Focus(); break; } } }
//当移出会员框,判断是否有重名 private void TxtID_Leave(object sender, EventArgs e) { DBHelper db = null; try { db = new DBHelper(); string sql = string.Format("select count(*) from users where U_UsersId='{0}'", TxtID.Text); if ((int)db.SelectOne(sql) > 0) { MessageBox.Show("已有相同的用户名!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtID.Focus(); TxtID.SelectAll(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }