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.Xml;


namespace JuSNS.Web.system.sys
{
    public partial class Email : JuSNS.UI.Page.ManagePage
    {
        protected string sort = "sys";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.txtContent.Value = JuSNS.Config.emailsetConfig.letter;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string configpath = "~/config/email/emailset.config";
            string filepath = HttpContext.Current.Server.MapPath(configpath);

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filepath);//你的xml文件
            XmlNodeList xmlList = xmlDoc.SelectSingleNode("emailset").ChildNodes;
            foreach (XmlNode xmlNo in xmlList)
            {
                if (xmlNo.NodeType != XmlNodeType.Comment)
                {
                    XmlElement xe = (XmlElement)xmlNo;
                    {
                        if (xe.Name == "letter")
                        {
                            xe.RemoveAll();
                            XmlNode newNode;
                            newNode = xmlDoc.CreateNode("cdatasection", "letter", "");//创建节点
                            newNode.InnerText = this.txtContent.Value;//给节点赋值
                            xe.AppendChild(newNode);//把节点添加到doc

                            xmlDoc.Save(filepath);
                            JuSNS.Config.emailsetConfig.Reload();
                            Response.Redirect("email.aspx");
                            return;
                        }
                    }
                }
            }
        }
    }
}
