private void RfidTestForm_FormClosing(object sender, FormClosingEventArgs e) { rfid.Attach -= new AttachEventHandler(rfid_Attach); rfid.Detach -= new DetachEventHandler(rfid_Detach); rfid.Tag -= new TagEventHandler(rfid_Tag); rfid.TagLost -= new TagEventHandler(rfid_TagLost); //run any events in the message queue - otherwise close will hang if there are any outstanding events Application.DoEvents(); FormMain form1 = new FormMain(); }
private void Login() { string username = textBoxUsername.Text; string password = textBoxPassword.Text; bool isUser = false; if (username.Length > 0 && password.Length > 0) { try { FormLoading.Show(); Database db = new Database(); db.CreateCommand("SELECT id FROM users WHERE username = :username AND password = :password AND isemployee = 1"); db.AddParameter("username", username); db.AddParameter("password", password); db.OpenConnection(); db.ExecuteCommand(); OracleDataReader dr = db.DataReader; if (dr.HasRows) { isUser = true; } db.CloseConnection(); FormLoading.CloseForm(); } catch (Exception ex) { MessageBox.Show(ex.Message); labelResult.Text = "Verbinding met database mislukt."; return; } if (isUser) { this.Hide(); this.formMain = new FormMain(); this.formMain.Show(); this.formMain.FormClosing += formMain_FormClosing; } else { labelResult.Text = "Uw aanmeldgegevens zijn onjuist."; } } }