0

该程序运行正常。当出现提示并点击“无效 RFID”时,会弹出无效 RFID 消息,我可以再次扫描。但是,如果 RFID 被接受,我希望提示自动关闭。在这个程序中,提示不会自动关闭。我必须添加什么才能使提示自动关闭?

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        string ramses = serialPort1.ReadLine();
        SetRFIDText(ramses);

    }

    private string dotRFID = "";
    private bool shouldClose = false;

    protected void SetRFIDText(string input)
    {
        this.Invoke(new Function(delegate()
        {
            string Hexed = new LasalleRFIDComputerRentals.BLL.DAL.Utils().HexIt(input);

            dotRFID = Hexed.Trim();
            txtRFID.Text = Hexed.Trim();


            if (txtRFID.Text.Trim() == "")
            {
                MessageBox.Show(this, "Please provide the member's RFID.", "Save Member Information", MessageBoxButtons.OK);
                txtRFID.Focus();
                return;
            }

            CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);
            if (customer.CustomerID <= 0)
            {
                MessageBox.Show(this, "Incorrect RFID.", "Validation", MessageBoxButtons.OK);
                return;
            }
            else
            {

                txtRFID.Text = "";



                if (_parentForm == "StandBy")
                {
                    Utils.CurrentCustomer.CustomerInfo = customer;
                    frmStandBy form = (frmStandBy)this.Owner;
                    form.xResult = "OK";
                    this.Close();

                }

            }
           }));

    }

我尝试this.Close();在底部(下form.xResult = "OK";)使用它,但它最终挂起。帮助!

4

1 回答 1

0

好吧,我能够通过更改This.Close();This.Hide();

于 2013-03-01T08:29:10.103 回答