/// <summary>
 /// this statement is used to Verify the username and password match with the database
 /// otherwise return the message of incorrect details.
 /// written by author : Abdelrahman Ahmed
 /// </summary>
 private void LoginInit()
 {
     if (LoginAuth.VerifyLogin(Username_txt.Text, Password_txt.Password))
     {
         MainEvent window = new MainEvent();
         window.Show();
         this.Close();
     }
     else
     {
         progbar.Opacity = 0;
         MessageBox.Show("Incorrect details. Please try again.");
     }
 }
Example #2
0
        private void TimetableVisibility()
        {
            string currentRole = LoginAuth.displayRole();

            if (currentRole == "admin")
            //admin = Manager Role
            {
                eventsDataGrid.Visibility  = Visibility.Visible;
                accessDeniedlbl.Visibility = Visibility.Hidden;
            }
            if (currentRole == "user")
            //user = Labourer Role
            {
                eventsDataGrid.Visibility  = Visibility.Hidden;
                accessDeniedlbl.Visibility = Visibility.Visible;
            }
        }
        /// <summary>
        /// after initialise component the uername appears on the top of the window
        /// and then the switch case is used to display certain properities
        /// depending if the user is an admin or not
        /// written by author : Abdelrahman Ahmed
        /// </summary>
        public MainEvent()
        {
            InitializeComponent();
            UserView.Text = LoginAuth.displayuser();
            switch (LoginAuth.permcheck())
            {
            case "admin":
                Users.IsEnabled    = true;
                Delivery.IsEnabled = true;

                break;

            case "user":
                Users.IsEnabled    = false;
                Delivery.IsEnabled = false;
                break;

            default:
                break;
            }
        }
        //Displaying buttons accordingly to user's role
        private void ButtonsVisibility()
        {
            //Getting the logged in user's role (admin or user)
            string currentRole = LoginAuth.displayRole();

            //admin = Manager Role
            if (currentRole == "admin")
            {
                //Display all buttons
                Button_Crops_Cultivation.Visibility = Visibility.Visible;
                Button_Fertiliser_Plan.Visibility   = Visibility.Visible;
                Button_Fertiliser_Stock.Visibility  = Visibility.Visible;
            }
            //user = Labourer Role
            if (currentRole == "user")
            {
                //Display only one button, "Fertiliser Plan"
                Button_Crops_Cultivation.Visibility = Visibility.Hidden;
                Button_Fertiliser_Plan.Visibility   = Visibility.Visible;
                Button_Fertiliser_Stock.Visibility  = Visibility.Hidden;
            }
        }