private void btnExit_Click(object sender, EventArgs e) { if (user != null) { DialogResult result = MessageBox.Show("Do you want to log out", "Message", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { user = null; setBtnHistoryEnable(false); MessageBox.Show("Log out sucessful"); } } else { LoginUser loginUser = new LoginUser(this); loginUser.Show(); } }