using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Text; using DSWeb.Models; using DSWeb.EntityDA; using DSWeb.Filter; namespace DSWeb.CRM { public partial class CRMClientEdit : System.Web.UI.Page { StringBuilder leftNav = new StringBuilder(); StringBuilder leftTree = new StringBuilder(); StringBuilder tmpLeftTree = new StringBuilder(); private string strHandleType; private string strGID; private string hdEnabled; protected void Page_Load(object sender, EventArgs e) { HttpRequest request = Page.Request; LeftTreeCssFilter myFilter = new LeftTreeCssFilter(request); if (Request.QueryString["handle"] != null) { strHandleType = Request.QueryString["handle"].Trim().ToString().ToLower(); if (Request.QueryString["id"] != null) { strGID = Request.QueryString["id"].ToString().Trim(); } if (Request.QueryString["isenabled"] != null)//if (Request.QueryString["id"] != null) { hdEnabled = Request.QueryString["isenabled"].ToString(); } } DoGet(); } /// /// 只显示用户设置 /// /// /// private List ActionFilter(List moduleEntites) { List ActionFilter = new List(); foreach (ModuleEntity moduleEntity in moduleEntites) { if (moduleEntity.Gid == "e6fc61b1-13c1-4995-921b-7bad0aa0133c") { ActionFilter.Add(moduleEntity); } } return ActionFilter; } public void DoGet() { ModuleDA moduleDA = new ModuleDA(); List moduleEntites = ActionFilter(moduleDA.GetModuleByType(ModuleDA.ModuleType.SEAEXPORT)); StringBuilder htmlBuilder = new StringBuilder(); LeftTreeCssFilter cssFilter = new LeftTreeCssFilter(Page.Request); string strBVersion = cssFilter.Version.Trim(); string strBName = cssFilter.BrowserName.ToLower().Trim(); htmlBuilder.Append(""); htmlBuilder.Append("Manager"); //根据不同的浏览器加载不同的css样式 if (strBVersion.Equals("6.0") && strBName.Equals("ie")) { htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); } else { htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); } htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); //htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("
"); htmlBuilder.Append("");// //htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("
");// align=\"center\" //htmlBuilder.Append("
"); //htmlBuilder.Append("
");//
添加费用更改单
htmlBuilder.Append("
"); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append(""); htmlBuilder.Append("
"); htmlBuilder.Append(""); htmlBuilder.Append("
 "); htmlBuilder.Append("
"); htmlBuilder.Append("[退出]    
    "); htmlBuilder.Append("
      "); htmlBuilder.Append("
    • "); htmlBuilder.Append("
    "); htmlBuilder.Append("
      "); string strValue = GetTreeView(moduleEntites); htmlBuilder.Append(leftNav.ToString()); htmlBuilder.Append("
    "); htmlBuilder.Append(strValue); if (strHandleType != null) { if (strHandleType.Equals("edit") && !strGID.Equals("")) { htmlBuilder.Append(""); } else { htmlBuilder.Append(""); } } else { Response.End(); } Response.Clear(); Response.Write(htmlBuilder.ToString()); } /// /// 获取左侧展开树内容 /// /// 实体类ModuleEntity /// public String GetTreeView(List tempEntities) { //StringBuilder leftNav = new StringBuilder(); StringBuilder leftTree = new StringBuilder(); StringBuilder tmpLeftTree = new StringBuilder(); //树型菜单第一级菜单 StringBuilder leftTreeData = new StringBuilder(); StringBuilder treesJS = new StringBuilder(); foreach (ModuleEntity mdel in tempEntities) { leftNav.Append("
  • "); leftNav.Append(" "); leftNav.Append(mdel.ModuleDescription); leftNav.Append("
  • "); tmpLeftTree = new StringBuilder();// class=\"TreeMenu\" tmpLeftTree.Append("
    "); tmpLeftTree.Append("
    "); leftTreeData.Append(LeftTreeNodeData(mdel)); leftTree.Append(tmpLeftTree.ToString()); } return leftTreeData.ToString(); } public String ConvertToJS(JSTreeNodeEntity tempJSTreeEntity) { StringBuilder nodeJS = new StringBuilder(); nodeJS.Append("{"); nodeJS.Append("\"id\":\"root" + tempJSTreeEntity.Gid + "\""); nodeJS.Append(","); nodeJS.Append("\"text\":\"" + tempJSTreeEntity.Text + "\""); nodeJS.Append(","); nodeJS.Append("\"value\":\"" + tempJSTreeEntity.Value + "\""); nodeJS.Append(","); nodeJS.Append("\"showcheck\":" + (tempJSTreeEntity.SetShowCheck ? 1 : 0).ToString() + ""); nodeJS.Append(","); nodeJS.Append("\"complete\":1"); nodeJS.Append(","); nodeJS.Append("\"isexpand\":1"); nodeJS.Append(","); nodeJS.Append("\"checkstate\":" + tempJSTreeEntity.CheckState + ""); nodeJS.Append(","); nodeJS.Append("\"hasChildren\":" + (tempJSTreeEntity.SetHasChild ? 1 : 0).ToString() + ""); nodeJS.Append(","); string classes = tempJSTreeEntity.SetClasses; if (classes != null && !classes.Equals("")) { int ilen = classes.IndexOf('.'); classes = classes.Substring(0, ilen); if (classes.Length > 1) { nodeJS.Append("\"classes\":\"" + classes + "\""); nodeJS.Append(","); } } nodeJS.Append("\"ChildNodes\":\"null\""); nodeJS.Append("}"); return nodeJS.ToString(); } /// /// 遍历模块查看此模块是否为父模块 /// /// /// /// public bool IsParent(List tempEntities, string strGID) { bool IsExist = false; foreach (ModuleEntity mdle in tempEntities) { if (mdle.ParentID.Trim().Equals(strGID)) { IsExist = true; } } return IsExist; } public String LeftTreeNodeData(ModuleEntity tempEntity) { StringBuilder appTreeData = new StringBuilder(); StringBuilder childerData = new StringBuilder(); ModuleDA moduleDA = new ModuleDA(); //List subModule = moduleDA.GetSubModule(tempEntity.Gid); //List tempEntities = moduleDA.GetAllUserBaseSubModules(); List subModule = moduleDA.GetSubModule(tempEntity.Gid); List tempEntities = moduleDA.GetAllSubModules(); appTreeData.Append(""); return appTreeData.ToString(); } /// /// 返回 /// /// /// /// public String GetSubJs(string parentGid, List tempEntities, string tempJSON) { StringBuilder valBuilder = new StringBuilder(); StringBuilder childBuilder = new StringBuilder(); foreach (ModuleEntity mdle in tempEntities) { if (parentGid.Trim().Equals(mdle.ParentID)) { bool isParentNode = IsParent(tempEntities, mdle.Gid); string strTempNode = GetNodeJs(mdle, isParentNode); string strTempValue = ""; if (isParentNode) { strTempValue = GetSubJs(mdle.Gid, tempEntities, strTempNode); childBuilder.Append(strTempValue); } if (strTempValue.Trim().Equals("")) { childBuilder.Append(strTempNode); } } } if (childBuilder.Length > 1) { string strChilds = childBuilder.ToString(); strChilds = strChilds.Substring(0, strChilds.Length - 1);//去除末尾逗号 if (!tempJSON.Equals("")) { tempJSON = tempJSON.Replace("\"null\"", "[" + strChilds + "]"); valBuilder.Append(tempJSON); } else { valBuilder.Append(strChilds); } } return valBuilder.ToString(); } #region 获取节点JSON值 /// /// 获取节点JSON值 /// /// /// /// public String GetNodeJs(ModuleEntity tempEntity, bool hasChild) { StringBuilder tempNodeBuilder = new StringBuilder(); JSTreeNodeEntity modelData = new JSTreeNodeEntity(); modelData.Gid = tempEntity.Gid.Replace("-", ""); modelData.Text = tempEntity.ModuleDescription; modelData.SetShowCheck = false; modelData.CheckState = 0; modelData.IsExpand = false; modelData.SetClasses = tempEntity.ModuleIcon; String tmpUrl = tempEntity.ModuleUrl.Trim(); //如果数据库模板表Module字段Url设置为"#"则不提供链接 if (!tmpUrl.Equals("#")) { tmpUrl = "../" + tmpUrl; modelData.Value = "CreateTab('" + tempEntity.ModuleDescription + "','H','" + tmpUrl + "?handle=edit&id=" + strGID + "&isenabled=" + hdEnabled + "');"; } else { modelData.Value = "javascript:void(0);"; } //设置是否有子菜单 if (hasChild) { modelData.SetChildNode = 0; modelData.SetHasChild = true; } else { modelData.SetChildNode = 0; modelData.SetHasChild = false; } //recording++; // Response.Write(ConvertToJS(modelData) + ","); return (ConvertToJS(modelData) + ","); } #endregion } }