예제 #1
0
        protected void Button_SubmitNews_Click(object sender, EventArgs e)
        {
            User creator = Help.GetUserSession(Session);

            if (creator != null)
            {
                NewsPost newPost = new NewsPost(0, creator, DateTime.Now, "", FreeTextBox1.Text);
                bool     result  = DatabaseHandler.AddNewsPost(Session, newPost);
                if (result)
                {
                    ShowNewsInfo("A new news post was created!", Color.Green);
                }
                else
                {
                    ShowNewsInfo("Error occured while trying to create a news post.", Color.Red);
                }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((MasterPage)Master).SetPagePermissionLevel(3);
            User loggedUser = Help.GetUserSession(Session);

            if (loggedUser != null && loggedUser.PermissionLevel >= 3)
            {
                List <string> activeCodes = DatabaseHandler.GetActiveCodes(Session);

                foreach (string s in activeCodes)
                {
                    Label codeLabel = new Label();
                    codeLabel.ForeColor = codeColor;
                    codeLabel.Text      = s;
                    Button deactiveButton = new Button();
                    deactiveButton.Text            = "Deactivate";
                    deactiveButton.CommandArgument = s;
                    deactiveButton.Command        += DeactiveButton_Command;
                    Panel_ActiveCodes.Controls.Add(codeLabel);
                    Panel_ActiveCodes.Controls.Add(deactiveButton);
                    Panel_ActiveCodes.Controls.Add(new LiteralControl("<br />"));
                }

                List <User> users = DatabaseHandler.GetUsers(Session, currentUserPage, currentUserPage + usersPerPage + 1);
                int         count = users.Count;
                if (users.Count > usersPerPage)
                {
                    count -= 1;
                }
                for (int i = 0; i < count; i++)
                {
                    User u = users[i];
                    if (u.PermissionLevel <= 2) //We do not want to list super referees.
                    {
                        Label l = new Label();
                        l.Text = u.Username + "  "; //Two spaces for some padding against the button.
                        Button but      = new Button();
                        bool   isRevoke = false;
                        if (u.PermissionLevel >= 2)
                        {
                            l.ForeColor = refereeColor;
                            but.Text    = "Revoke";
                            isRevoke    = true;
                        }
                        else
                        {
                            l.ForeColor = nonRefereeColor;
                            but.Text    = "Add";
                        }

                        but.CommandArgument = CreateAddRevokeArgument(u.ID, isRevoke);
                        but.Command        += But_Command;

                        Panel_CreateReferee.Controls.Add(l);
                        Panel_CreateReferee.Controls.Add(but);
                        Panel_CreateReferee.Controls.Add(new LiteralControl("<br />"));
                    }
                }

                if (users.Count > currentUserPage + usersPerPage)
                {
                    Button nextButton = new Button();
                }


                //Slow loading this is a temporary solution
                //System.Threading.Thread.Sleep(1000);

                //Checking if data needs to be filled in...
                string editID = Request.QueryString["editID"];
                if (editID != null)
                {
                    int      postID = int.Parse(editID);
                    NewsPost post   = DatabaseHandler.GetNewsPost(postID);
                    if (post != null && post.Creator.ID == loggedUser.ID)
                    {
                        editingPost                = post;
                        FreeTextBox1.Text          = post.Data; //Server.HtmlDecode(post.Data);
                        FreeTextBox1.UpdateToolbar = true;
                    }
                }
            }
        }