当点击只获得1位数

时间:2016-09-23 03:54:22

标签: c# winforms rfid

我的rfid卡值是

rfidno

案例是当我点击为什么文本不为空?当我点击第二张卡时,它只给我一位数

tapcard1

card2点击

tapcard2

我使用的代码

 private void textEdit1_KeyPress(object sender, KeyPressEventArgs e)
    {

        if (this.textEdit1.Text.Length == 10)
        {
            getcodestudent();
            this.textEdit1.Text = "";
        }
    }

for getcodestudent()

  public void getcodestudent()
    {
        SqlDataAdapter adapter = new SqlDataAdapter();
        SqlParameter para2 = new SqlParameter();
        try
        {
            ds6.Clear();
            dt6.Clear();

            command6.Connection = myConnection;
            command6.CommandText = //..//;                               
            adapter.SelectCommand = command6;
            adapter.Fill(ds6);
            adapter.Fill(dt6);                               
        }
        catch (Exception ex)
        {
            MessageBox.Show("error" + ex);

        }
        if (dt6.Rows.Count == 1)
        {
            member = ds6.Tables[0].Rows[0][0].ToString();
            MessageBox.Show(member);
        }

但是,如果我使用卡片backspace点击后删除文字,然后再使用卡片再次点击,那么在运行getcodestudent(); this.textEdit1.Text = "";

时,它可以正常运行

0 个答案:

没有答案