Exemplo n.º 1
0
        /// <summary>
        /// Method updates labels on start1.aspx with relevant values.
        /// Uses method GetLoggedInUserInfo to retrieve said information,
        /// </summary>
        private void UpdateWebsiteGUI()
        {
            DatabaseConnection dc = new DatabaseConnection();
            DataTable dt = new DataTable();
            DataTable dtAllInfo = new DataTable();

            dt = dc.GetPersonInfo(userId);
            string userName = dt.Rows[0]["username"].ToString();
            lblUserName.Text = userName;

            dtAllInfo = dc.GetPersonAndTestInfo(userName);

            if (dtAllInfo.Rows.Count <= 0)
            {
                lblresult.Text = "Inget test hittat";
                lbldate.Text = "Inget datum";
                lbltestToDo.Text = "1";
                lblTestType.Text = "LST";
                DateTime today = DateTime.Now;
                lblNextTestDate.Text = today.ToString("yyyy-MM-dd");
                btnGoToOldTest.Enabled = false;
            }
            else
            {
                string passTest = dtAllInfo.Rows[0]["passed"].ToString();

                DateTime date = DateTime.Parse(dtAllInfo.Rows[0]["date"].ToString());
                lblresult.Text = SetPassOrFail(passTest);
                lbltestToDo.Text = CheckDateOfLastTest(date, passTest);
                lbldate.Text = date.ToString("yyyy-MM-dd");
                lblTestType.Text = SetTypeOfTest();
                lblTestTypeDone.Text = dtAllInfo.Rows[0]["testtype"].ToString();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method assumes that that a user has been redirected from a login page
        /// calls method GetLoggedinuserinfo to retrieve what privielge user have
        /// to see if admin or not. Hides navbar button to get to adminpanel.
        /// Should maybe put this in a class togheter with GeLoggedInUserInfo
        /// to be able to use it on every page? Good enough for the demo,
        /// but will have to be reworked, preferably with a proper nuget or built in
        /// system to restrict access to webpages.
        /// </summary>
        private void CheckPrivilegeHideNavButton()
        {
            DatabaseConnection dc = new DatabaseConnection();
            DataTable dt = dc.GetPersonInfo(userId);
            string userType = dt.Rows[0]["privilege"].ToString();

            if (userType != "Admin")
            {
                //Goes through HTML to find buttons to hide.
                HtmlAnchor menuButton = (HtmlAnchor)Page.Master.FindControl("adminButton");
                HtmlAnchor menuButton1 = (HtmlAnchor)Page.Master.FindControl("a1");
                //Hides buttons.
                menuButton.Visible = false;
                menuButton1.Visible = false;
            }
        }