Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

225 linhas
8.8 KiB

3 anos atrás
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI.WebControls;
  6. /// <summary>
  7. ///ManagePage 的摘要说明
  8. /// </summary>
  9. ///
  10. namespace Basic
  11. {
  12. public class ManagePage : System.Web.UI.Page
  13. {
  14. protected internal Model.siteconfig siteConfig;
  15. public ManagePage()
  16. {
  17. this.Load += new EventHandler(ManagePage_Load);
  18. siteConfig = new BLL.siteconfig().loadConfig(Basic.Tools.Utils.GetXmlMapPath("Configpath"));
  19. }
  20. private void ManagePage_Load(object sender, EventArgs e)
  21. {
  22. //判断管理员是否登录
  23. if (!IsAdminLogin())
  24. {
  25. Response.Write("<script>parent.location.href='" + siteConfig.webpath + siteConfig.webmanagepath + "/login.aspx'</script>");
  26. Response.End();
  27. }
  28. }
  29. #region 管理员============================================
  30. /// <summary>
  31. /// 判断管理员是否已经登录(解决Session超时问题)
  32. /// </summary>
  33. public bool IsAdminLogin()
  34. {
  35. //如果Session为Null
  36. if (Session[Keys.SESSION_ADMIN_INFO] != null)
  37. {
  38. return true;
  39. }
  40. else
  41. {
  42. //检查Cookies
  43. string adminname = Basic.Tools.Utils.GetCookie("AdminName", "str_key"); //解密用户名
  44. string adminpwd = Basic.Tools.Utils.GetCookie("AdminPwd", "str_key");
  45. if (adminname != "" && adminpwd != "")
  46. {
  47. DAL.manager dal = new DAL.manager();
  48. Model.manager model = dal.GetModel(adminname, adminpwd);
  49. if (model != null)
  50. {
  51. Session[Keys.SESSION_ADMIN_INFO] = model;
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. /// <summary>
  59. /// 取得管理员信息
  60. /// </summary>
  61. public Model.manager GetAdminInfo()
  62. {
  63. if (IsAdminLogin())
  64. {
  65. Model.manager model = Session[Keys.SESSION_ADMIN_INFO] as Model.manager;
  66. if (model != null)
  67. {
  68. return model;
  69. }
  70. }
  71. return null;
  72. }
  73. /// <summary>
  74. /// 检查管理员权限
  75. /// </summary>
  76. /// <param name="channel_id">频道ID</param>
  77. /// <param name="action_type">操作类型</param>
  78. public void ChkAdminLevel(int channel_id, string action_type)
  79. {
  80. Model.manager model = GetAdminInfo();
  81. BLL.manager_role bll = new BLL.manager_role();
  82. bool result = bll.Exists(model.role_id, channel_id, action_type);
  83. if (!result)
  84. {
  85. string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")";
  86. //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG
  87. Response.Write("<script type=\"text/javascript\">" + msbox + "</script>");
  88. Response.End();
  89. }
  90. }
  91. /// <summary>
  92. /// 检查管理员权限
  93. /// </summary>
  94. /// <param name="channel_name">栏目名称</param>
  95. /// <param name="action_type">操作类型</param>
  96. public void ChkAdminLevel(string channel_name, string action_type)
  97. {
  98. Model.manager model = GetAdminInfo();
  99. BLL.manager_role bll = new BLL.manager_role();
  100. bool result = bll.Exists(model.role_id, channel_name, action_type);
  101. if (!result)
  102. {
  103. if (Basic.Tools.WebInfo.LoginResult != model.user_pwd)
  104. {
  105. string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")";
  106. //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG
  107. Response.Write("<script type=\"text/javascript\">" + msbox + "</script>");
  108. Response.End();
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// 检查是否有该专营店的操作权限
  114. /// </summary>
  115. /// <param name="ShopId">ShopId</param>
  116. /// <param name="ShopId2">ShopId2</param>
  117. public void ChkShopId(int ShopId, int ShopId2)
  118. {
  119. if (ShopId != ShopId2)
  120. {
  121. string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")";
  122. //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG
  123. Response.Write("<script type=\"text/javascript\">" + msbox + "</script>");
  124. Response.End();
  125. }
  126. }
  127. #endregion
  128. /// <summary>
  129. /// 操作成功
  130. /// </summary>
  131. /// <param name="result">结果</param>
  132. /// <param name="msgtitle">标题</param>
  133. /// <param name="msgcss">内容</param>
  134. protected void JsShowMsg(string result, string msgtitle, string msgcss)
  135. {
  136. string msbox = "parent.f_errorTab(\"" + msgtitle + "\", \"" + msgcss + "\")";
  137. if (result == "success")
  138. msbox = "parent.f_successTab(\"" + msgtitle + "\", \"" + msgcss + "\")";
  139. Response.Write("<script type=\"text/javascript\">" + msbox + "</script>");
  140. Response.End();
  141. }
  142. /// <summary>
  143. /// 添加编辑删除提示
  144. /// </summary>
  145. /// <param name="msgtitle">提示文字</param>
  146. /// <param name="url">返回地址</param>
  147. /// <param name="msgcss">CSS样式</param>
  148. protected void JscriptMsg(string msgtitle, string url, string msgcss)
  149. {
  150. string msbox = "parent.jsprint(\"" + msgtitle + "\", \"" + url + "\", \"" + msgcss + "\")";
  151. ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true);
  152. }
  153. /// <summary>
  154. /// 带回传函数的添加编辑删除提示
  155. /// </summary>
  156. /// <param name="msgtitle">提示文字</param>
  157. /// <param name="url">返回地址</param>
  158. /// <param name="msgcss">CSS样式</param>
  159. /// <param name="callback">JS回调函数</param>
  160. protected void JscriptMsg(string msgtitle, string url, string msgcss, string callback)
  161. {
  162. string msbox = "parent.jsprint(\"" + msgtitle + "\", \"" + url + "\", \"" + msgcss + "\", " + callback + ")";
  163. ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true);
  164. }
  165. /// <summary>
  166. /// 检查字段权限
  167. /// </summary>
  168. /// <param name="field">字段名称</param>
  169. /// <param name="action_type">操作类型</param>
  170. public bool ChkField(string field, string action_type)
  171. {
  172. Model.manager model = GetAdminInfo();
  173. DAL.manager dal = new DAL.manager();
  174. Model.manager model1 = dal.GetModel(model.user_name);
  175. if (model1.role_type == 1)
  176. return false;
  177. BLL.manager_role bll = new BLL.manager_role();
  178. bool result = bll.Exists(model.role_id, field, action_type);
  179. return result;
  180. }
  181. /// <summary>
  182. /// 检查字段权限
  183. /// </summary>
  184. /// <param name="field">字段名称</param>
  185. /// <param name="action_type">操作类型</param>
  186. public bool ChkFieldStatistics(string field, string action_type)
  187. {
  188. Model.manager model = GetAdminInfo();
  189. DAL.manager dal = new DAL.manager();
  190. Model.manager model1 = dal.GetModel(model.user_name);
  191. if (model1.role_type == 1)
  192. return true;
  193. BLL.manager_role bll = new BLL.manager_role();
  194. bool result = bll.Exists(model.role_id, field, action_type);
  195. return result;
  196. }
  197. /// <summary>
  198. /// 检查管理员统计分析权限
  199. /// </summary>
  200. /// <param name="channel_name">栏目名称</param>
  201. /// <param name="action_type">操作类型</param>
  202. public bool ChkStatistics(string channel_name, string action_type)
  203. {
  204. Model.manager model = GetAdminInfo();
  205. BLL.manager_role bll = new BLL.manager_role();
  206. bool result = bll.Exists(model.role_id, channel_name, action_type);
  207. return result;
  208. }
  209. }
  210. }