Web/Admin/News/channel.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Data;
using Bocent.BLL;

namespace Bocent.Web.Admin.News
{
    public partial class channel : AspxBase
    {
        protected override void process()
        {
            DataSet ds = TAB.Select("news_channel");
            var pddt = DICT.GetArray("Channel");
            ds.Tables[0].Columns.Add("TypeName", System.Type.GetType("System.String"));
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                ds.Tables[0].Rows[i].BeginEdit();
                if (pddt != null && pddt.ContainsKey(ds.Tables[0].Rows[i]["ChannelType"].ToString()))
                {
                    ds.Tables[0].Rows[i]["TypeName"] = pddt[ds.Tables[0].Rows[i]["ChannelType"].ToString()];
                }
                ds.Tables[0].Rows[i].EndEdit();
            }

            ListJdlb.DataSource = tree(0, 0, ds).DefaultView;
        }

        private DataTable tree(int parentid = 0, int depth = 0, DataSet ds = null)
        {
            if (ds == null) { ds = TAB.Select("news_channel"); }
            DataView dv = ds.Tables[0].DefaultView;
            dv.RowFilter = string.Format("(ParentID = {0})", parentid);
            dv.Sort = "OrderNo";
            DataTable dt = dv.ToTable(string.Format("channel_tree_{0}", depth));
            dt.Columns.Add("Depth", System.Type.GetType("System.Int32"));
            dt.Columns.Add("TreeIco", System.Type.GetType("System.String"));
            DataTable nodedt = new DataTable();
            nodedt = dt.Clone();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                #region 计算子节点
                string sqlstr = string.Format("(ParentID = {0})", (int)dt.Rows[i]["ChannelID"]);
                DataView datav = ds.Tables[0].DefaultView;
                int subcount = ((int)datav.Table.Compute("COUNT(ChannelID)", sqlstr));
                #endregion

                dt.Rows[i].BeginEdit();
                dt.Rows[i]["Depth"] = depth;
                dt.Rows[i]["TreeIco"] = treetag.get_tree_ico(subcount, depth, (i == (dt.Rows.Count - 1)));
                dt.Rows[i].EndEdit();
                nodedt.Rows.Add(dt.Rows[i].ItemArray);
                if (subcount > 0)
                {
                    DataTable subdt = tree((int)dt.Rows[i]["ChannelID"], depth + 1, ds);
                    for (int k = 0; k < subdt.Rows.Count; k++)
                    {
                        nodedt.Rows.Add(subdt.Rows[k].ItemArray);
                    }
                }
            }
            dt.Clear();
            return nodedt;
后面还有 3 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。