Esempio n. 1
0
    private void BindArticleItems()
    {
        PagedDataSource pds            = new PagedDataSource();
        DataTable       dtArticleItems = null;

        pds.AllowPaging = true;

        if (IsAdmin)
        {
            dtArticleItems = Forum.GetArticleItems(ArticleID, Forum.ArticleItemStatus.All);
        }
        else
        {
            dtArticleItems = Forum.GetArticleItems(ArticleID, Forum.ArticleItemStatus.Active);
        }


        Forum.ArticleStatus ForumAStatus = Forum.GetArticleStatus(ArticleID);

        if (ForumAStatus == Forum.ArticleStatus.Deactive)
        {
            Forum.GotoDefaultPage(this.Response);
        }

        if (ForumAStatus == Forum.ArticleStatus.Locked && (!IsAdmin))
        {
            btnReply.Visible  = false;
            btnReply2.Visible = false;
        }

        pds.DataSource = dtArticleItems.DefaultView;

        UctrlPaging2.RecordCount = UctrlPaging1.RecordCount = pds.DataSourceCount;
        pds.PageSize             = UctrlPaging1.PageSize = UctrlPaging2.PageSize;
        pds.CurrentPageIndex     = UctrlPaging1.CurrentPage - 1;

        rptArticleItems.DataSource = pds;
        rptArticleItems.DataBind();

        #region Edit and ddlScore

        DataTable dtScores = Forum.GetItemScores();
        foreach (RepeaterItem rptitem in rptArticleItems.Items)
        {
            DropDownList ddlScore = ((DropDownList)(rptitem.FindControl("ddlScore")));

            ddlScore.DataSource     = dtScores;
            ddlScore.DataTextField  = "Text";
            ddlScore.DataValueField = "Value";
            ddlScore.DataBind();

            if (SessRoot != null)
            {
                int MemberID = int.Parse(((Label)rptitem.FindControl("lblMemberID")).Text);

                if (MemberID == SessRoot.UserID || IsAdmin)
                {
                    ((Panel)(rptitem.FindControl("pnlEdit"))).Visible = true;
                }
            }

            if (ForumAStatus == Forum.ArticleStatus.Locked && (!IsAdmin))
            {
                ((ImageButton)rptitem.FindControl("btnEdit")).Visible  = false;
                ((ImageButton)rptitem.FindControl("btnReply")).Visible = false;
            }

            if (((Label)rptitem.FindControl("lblRMemberID")).Text == "" || ((Label)rptitem.FindControl("lblRMemberID")).Text == "-1")
            {
                ((Panel)rptitem.FindControl("pnlMemberCreated")).Visible = false;
                ((Panel)rptitem.FindControl("pnlAdminCreated")).Visible  = true;
            }
        }

        #endregion
    }
Esempio n. 2
0
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        switch (ItemType)
        {
        case Forum.ItemType.Category:
        {
            Forum.CategoryStatus state = Forum.CategoryStatus.Active;

            if (ddlState.SelectedIndex == -1)
            {
                state = (Forum.CategoryStatus) int.Parse(ddlState.Items[0].Value);
            }
            else
            {
                state = (Forum.CategoryStatus) int.Parse(ddlState.SelectedValue);
            }

            if (ItemID == -1)
            {
                Forum.InsertCategory(txtSubject.Text.Trim(), ForumTextBox1.Text, state, SessRoot.UserID);
            }
            else
            {
                Forum.UpdateCategory(ItemID, txtSubject.Text.Trim(), ForumTextBox1.Text, state);
            }
            break;
        }

        case Forum.ItemType.Article:
        {
            Forum.ArticleStatus state = Forum.ArticleStatus.Active;

            if (ddlState.SelectedIndex == -1)
            {
                state = (Forum.ArticleStatus) int.Parse(ddlState.Items[0].Value);
            }
            else
            {
                state = (Forum.ArticleStatus) int.Parse(ddlState.SelectedValue);
            }


            if (ItemID == -1)
            {
                int UserID = SessRoot.UserID;
                if (IsAdmin)
                {
                    UserID = -1;
                }
                Forum.InsertArticle(txtSubject.Text.Trim(), ForumTextBox1.Text, state, CategoryID, UserID, SessRoot.NickName);
            }
            else
            {
                Forum.UpdateArticle(ItemID, txtSubject.Text.Trim(), ForumTextBox1.Text, state, int.Parse(ddlCategory.SelectedValue));
            }
        }
        break;

        case Forum.ItemType.ArticleItem:
        {
            Forum.ArticleItemStatus state = Forum.ArticleItemStatus.Active;

            if (ddlState.SelectedIndex == -1)
            {
                state = (Forum.ArticleItemStatus) int.Parse(ddlState.Items[0].Value);
            }
            else
            {
                state = (Forum.ArticleItemStatus) int.Parse(ddlState.SelectedValue);
            }

            if (ItemID == -1)
            {
                int UserID = SessRoot.UserID;
                if (IsAdmin)
                {
                    UserID = -1;
                }

                Forum.InsertArticleItem(CategoryID, ArticleID, txtSubject.Text.Trim(), ForumTextBox1.Text, state, UserID, SessRoot.NickName);
            }
            else
            {
                if (isMainArticleItem)
                {
                    Forum.UpdateArticleItem(ItemID, ArticleID, txtSubject.Text.Trim(), ForumTextBox1.Text, state);
                }
                else
                {
                    Forum.UpdateArticleItem(ItemID, txtSubject.Text.Trim(), ForumTextBox1.Text, state);
                }
            }
        }
        break;
        }

        if (RefreshData != null)
        {
            RefreshData(null, EventArgs.Empty);
        }
        this.Visible = false;

        if (ItemType == Forum.ItemType.Article && ArticleID != -1)
        {
            Response.Redirect("Category.aspx?CategoryID=" + CategoryID.ToString());
        }
    }