2013-03-01 60 views
0

该程序正常工作。当出现提示并点击“无效RFID”时,弹出无效RFID信息,并且我可以再次扫描。但是,如果RFID被接受,我希望提示关闭AUTOMATICALLY。在这个程序中,提示符没有关闭AUTOMATICALLY。我必须添加什么才能使提示关闭AUTOMATICALLY?如何关闭提示窗口?

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";),但它结束了挂。帮帮我!

+0

你问[同样的问题(http://stackoverflow.com/questions/15152754/how-to-close-the-prompt - 窗口)几分钟前,你删除它。你为什么再问一次?你需要改进旧的才能获得更好的答案。请阅读[常见问题]和[问] – 2013-03-01 08:03:38

+0

对不起。我在这里更清楚了。 – Kael 2013-03-01 08:10:02

回答

0

好,我是能够使通过改变它的工作This.Close();This.Hide();

+0

我希望你不要经常使用This.Hide()。你永远不要使用这个问题,如果你想关闭一些东西,你就关闭它。如果你曾经在大型项目中工作过,那么你会注意到它的性能,因为它的全部功能就是隐藏它,它仍然在后台运行并且吸收你的性能。 – WeeklyDad 2013-03-01 08:34:08