Example #1
0
    private void BindData()
    {
        NewsForum _NewsForum = new NewsForum();
        int       newsID     = AppUtils.Request("newsid");
        int       status     = Convert.ToInt32(drpStatus.SelectedValue);
        int       pageIndex  = Convert.ToInt32(drpPage.SelectedValue);
        int       pageSize   = Convert.ToInt32(drpPageSize.SelectedValue);;
        int       total      = 0;

        rptList.DataSource = _NewsForum.GetList(newsID, status, pageIndex, pageSize, ref total);
        rptList.DataBind();

        lblTotal.Text = "(" + total.ToString() + ")";
        total         = (total - 1) / pageSize + 1;
        if (total == 0)
        {
            total = 1;
        }
        drpPage.Items.Clear();
        for (int i = 1; i <= total; i++)
        {
            drpPage.Items.Add(new ListItem(i.ToString()));
        }

        try
        {
            drpPage.SelectedValue = pageIndex.ToString();
        }
        catch
        {
        }
    }
    private void init()
    {
        NewsForum _NewsForum = new NewsForum()
        {
            ForumID = AppUtils.Request("id")
        };

        _NewsForum = _NewsForum.Get();
        if (_NewsForum.ForumID == 0)
        {
            Response.Redirect(Constant.ADMIN_PATH + Resources.Url.SignOut);
        }

        txtTitle.Text            = _NewsForum.Title;
        lblCreatedTime.Text      = _NewsForum.CreatedTime.ToString("dd/MM/yyyy HH'h'mm");
        txtContent.Text          = _NewsForum.Content;
        txtHeader.Text           = _NewsForum.Header;
        txtEmail.Text            = _NewsForum.Email;
        hplNewsForum.NavigateUrl = Constant.ADMIN_PATH + Resources.Url.NewsForumList + "?newsid=" + _NewsForum.NewsID.ToString();
        cbxStatus.Checked        = _NewsForum.Status == 2;

        News _News = new News()
        {
            NewsID = _NewsForum.NewsID
        };

        _News             = _News.Get();
        lblNewsTitle.Text = _News.Title;
    }
    protected void btDelete_Click(object sender, EventArgs e)
    {
        NewsForum _NewsForum = new NewsForum()
        {
            ForumID = AppUtils.Request("id")
        };

        _NewsForum.Delete();
        Response.Redirect(Request["u"]);
    }
    protected void btUpdate_Click(object sender, EventArgs e)
    {
        NewsForum _NewsForum = new NewsForum()
        {
            ForumID = AppUtils.Request("id")
        };

        _NewsForum         = _NewsForum.Get();
        _NewsForum.Title   = txtTitle.Text.Trim();
        _NewsForum.Content = txtContent.Text.Trim();
        _NewsForum.Header  = txtHeader.Text.Trim();
        _NewsForum.Email   = txtEmail.Text.Trim().ToLower();
        _NewsForum.Status  = cbxStatus.Checked ? 2 : 1;
        _NewsForum.Update();
        Response.Redirect(Request["u"]);
    }