Beispiel #1
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        bool bRemoved = false;

        for (int i = 0; i < gvItems.Rows.Count; i++)
        {
            CheckBox cb = gvItems.Rows[i].FindControl("cb") as CheckBox;
            if (cb.Checked)
            {
                int     iCommentID = 0;
                Literal literal    = gvItems.Rows[i].FindControl("CommentID") as Literal;
                if (literal != null)
                {
                    int.TryParse(literal.Text, out iCommentID);
                }

                BSComment bsComment = BSComment.GetComment(iCommentID);
                if (bsComment != null)
                {
                    bRemoved = bsComment.Remove();
                }
            }
        }
        if (bRemoved)
        {
            MessageBox1.Message = Language.Admin["CommentDeleted"];
            MessageBox1.Type    = MessageBox.ShowType.Information;
            MessageBox1.Visible = true;
            gvItems.DataBind();
        }
    }
Beispiel #2
0
    public void ApproveUnApprove(int approve)
    {
        bool bApproved = false;

        for (int i = 0; i < gvItems.Rows.Count; i++)
        {
            CheckBox cb = gvItems.Rows[i].FindControl("cb") as CheckBox;
            if (cb.Checked)
            {
                int     iCommentID = 0;
                Literal literal    = gvItems.Rows[i].FindControl("CommentID") as Literal;
                if (literal != null)
                {
                    int.TryParse(literal.Text, out iCommentID);
                }

                BSComment bsComment = BSComment.GetComment(iCommentID);

                if (bsComment != null)
                {
                    bApproved = bsComment.DoApprove(approve == 1);
                }
            }
        }
        if (bApproved)
        {
            MessageBox1.Message = approve == 1 ? Language.Admin["SelectedApproved"] : Language.Admin["SelectedUnApproved"];
            MessageBox1.Type    = MessageBox.ShowType.Information;
            MessageBox1.Visible = true;
        }
    }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string commentID  = Request["CommentID"];
            int    iCommentID = 0;

            int.TryParse(commentID, out iCommentID);

            if (iCommentID > 0)
            {
                divComments.Visible        = false;
                divEditComment.Visible     = true;
                divSideEditComment.Visible = true;

                BSComment bsComment = BSComment.GetComment(iCommentID);
                txtName.Text           = bsComment.UserName;
                txtWebSite.Text        = bsComment.WebPage;
                txtComment.Text        = bsComment.Content;
                txtEMail.Text          = bsComment.Email;
                ltIP.Text              = bsComment.IP;
                rblState.SelectedValue = bsComment.Approve ? "1" : "0";
                ltCommentedPost.Text   = BSPost.GetPost(bsComment.PostID).LinkedTitle;

                // DateTime
                txtDateDay.Text   = bsComment.Date.Day.ToString("00");
                txtDateMonth.Text = bsComment.Date.Month.ToString("00");
                txtDateYear.Text  = bsComment.Date.Year.ToString("0000");

                txtTimeHour.Text   = bsComment.Date.Hour.ToString("00");
                txtTimeMinute.Text = bsComment.Date.Minute.ToString("00");
                txtTimeSecond.Text = bsComment.Date.Second.ToString("00");
            }
            else
            {
                divComments.Visible        = true;
                divEditComment.Visible     = false;
                divSideEditComment.Visible = false;
                gvItems.DataBind();
            }
        }
        btnDelete.OnClientClick = "return confirm('" + Language.Admin["CommentDeleteConfirm"] + "');";
    }
Beispiel #4
0
    protected void btnSavePost_Click(object sender, EventArgs e)
    {
        try
        {
            int iCommentID = 0;
            int.TryParse(Request["CommentID"], out iCommentID);

            BSComment bsComment = BSComment.GetComment(iCommentID);
            bsComment.UserName = txtName.Text;
            bsComment.Content  = txtComment.Text;
            bsComment.Email    = txtEMail.Text;
            bsComment.WebPage  = txtWebSite.Text;

            bsComment.Date = new DateTime(
                Convert.ToInt16(txtDateYear.Text),
                Convert.ToInt16(txtDateMonth.Text),
                Convert.ToInt16(txtDateDay.Text),
                Convert.ToInt16(txtTimeHour.Text),
                Convert.ToInt16(txtTimeMinute.Text),
                Convert.ToInt16(txtTimeSecond.Text));

            bsComment.Approve = rblState.SelectedValue.Equals("1");

            if (bsComment.Save())
            {
                MessageBox1.Message = Language.Admin["CommentSaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
            }
            else
            {
                MessageBox1.Message = "Error";
                MessageBox1.Type    = MessageBox.ShowType.Error;
            }
        }
        catch (System.Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
Beispiel #5
0
    private static void FillMenu(IDataReader dr, BSMenu menu)
    {
        menu.Description = (string)dr["Description"];
        menu.MenuGroupID = (int)dr["MenuGroupID"];
        menu.MenuID      = (int)dr["MenuID"];
        menu.MenuType    = (MenuTypes)dr["MenuType"];
        menu.ObjectID    = (int)dr["ObjectID"];
        menu.ObjectType  = (ObjectTypes)dr["ObjectType"];
        menu.ParentID    = (int)dr["ParentID"];
        menu.Sort        = (short)dr["Sort"];
        menu.Target      = (string)dr["Target"];
        menu.Title       = (string)dr["Title"];
        menu.Url         = (string)dr["Url"];

        if (menu.Url.StartsWith("~/"))
        {
            menu.Url = Blogsa.Url + menu.Url.Substring(2);
        }

        switch (menu.ObjectType)
        {
        case ObjectTypes.Article:
            BSPost article = BSPost.GetPost(menu.ObjectID);
            if (article != null)
            {
                menu.Title = article.Title;
                menu.Url   = article.Link;
            }
            break;

        case ObjectTypes.Page:
            BSPost page = BSPost.GetPost(menu.ObjectID);
            if (page != null)
            {
                menu.Title = page.Title;
                menu.Url   = page.Link;
            }
            break;

        case ObjectTypes.File:
            BSPost file = BSPost.GetPost(menu.ObjectID);
            if (file != null)
            {
                menu.Title = file.Title;
                menu.Url   = file.Link;
            }
            break;

        case ObjectTypes.Link:
            BSLink link = BSLink.GetLink(menu.ObjectID);
            if (link != null)
            {
                menu.Title = link.Name;
                menu.Url   = link.Url;
            }
            break;

        case ObjectTypes.Term:
            BSTerm term = BSTerm.GetTerm(menu.ObjectID);
            if (term != null)
            {
                menu.Title = term.Name;
                menu.Url   = term.Link;
            }
            break;

        case ObjectTypes.Comment:
            BSComment comment = BSComment.GetComment(menu.ObjectID);
            if (comment != null)
            {
                menu.Title = comment.Content;
                menu.Url   = comment.Link;
            }
            break;

        default:
            break;
        }
    }