I have a program wherein the user taps an RFID card on a reader and the program will input this data. In this program, there is a prompt wherein I have to click OK. How do I remove the OK button and make it an auto-OK program once the RFID card is tapped?
Here are the parts of the program:
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();
}
Simply separate the logic of the OK button
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With