Пример #1
0
 public void HideUnauthorizedButtons(ControlCollection controls)
 {
     foreach (Control c in controls)
     {
         if (c is Panel)
         {
             HideUnauthorizedButtons(c.Controls);
         }
         else if (c is ProtectedButton)
         {
             (c as ProtectedButton).CheckRole(DBUser.GetRole());
         }
     }
 }
Пример #2
0
        public void SetScreen(Screen screen, bool isExtendedForm = true)
        {
            //Check if the current user is allowed to access the passed screen
            if (screen.IsAuthorized(DBUser.GetRole()))
            {
                //Clear the status text
                this.SetStatus("");

                //Set the forms title to the screen title
                this.lblPageTitle.Text = screen.Title;

                //Only show the back button if it makes sense for there to be a screen before it
                this.btnBack.Visible = screen.BackScreen != null;

                //Don't show the back to main menu button if the current screen is the main menu or login screen
                this.btnBackToMainMenu.Visible = !(screen is MainMenuScreen || screen is LoginScreen);

                //Include additional master page options if true
                this.SetExtended(isExtendedForm);

                //Remove the current screen and replace it with the passed screen
                this.tlpMasterLayout.Controls.Remove(currentScreen);
                this.currentScreen = screen;
                this.tlpMasterLayout.Controls.Add(currentScreen, 0, 1);

                this.currentScreen.HideUnauthorizedButtons(this.Controls);

                //Set the active control to null so no buttons are auto-focused
                //and the accept button is prioritized
                this.ActiveControl = null;
            }
            else
            {
                //TODO: Log failed access attempt
                this.SetStatus("Error! You do not have access to the requested screen");
            }
        }
Пример #3
0
 private void btnLogout_Click(object sender, EventArgs e)
 {
     DBUser.Logout();
     this.SetScreen(this.screenLogin, false);
 }