| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using BizCom;
- using SiteCore;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using Utils;
- public partial class MainPage : BasePage
- {
- DataView dv = null;
- DataView sDv = null;
- DataTable resources = null;
- protected void Page_Load(object sender, EventArgs e)
- {
-
- if (!CheckRights()) return;
- resources = WebUser.GetPermission(Session["xyUserID"]);
- if (resources == null || resources.Rows.Count < 1)
- {
- ShowError("您的账户暂时还没有分配权限,无法使用系统!");
- return;
- }
- //litTitle.Text = "";
- StringBuilder userStr = new StringBuilder();
- userStr.AppendFormat("<span>账号:<em >{0}</em></span>", Session["xyUserName"]);
- //if (CurrentUser.User.PreLoginTime != null)
- //{
- // userStr.AppendFormat("<span>上次登录:<em >{0}</em></span>", Convert.ToDateTime(CurrentUser.User.PreLoginTime).ToString("yy年M月d日 HH:mm"));
- //}
- //else
- //{
- // userStr.Append("<span>上一次登录时间:<em >无</em></span>");
- //}
- //userStr.AppendFormat("<span>登录IP:<em>{0}</em></span>",CurrentUser.User.LoginIP);
- litUser.Text = userStr.ToString();
- if(Session["xyUserName"].ToString()== "zc_admin")
- {
- litTitle.Text = "家具资产管理维保云平台";
- }
- else
- {
- litTitle.Text = "后台管理平台";
- }
- //litTitle.Text = SiteName;
- //this.Title = litTitle.Text + "砼生产管理系统";
- dv = new DataView(resources);
- sDv = new DataView(resources);
- StringBuilder str = new StringBuilder();
- getTreeMenu("0", 0, ref str);
- litScript.Text = "<script type=\"text/javascript\">menuData=[" + str.ToString() + "];</script>";
- //litMenu.Text = str.ToString();
- }
- int j = 0;
- private void getTreeMenu(string pId, int idx, ref StringBuilder str)
- {
- dv.RowFilter = "ParentID=" + pId + " and isoperate=0";
- foreach (DataRowView drv in dv)
- {
- //if (drv["Tag"].ToString() == "index")
- //{
- // getIndexMenu(drv["ID"]);
- // continue;
- //}
- sDv.RowFilter = "ParentID=" + drv["ID"] + " and isoperate=0";//判断有没有子节点
- if (sDv.Count > 0)
- {
- if (j == 0) j++;
- else str.Append(",");
- if (pId == "0")
- {
- str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",iconCls: \"icon-{2}\"", drv["ID"], drv["Name"], drv["Icon"]).Append("}");
- }
- else
- {
- str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",iconCls: \"icon-{3}\",\"iconPosition\": \"top\"", drv["ID"], drv["Name"], pId, drv["Icon"]).Append("}");
- }
- getTreeMenu(drv["ID"].ToString(), idx + 1, ref str);
- }
- else
- {
- if (idx > 1)
- {
- if (j == 0) j++;
- else str.Append(",");
- str.Append("{");
- str.AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",\"url\":\"{3}\"", drv["ID"], drv["Name"], pId, drv["Url"]).Append("}");
- }
- else
- {
- if (j == 0) j++;
- else str.Append(",");
- str.Append("{");
- str.AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",\"url\":\"{3}\",iconCls: \"icon-{4}\",\"iconPosition\": \"top\"", drv["ID"], drv["Name"], pId, drv["Url"], (drv["Icon"].ToString() == "" ? drv["Tag"] : drv["Icon"]), drv["Icon"]).Append("}");
- }
- //else
- //{
- // str.Append(",{").AppendFormat("\"text\":\"<li class='mini-separator' style='height:1px;'></li>\",\"pid\":\"{1}\"", drv["ID"], pId).Append("}");
- //}
- }
- }
- }
- //private void getIndexMenu(object pId)
- //{
- // StringBuilder str = new StringBuilder();
- // DataView indexDv = new DataView(resources);
- // indexDv.RowFilter = "ParentID=" + pId + " and isoperate=0";
- // foreach (DataRowView drv in indexDv)
- // {
- // string tag = drv["Tag"].ToString();
- // str.AppendFormat("<a class=\"mini-button mini-button-iconTop\" iconCls=\"icon-{1}\" onclick=\"open_{1}()\" plain=\"true\" >{0}</a>", drv["Name"], tag.Replace("view", ""));
- // }
- // if (str.Length > 0)
- // litIndexMenu.Text = str.ToString();
- //}
- }
|