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;

namespace JuSNS.Web.Inc.Ajax
{
    public partial class DisCussInfoEdit : JuSNS.UI.Page.UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "no-cache";
            StartOp();
        }

        /// <summary>
        /// 开始删除
        /// </summary>
        /// <returns></returns>
        protected void StartOp()
        {
            string s_Act = Request.QueryString["Action"];
            string s_ID = Request.QueryString["DisID"];
            string s_Content = Request.QueryString["Content"];
            int ID = Convert.ToInt32(s_ID);
            string s_Temp = "";
            JuSNS.Home.Group discuss = new JuSNS.Home.Group();
            JuSNS.Model.GroupDiscussInfo discussinfo = new JuSNS.Model.GroupDiscussInfo();
            switch (s_Act)
            {
                case "getContent":
                    discussinfo = discuss.Info(ID);
                    s_Temp = "<div>" +
                             "<textarea id=\"Content" + ID.ToString() + "\" rows=\"6\" cols=\"55\" class=\"f-text\" maxlength=\"4000\">" + JuSNS.Common.Input.HtmlDecode(discussinfo.Content) + "</textarea><div class=\"act\"><input type=\"button\" value=\"编辑\" class=\"f-button\" onclick='javascript:SaveEditDis(" + ID.ToString() + ")'>&nbsp;<input type=\"button\" class=\"f-reset\" value=\"取消\"  onclick='HideDis(" + ID.ToString() + ");' /><span id=\"spanerr\"></span></div></div>";
                    Response.Write(s_Temp);
                    Response.End();
                    break;
                case "SaveContent":
                    discuss.Edit(JuSNS.Common.Input.HtmlEncode(s_Content), UserID, ID);
                    discussinfo = discuss.Info(ID);
                    s_Temp = "<div>" + JuSNS.Common.Input.Htmls(s_Content) + "</div><div class=\"time\">最后编辑于 " + JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(discussinfo.LastModifyTime)) + "</div>";
                    Response.Write(s_Temp);
                    Response.End();
                    break;
                case "getReplyContent":
                    discussinfo = discuss.Info(ID);
                    s_Temp = JuSNS.Common.Input.Htmls(JuSNS.Common.Input.HtmlDecode(discussinfo.Content));
                    Response.Write(s_Temp);
                    Response.End();
                    break;
            }
        }

        /// <summary>
        /// 取得回复附加内容
        /// </summary>
        /// <param name="ReplyTack"></param>
        protected string getReplay(string ReplyTack)
        {
            string s_ReplyTack = string.Empty;
            if (ReplyTack != null)
                s_ReplyTack = "<p class=\"tip\">" + ReplyTack.ToString() + "</p>";
            return s_ReplyTack;
        }
    }
}
