2013-03-01 56 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