using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JuSNS.Common;
using JuSNS.UI.Control;

namespace JuSNS.Web.system.sys
{
    public partial class gbook : JuSNS.UI.Page.ManagePage
    {
        protected string sort = "sys";
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadList();
            Operate();
        }

        /// <summary>
        /// 加载分页
        /// </summary>
        protected void LoadList()
        {
            int r, p, PageIndex = 0;
            PageIndex = Convert.ToInt32(Request.QueryString["Page"]);
            string a = Request.QueryString["a"];
            DataTable dt = null;
            if (!string.IsNullOrEmpty(a))
            {
                dt = JuSNS.Home.UtilPage.GetPage("guestbookA_1_aspx", PageIndex, 20, out r, out p, null);
            }
            else
            {
                dt = JuSNS.Home.UtilPage.GetPage("guestbook_1_aspx", PageIndex, 20, out r, out p, null);
            }
            if (dt != null)
            {
                Rpt_SysNotepad.DataSource = dt;
                Rpt_SysNotepad.DataBind();
                dt.Clear();
                dt.Dispose();
            }
            //判断是否调用分页
            if (r > 20)
            {
                DivPage.InnerHtml = PageNavigator.Pagination(PageIndex, p, "gbook.aspx?a="+a+"");
            }
        }

        protected string GetRep(object RecID,object ID)
        {
            if (RecID.ToString() == "-1")
            {
                return "<a href=\"javascript:edit(" + ID.ToString() + ");\">回复</a>|";
            }
            else
            {
                return string.Empty;
            }

        }
        /// <summary>
        /// 取得管理员是否回复
        /// </summary>
        /// <param name="Replier">管理员编号(如果为0则是未回复的信息)</param>
        /// <returns></returns>
        protected string getReply(object Replier)
        {
            string s_Reply = "已回复";
            if (Replier.ToString() == "0")
                s_Reply = "<font color=red>未回复</font>";
            return s_Reply;
        }

        /// <summary>
        /// 操作
        /// </summary>
        protected void Operate()
        {
            string s_Act = Request.QueryString["action"];
            if (s_Act == "del")
            {
                string s_ID = Request.QueryString["id"];
                if (s_ID == null || s_ID == "")
                {
                    PageError("参数传递错误!", "sysnotepad.aspx");
                }
                JuSNS.Home.SysNotepad notepad = new JuSNS.Home.SysNotepad();
                if (notepad.Del(Convert.ToInt32(s_ID)) == 1)
                    Response.Redirect("gbook.aspx");
                else
                    PageError("删除留言失败!", "gbook.aspx");
            }
        }
    }
}
