gpt4 book ai didi

C# 如何从 RFID 扫描中自动确定?

转载 作者:太空狗 更新时间:2023-10-29 23:46:45 26 4
gpt4 key购买 nike

我有一个程序,其中用户在读取器上轻敲 RFID 卡,程序将输入此数据。在此程序中,有一个提示,我必须单击“确定”。如何删除 OK 按钮并使其成为轻触 RFID 卡后的自动 OK 程序?

程序部分如下:

委托(delegate) 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();
}

最佳答案

将OK按钮的逻辑简单分离

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;
}));

// what is it for?
//CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);

SearchCustomer();

}

private void btnOk_Click(object sender, EventArgs e)
{
SearchCustomer();
}

private void SearchCustomer()
{

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";
}

// what is it for?
//this.Close();

}

关于C# 如何从 RFID 扫描中自动确定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15150672/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com