C#如何自动从RFID扫描中恢复?

Kae*_*ael 5 c# button rfid

我有一个程序,其中用户在阅读器上轻敲RFID卡,程序将输入该数据.在这个程序中,有一个提示,我必须单击确定.轻敲RFID卡后,如何取下确定按钮并将其设为自动确认程序?

以下是该计划的部分内容:

委托void Function();

    private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        string sdsd = serialPort1.ReadLine();
        string Hexed = new LasalleRFIDComputerRentals.BLL.DAL.Utils().HexIt(sdsd);

        SetRFIDText(Hexed);
    }


    protected void SetRFIDText(string input)
    {
        this.Invoke(new Function(delegate()
        {
            txtRFID.Text = input;
        }));

        CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);


    }

    private void btnOk_Click(object sender, EventArgs e)
    {
        if (txtRFID.Text.Trim() == "")
        {
            MessageBox.Show(this, "Please supply the RFID.", "RFID Reader", MessageBoxButtons.OK);

            txtRFID.Focus();
            return;
        }

        CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);

        if (customer.CustomerID <= 0)
        {
            MessageBox.Show("Invalid RFID", "Validation");

            this.Close();
            return;
        }


        if (_parentForm == "StandBy")
        {
            Utils.CurrentCustomer.CustomerInfo = customer;

            frmStandBy form = (frmStandBy)this.Owner;

            form.xResult = "OK";
        }

        this.Close();
    }
Run Code Online (Sandbox Code Playgroud)

Flo*_*ris 0

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    string sdsd = serialPort1.ReadLine();
    string Hexed = new LasalleRFIDComputerRentals.BLL.DAL.Utils().HexIt(sdsd);

    SetRFIDText(Hexed);
    btnOK_click(sender, e);
}
Run Code Online (Sandbox Code Playgroud)

这并没有回答“如何删除“确定”按钮”的问题,因为您首先没有显示它是如何创建的 - 我怀疑您需要为此编辑表单定义。在这种情况下,将 btnOK_click 的代码从事件处理程序更改为“常规”函数(无论如何,这都是一个好主意)。