Exemple #1
0
        //
        // FORM
        //

        public void setPermissions()
        {
            // Hide all items
            bool lValue = false; // for debug

            foreach (ToolStripMenuItem Item in menuStrip.Items)
            {
                Item.Visible = lValue;

                foreach (ToolStripItem dropItem in Item.DropDownItems)
                {
                    dropItem.Visible = lValue;
                }
            }

            // Login button
            if (LoginData.Logged)
            {
                this.itemLogin.Visible  = false;
                this.itemLogout.Visible = true;
            }
            else
            {
                this.itemLogin.Visible  = true;
                this.itemLogout.Visible = false;
            }

            //
            // Set permissions
            //
            if (LoginData.havePermission("SHOW_ADMIN_PANEL", LoginData.AccessControl.YES))
            {
                this.menuAdmin.Visible = true;
            }
            if (LoginData.havePermission("SHOW_SHOW_PANEL", LoginData.AccessControl.YES))
            {
                this.menuShow.Visible = true;
            }
            if (LoginData.havePermission("SHOW_TOOLS_PANEL", LoginData.AccessControl.YES))
            {
                this.menuTools.Visible = true;
            }

            // menuShow
            if (LoginData.havePermission("SHOW_BUILDS", LoginData.AccessControl.YES) ||
                LoginData.havePermission("SHOW_BUILDS", LoginData.AccessControl.ONLY_OWN))
            {
                this.menuShow_Builds.Visible = true;
            }
            if (LoginData.havePermission("SHOW_COMPONENTS", LoginData.AccessControl.YES))
            {
                this.menuShow_Components.Visible = true;
            }
            if (LoginData.havePermission("SHOW_STATISTICS", LoginData.AccessControl.ONLY_OWN) ||
                LoginData.havePermission("SHOW_STATISTICS", LoginData.AccessControl.YES))
            {
                this.menuShow_Statistics.Visible = true;
                this.menuShow_Separator.Visible  = true;
            }


            //menuAdmin
            if (LoginData.havePermission("SHOW_USERS", LoginData.AccessControl.YES))
            {
                this.menuAdmin_Users.Visible = true;
            }
            if (LoginData.havePermission("SHOW_COMPONENTS_TYPES", LoginData.AccessControl.YES))
            {
                this.menuAdmin_Types.Visible = true;
            }
            if (LoginData.havePermission("SHOW_ROLES", LoginData.AccessControl.YES))
            {
                this.menuAdmin_Roles.Visible = true;
            }
            if (LoginData.havePermission("SHOW_STATISTICS", LoginData.AccessControl.YES))
            {
                this.menuAdmin_Statistics.Visible = true;
                this.menuAdmin_Separator.Visible  = true;
            }

            //menuTools
            if (LoginData.havePermission("SHOW_TOOLS_PANEL", LoginData.AccessControl.YES))
            {
                this.menuTools.Visible         = true;
                this.menuTools_Options.Visible = true;
                this.menuTool_Profil.Visible   = true;
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                SqlCommand checkPaswd = new SqlCommand("SELECT [dbo].[checkPassword] (@idUsr, @newPasswd) as [result]", SqlConn.Connection);
                checkPaswd.Parameters.AddWithValue("@idUsr", LoginData.GetUserID());
                checkPaswd.Parameters.AddWithValue("@newPasswd", Utilities.StringHash(textBox1.Text));

                bool exist = (bool)(checkPaswd.ExecuteScalar());

                if (exist == true)
                {
                    MessageBox.Show("Enter a diffrent password");
                }
                else
                {
                    SqlCommand updatePassword = new SqlCommand("UPDATE USERS SET usrPasswd = '" + Utilities.StringHash(textBox1.Text) + "' WHERE usrID = " + LoginData.GetUserID(), SqlConn.Connection);
                    updatePassword.ExecuteNonQuery();
                    MessageBox.Show("You have changed your password");
                }
            }
            else
            {
                MessageBox.Show("Enter a new password");
            }
        }