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 System.Text;

using TopWinCMS.BLL;
using TopWinCMS.Model;
namespace TopWinCMS.WebUI.Member
{
    public partial class Message_Send : TopWinCMS.BLL.PageFactory.Pages.ClientPublicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Title = Config.SiteName + "→ 会员中心 → 短信管理 → 发送短信";

                if (Request["Action"] == "Reply")
                {
                    DataLoad();
                }
                else if (Request["Action"] == "Read")
                {
                    MessageInfo model = new MessageManage().EditLoad(Request["GUID"]);
                    TB_Incept.Text = model.Incept;
                    TB_Title.Text = model.Title;
                    CE_Content.Text = model.Content;

                    CheckRow.InnerText = "";
                    PassCodeRow.Visible = false;
                }
            }
        }

        private void DataLoad()
        {
            MessageInfo model = new MessageManage().EditLoad(Request["GUID"]);
            TB_Incept.Text = model.Sender;//因为是回复，所以是颠倒的。
            TB_Title.Text = "回复:" + model.Title;
            StringBuilder winner = new StringBuilder();

            winner.Append("Re:[ " + model.Incept + " ]<br>");
            winner.Append("<table width=\"90%\"  border=\"0\" cellpadding=\"9\" cellspacing=\"0\" bgcolor=\"#DDDDDD\">");
            winner.Append("<tr>");
            winner.Append("<td>" + model.Content + "</td>");
            winner.Append("</tr>");
            winner.Append("</table><div></div><div></div><br>");

            CE_Content.Text = winner.ToString();
        }

        protected void BT_Send_Click(object sender, EventArgs e)
        {

            MessageInfo model = new MessageInfo();
            model.GUID = Guid.NewGuid().ToString();
            model.Sender = MemberLoginInfo.UserName;
            model.Incept = TB_Incept.Text;
            model.Title = TB_Title.Text;
            model.PassCode = TB_PassCode.Text;
            model.Content = CE_Content.Text;

            new MessageManage().Add(model);
        }
    }
}