|
√ Google adsense申请技巧 √ 本站核心代理域名注册主机业务
√ 快速发布你的买卖域名买卖网站信息
√ 1元注册 cn域名
√ 站长每日新闻导读 √ ·推荐万网空间¥120元 150m √ 站长网:站长必上的网站 √ 网站联盟大全 √ 本站代理万网域名55空间120元 |
/*menulist 类开始*/
using System;
using System.Data;
using System.Configuration;
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;
using Singcn.SQL;
using System.Data.SqlClient;
using System.IO;
using System.Text;
namespace myfunc.Common
{
/// <summary>
/// PubFunc 的摘要说明
/// </summary>
public class menulist
{
public XmlWriterSettings settings = new XmlWriterSettings();
public XmlWriter writer = null;
public string buf = "";
public SqlShell objShell;
public SqlCommand objCommand;
public DataTable objDataTable;
public menulist(string userid)
{
objShell = new SqlShell();
objCommand = new SqlCommand("select * from qxdmb order by jb,px,qxdm");
objCommand.CommandType = CommandType.Text;
objDataTable = objShell.executeDataSet(ref objCommand).Tables[0];
StringWriter writerstr = new StringWriter();
settings.Indent = true;
settings.Encoding = Encoding.GetEncoding("utf-8");
try
{
writer = XmlWriter.Create(writerstr, settings);
writer.WriteStartDocument();
writer.WriteStartElement("DSTreeRoot");
writer.WriteAttributeString("text", "后台管理系统-["+userid+"]");
writer.WriteAttributeString("treeId", "0000");
writer.WriteAttributeString("open", "true");
readqxdmb("0");
writer.WriteEndElement();
writer.WriteEndDocument();
}
finally
{
if (writer != null)
writer.Close();
}
buf = writerstr.ToString();
buf = buf.Replace(@"encoding=""utf-16""", @"encoding=""utf-8""");//在使用StringWriter 作为xml输出时XML自动为“utf-16”,此处用Replace方法处理,如有更好的方法请指教!
}
private void readqxdmb(string sjdm)//生成XML树的方法
{
DataTable mytable = objDataTable.Copy();
DataRow[] foundRows;
foundRows = mytable.Select("sjdm='" + sjdm + "'");
if (foundRows.Length > 0)
{
//写子节点
for (int i = 0; i < foundRows.Length; i++)
{
writer.WriteStartElement("DSTree");
writer.WriteAttributeString("text", foundRows[i]["qxsm"].ToString().Trim());
writer.WriteAttributeString("treeId", foundRows[i]["qxdm"].ToString().Trim());
writer.WriteAttributeString("open", "false");
//处理下级节点
readqxdmb((string)foundRows[i]["qxdm"]);
writer.WriteEndElement();
}
}
mytable.Dispose();
}
}
}
/*menulist 结束*/