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;

public partial class admin_htm_temp_default : Fm.Bussiness.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Fm.Bussiness.Xml_work xml = new Fm.Bussiness.Xml_work();
            //读取XML文件
            DataTable dt = xml.Xml_Reader(Server.MapPath("../") + "config/templates.xml", "templates");
            foreach (DataRow row in dt.Rows)
            {
                txtindex.Text = row["index"].ToString();
                txtdefault.Text = row["default"].ToString();
                txtlist.Text = row["list"].ToString();
                txtarticle.Text = row["article"].ToString();
                txtsearch.Text = row["search"].ToString();
            }
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Fm.Bussiness.Xml_work xml = new Fm.Bussiness.Xml_work();
        //路径
        string path = Server.MapPath("../") + "config/templates.xml";
        //获取XML文件信息
        DataTable dt = xml.Table_Create(path,"templates");
        //创建新行
        DataRow row = dt.NewRow();
        //把模板记录保存
        row["index"] = txtindex.Text;
        row["default"] = txtdefault.Text;
        row["list"] = txtlist.Text;
        row["article"] = txtarticle.Text;
        row["search"] = txtsearch.Text;
        //把ROW添加到DT中
        dt.Rows.Add(row);
        //调用XML更新方法
        xml.Xml_Update(path,"templates",dt);
        Response.Redirect("Erro.aspx?eid=默认模板设置成功!&url=htm_temp_default.aspx", true);
    }
}
