protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            if (e.CloseReason == CloseReason.WindowsShutDown ||
                e.CloseReason == CloseReason.ApplicationExitCall ||
                e.CloseReason == CloseReason.TaskManagerClosing)
            {
                return;
            }

            foreach (Form form in Application.OpenForms)
            {
                //Don't logout if this is an open form which isn't the login form
                // and isn't this form, which is closing now.
                // *** this condition represents a transition between two forms *** //
                if ((String.Compare(form.Name, "LoginForm") != 0) &&
                    (String.Compare(form.Name, this.Name) != 0))
                {
                    return;
                }
            }

            // Log them out. A click to the X button on the Login form will be required to exit like this.
            _loginForm.Logout();
        }
 private void lnkLogout_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     _loginForm.Logout();
     this.Close();
 }
 private void btnCancel_Click(object sender, EventArgs e)
 {
     _loginForm.Logout();
     this.Close();
 }