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;

namespace JuSNS.Web.system.sys
{
    public partial class gbookedit : JuSNS.UI.Page.ManagePage
    {
        protected string sort = "sys";
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "no-cache";
            if (!Page.IsPostBack)
                getInfo();
        }
        /// <summary>
        /// 加载页面初始信息
        /// </summary>
        protected void getInfo()
        {
            string s_ID = Request.QueryString["id"];
            if (string.IsNullOrEmpty(s_ID))
                PageError("参数传递错误!", "sysnotepad.aspx");


            JuSNS.Home.SysNotepad sysnotepad = new JuSNS.Home.SysNotepad();
            JuSNS.Model.SysNotepadInfo sysnotepadinfo = new JuSNS.Model.SysNotepadInfo();
            sysnotepadinfo = sysnotepad.Info(Convert.ToInt32(s_ID));
            this.Content.InnerHtml = Input.HtmlEncode(sysnotepadinfo.Content);
            PostTime.InnerHtml = sysnotepadinfo.PostTime.ToString();

            SendID.Value = sysnotepadinfo.SendID.ToString();
            HidID.Value = s_ID;
        }

        /// <summary>
        /// 执行回复过程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                JuSNS.Home.SysNotepad sysnotepad = new JuSNS.Home.SysNotepad();
                JuSNS.Model.SysNotepadInfo sysnotepadinfo = new JuSNS.Model.SysNotepadInfo();

                sysnotepadinfo.ParentID = 0;
                sysnotepadinfo.SendID = -1;
                sysnotepadinfo.PostTime = DateTime.Now;
                sysnotepadinfo.PostIP = JuSNS.Common.Public.GetClientIP();
                sysnotepadinfo.Content = this.ReplyContent.Text;
                sysnotepadinfo.RecID = Convert.ToInt32(this.SendID.Value);

                if (sysnotepad.Reply(sysnotepadinfo) == 1)
                    Response.Redirect("gbook.aspx");
                else
                    PageError("回复失败!", "sysnotepad.aspx");
            }
        }
    }
}
