MainPage.aspx.cs.exclude 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using BizCom;
  2. using SiteCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using Utils;
  12. public partial class MainPage : BasePage
  13. {
  14. DataView dv = null;
  15. DataView sDv = null;
  16. DataTable resources = null;
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. if (!CheckRights()) return;
  20. resources = WebUser.GetPermission(Session["xyUserID"]);
  21. if (resources == null || resources.Rows.Count < 1)
  22. {
  23. ShowError("您的账户暂时还没有分配权限,无法使用系统!");
  24. return;
  25. }
  26. //litTitle.Text = "";
  27. StringBuilder userStr = new StringBuilder();
  28. userStr.AppendFormat("<span>账号:<em >{0}</em></span>", Session["xyUserName"]);
  29. //if (CurrentUser.User.PreLoginTime != null)
  30. //{
  31. // userStr.AppendFormat("<span>上次登录:<em >{0}</em></span>", Convert.ToDateTime(CurrentUser.User.PreLoginTime).ToString("yy年M月d日 HH:mm"));
  32. //}
  33. //else
  34. //{
  35. // userStr.Append("<span>上一次登录时间:<em >无</em></span>");
  36. //}
  37. //userStr.AppendFormat("<span>登录IP:<em>{0}</em></span>",CurrentUser.User.LoginIP);
  38. litUser.Text = userStr.ToString();
  39. if(Session["xyUserName"].ToString()== "zc_admin")
  40. {
  41. litTitle.Text = "家具资产管理维保云平台";
  42. }
  43. else
  44. {
  45. litTitle.Text = "后台管理平台";
  46. }
  47. //litTitle.Text = SiteName;
  48. //this.Title = litTitle.Text + "砼生产管理系统";
  49. dv = new DataView(resources);
  50. sDv = new DataView(resources);
  51. StringBuilder str = new StringBuilder();
  52. getTreeMenu("0", 0, ref str);
  53. litScript.Text = "<script type=\"text/javascript\">menuData=[" + str.ToString() + "];</script>";
  54. //litMenu.Text = str.ToString();
  55. }
  56. int j = 0;
  57. private void getTreeMenu(string pId, int idx, ref StringBuilder str)
  58. {
  59. dv.RowFilter = "ParentID=" + pId + " and isoperate=0";
  60. foreach (DataRowView drv in dv)
  61. {
  62. //if (drv["Tag"].ToString() == "index")
  63. //{
  64. // getIndexMenu(drv["ID"]);
  65. // continue;
  66. //}
  67. sDv.RowFilter = "ParentID=" + drv["ID"] + " and isoperate=0";//判断有没有子节点
  68. if (sDv.Count > 0)
  69. {
  70. if (j == 0) j++;
  71. else str.Append(",");
  72. if (pId == "0")
  73. {
  74. str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",iconCls: \"icon-{2}\"", drv["ID"], drv["Name"], drv["Icon"]).Append("}");
  75. }
  76. else
  77. {
  78. str.Append("{").AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",iconCls: \"icon-{3}\",\"iconPosition\": \"top\"", drv["ID"], drv["Name"], pId, drv["Icon"]).Append("}");
  79. }
  80. getTreeMenu(drv["ID"].ToString(), idx + 1, ref str);
  81. }
  82. else
  83. {
  84. if (idx > 1)
  85. {
  86. if (j == 0) j++;
  87. else str.Append(",");
  88. str.Append("{");
  89. str.AppendFormat("\"id\":\"{0}\",\"text\":\"{1}\",\"pid\":\"{2}\",\"url\":\"{3}\"", drv["ID"], drv["Name"], pId, drv["Url"]).Append("}");
  90. }
  91. else
  92. {
  93. if (j == 0) j++;
  94. else str.Append(",");
  95. str.Append("{");
  96. 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("}");
  97. }
  98. //else
  99. //{
  100. // str.Append(",{").AppendFormat("\"text\":\"<li class='mini-separator' style='height:1px;'></li>\",\"pid\":\"{1}\"", drv["ID"], pId).Append("}");
  101. //}
  102. }
  103. }
  104. }
  105. //private void getIndexMenu(object pId)
  106. //{
  107. // StringBuilder str = new StringBuilder();
  108. // DataView indexDv = new DataView(resources);
  109. // indexDv.RowFilter = "ParentID=" + pId + " and isoperate=0";
  110. // foreach (DataRowView drv in indexDv)
  111. // {
  112. // string tag = drv["Tag"].ToString();
  113. // str.AppendFormat("<a class=\"mini-button mini-button-iconTop\" iconCls=\"icon-{1}\" onclick=\"open_{1}()\" plain=\"true\" >{0}</a>", drv["Name"], tag.Replace("view", ""));
  114. // }
  115. // if (str.Length > 0)
  116. // litIndexMenu.Text = str.ToString();
  117. //}
  118. }