|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Data;
|
|
|
|
|
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.Collections.Generic;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Modules
|
|
|
|
|
{
|
|
|
|
|
public partial class ModuleGridSource : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string strHandle;//值list表示返回数据信息
|
|
|
|
|
private int iCurrentPage;//当前页数
|
|
|
|
|
private int iShowPage;//显示最大页数
|
|
|
|
|
private string strSearch;//查询条件
|
|
|
|
|
private string strModuleID;//模块GID
|
|
|
|
|
private string strSelectedUserID;//被操作人GID
|
|
|
|
|
private string strSelectedModuleID;//被操作模块GID
|
|
|
|
|
private string strSearchShowName;//要查询的用户名
|
|
|
|
|
private string strSearchDeptName;//要查询的部门名称
|
|
|
|
|
private string strSearchModuleName;//要查询的模块名称
|
|
|
|
|
private string strUserID;
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session["USERID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Server.Transfer("~/Error/FriendError.aspx");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#region 传值参数
|
|
|
|
|
if (Request.QueryString["handle"] != null)
|
|
|
|
|
{
|
|
|
|
|
strHandle = Request.QueryString["handle"].ToString().ToLower().Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["search"] != null)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["id"] != null)
|
|
|
|
|
{
|
|
|
|
|
strModuleID = Request.QueryString["id"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["cur_page"] != null)
|
|
|
|
|
{
|
|
|
|
|
iCurrentPage = int.Parse(Request.QueryString["cur_page"].ToString().Trim());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCurrentPage = 0;
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["show_page"] != null)
|
|
|
|
|
{
|
|
|
|
|
iShowPage = int.Parse(Request.QueryString["show_page"].ToString().Trim());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iShowPage = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["seluser"] != null)
|
|
|
|
|
{
|
|
|
|
|
strSelectedUserID = Request.QueryString["seluser"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Request.QueryString["searchuser"] != null)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
strSearchShowName = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["searchuser"].ToString())));
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["searchdept"] != null)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
strSearchDeptName = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["searchdept"].ToString())));
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["searchmod"] != null)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
strSearchModuleName = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["searchmod"].ToString())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["selmod"] != null)
|
|
|
|
|
{
|
|
|
|
|
strSelectedModuleID = Request.QueryString["selmod"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strHandle != null)
|
|
|
|
|
{
|
|
|
|
|
if (strHandle.Equals("list"))
|
|
|
|
|
{
|
|
|
|
|
Response.Write(GetModulesList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strHandle.Equals("modtree"))
|
|
|
|
|
{
|
|
|
|
|
Response.Write(GetModuleTree());
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("listpage"))
|
|
|
|
|
{
|
|
|
|
|
Response.Write(GetModulesListPage().ToString());
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("delete") && strModuleID != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(DeleteModule(strModuleID));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("modusertree") && strSelectedUserID != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(GetUserModuleTree(strSelectedUserID));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("checkuser") && strSearchShowName != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(SearchUserByName(strSearchShowName));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("checkdept") && strSearchDeptName != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(SearchDeptByName(strSearchDeptName));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("checkmod") && strSearchModuleName != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(SearchModuleByName(strSearchModuleName));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("addmod") && strSelectedUserID != null && strSelectedModuleID != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(AddUserModule(strSelectedUserID, strSelectedModuleID));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("removemod") && strSelectedUserID != null && strSelectedModuleID != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(RemoveUserModule(strSelectedUserID, strSelectedModuleID));
|
|
|
|
|
}
|
|
|
|
|
if (strHandle.Equals("validusermod") && strModuleID != null)
|
|
|
|
|
{
|
|
|
|
|
Response.Write(ValidateExistUserActionModule(strModuleID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 验证当前模块是否已经被指定到用户ACTION
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 验证当前模块是否已经被指定到用户ACTION
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempModuleID">模块GID</param>
|
|
|
|
|
/// <returns>值1表示存在 值不等于1表示不存在</returns>
|
|
|
|
|
private int ValidateExistUserActionModule(string tempModuleID)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
UserActionDA userActionDA = new UserActionDA();
|
|
|
|
|
|
|
|
|
|
int iTempCount = userActionDA.GetExistUserActionModule(tempModuleID);
|
|
|
|
|
|
|
|
|
|
if (iTempCount > 0)
|
|
|
|
|
{
|
|
|
|
|
iResult = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iResult = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 移除用户权限模块
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移除用户权限模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempSelectedUserID">用户GID</param>
|
|
|
|
|
/// <param name="tempSelectedModuleID">模块GID</param>
|
|
|
|
|
/// <returns>值1表示移除成功 值不等1表示移除失败</returns>
|
|
|
|
|
private int RemoveUserModule(string tempSelectedUserID,string tempSelectedModuleID)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
UserActionDA userActionDA = new UserActionDA();
|
|
|
|
|
//先判断当前要添加的模块是否用户已经开通了
|
|
|
|
|
if (userActionDA.IsExistUserModule(tempSelectedUserID, tempSelectedModuleID))
|
|
|
|
|
{
|
|
|
|
|
iResult = userActionDA.DeleteUserAction(tempSelectedUserID, tempSelectedModuleID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iResult = -2;//不存在相应的模块权限
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加用户权限模块
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加用户权限模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempSelectedUserID">用户GID</param>
|
|
|
|
|
/// <param name="tempSelectedModuleID">模块GID</param>
|
|
|
|
|
/// <returns>值1表示添加成功 值不等1表示添加失败</returns>
|
|
|
|
|
private int AddUserModule(string tempSelectedUserID, string tempSelectedModuleID)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
UserActionDA userActionDA = new UserActionDA();
|
|
|
|
|
//先判断当前要添加的模块是否用户已经开通了
|
|
|
|
|
if (!userActionDA.IsExistUserModule(tempSelectedUserID, tempSelectedModuleID))
|
|
|
|
|
{
|
|
|
|
|
iResult = userActionDA.InsertUserAction(tempSelectedUserID, tempSelectedModuleID, strUserID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iResult = -2;//错误已经已经为用户指定了模块权限,不能重复添加
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 通过模块名称模糊查询获取模块信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过模块名称模糊查询获取模块信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempModuleName">模块名称</param>
|
|
|
|
|
/// <returns>返回模块JSON</returns>
|
|
|
|
|
private string SearchModuleByName(string tempModuleName)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder searchModBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
IList<ModuleEntity> moduleEntities = new List<ModuleEntity>();
|
|
|
|
|
|
|
|
|
|
moduleEntities = moduleDA.GetModuleByDescriptionLike(tempModuleName);
|
|
|
|
|
|
|
|
|
|
searchModBuilder.Append("{");
|
|
|
|
|
searchModBuilder.Append("\"mods\":");
|
|
|
|
|
searchModBuilder.Append("[");
|
|
|
|
|
|
|
|
|
|
if (moduleEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < moduleEntities.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == moduleEntities.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
searchModBuilder.Append("{");
|
|
|
|
|
searchModBuilder.Append("\"gid\":\"" + moduleEntities[i].Gid + "\",");
|
|
|
|
|
searchModBuilder.Append("\"modname\":\"" + moduleEntities[i].ModuleName + "\"");
|
|
|
|
|
searchModBuilder.Append("}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
searchModBuilder.Append("{");
|
|
|
|
|
searchModBuilder.Append("\"gid\":\"" + moduleEntities[i].Gid + "\",");
|
|
|
|
|
searchModBuilder.Append("\"modname\":\"" + moduleEntities[i].ModuleName + "\"");
|
|
|
|
|
searchModBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchModBuilder.Append("]");
|
|
|
|
|
searchModBuilder.Append("}");
|
|
|
|
|
|
|
|
|
|
return searchModBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 通过部门名称模糊查询获取部门信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过部门名称模糊查询获取部门信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempDeptName">部门名称</param>
|
|
|
|
|
/// <returns>返回部门JSON</returns>
|
|
|
|
|
private string SearchDeptByName(string tempDeptName)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder searchDeptBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
SysDeptDA sysDeptDA = new SysDeptDA();
|
|
|
|
|
IList<SysDeptEntity> sysDeptEntities = new List<SysDeptEntity>();
|
|
|
|
|
|
|
|
|
|
sysDeptEntities = sysDeptDA.GetDeptsByDeptName(tempDeptName);
|
|
|
|
|
|
|
|
|
|
searchDeptBuilder.Append("{");
|
|
|
|
|
searchDeptBuilder.Append("\"depts\":");
|
|
|
|
|
searchDeptBuilder.Append("[");
|
|
|
|
|
|
|
|
|
|
if (sysDeptEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sysDeptEntities.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == sysDeptEntities.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
searchDeptBuilder.Append("{");
|
|
|
|
|
searchDeptBuilder.Append("\"gid\":\"" + sysDeptEntities[i].GID + "\",");
|
|
|
|
|
searchDeptBuilder.Append("\"deptname\":\"" + sysDeptEntities[i].DEPTNAME + "\"");
|
|
|
|
|
searchDeptBuilder.Append("}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
searchDeptBuilder.Append("{");
|
|
|
|
|
searchDeptBuilder.Append("\"gid\":\"" + sysDeptEntities[i].GID + "\",");
|
|
|
|
|
searchDeptBuilder.Append("\"deptname\":\"" + sysDeptEntities[i].DEPTNAME + "\"");
|
|
|
|
|
searchDeptBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchDeptBuilder.Append("]");
|
|
|
|
|
searchDeptBuilder.Append("}");
|
|
|
|
|
|
|
|
|
|
return searchDeptBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据检索的用户名称进行模糊查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据检索的用户名称进行模糊查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempShowName">用户ShowName</param>
|
|
|
|
|
/// <returns>返回JSON数据</returns>
|
|
|
|
|
private string SearchUserByName(string tempShowName)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder searchUserBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
UserDA userDA = new UserDA();
|
|
|
|
|
|
|
|
|
|
IList<UserEntity> userEntities = new List<UserEntity>();
|
|
|
|
|
|
|
|
|
|
userEntities = userDA.GetUserByShowNameLike(tempShowName);
|
|
|
|
|
|
|
|
|
|
searchUserBuilder.Append("{");
|
|
|
|
|
searchUserBuilder.Append("\"users\":");
|
|
|
|
|
searchUserBuilder.Append("[");
|
|
|
|
|
|
|
|
|
|
if (userEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for(int i=0;i<userEntities.Count;i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == userEntities.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
searchUserBuilder.Append("{");
|
|
|
|
|
searchUserBuilder.Append("\"gid\":\"" + userEntities[i].Gid + "\",");
|
|
|
|
|
searchUserBuilder.Append("\"showname\":\"" + userEntities[i].ShowName + "\"");
|
|
|
|
|
searchUserBuilder.Append("}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
searchUserBuilder.Append("{");
|
|
|
|
|
searchUserBuilder.Append("\"gid\":\"" + userEntities[i].Gid + "\",");
|
|
|
|
|
searchUserBuilder.Append("\"showname\":\"" + userEntities[i].ShowName + "\"");
|
|
|
|
|
searchUserBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchUserBuilder.Append("]");
|
|
|
|
|
searchUserBuilder.Append("}");
|
|
|
|
|
|
|
|
|
|
return searchUserBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除模块信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除模块信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempModuleGID">模块GID</param>
|
|
|
|
|
/// <returns>值1表示删除成功 值-1表示删除失败 值-2表示当前模板下有子模板不能删除,需要将所有子模板删除后,才能删除此模板</returns>
|
|
|
|
|
private int DeleteModule(string tempModuleGID)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
IList<ModuleEntity> moduleEntities = new List<ModuleEntity>();
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
moduleEntities = moduleDA.GetSubModule(tempModuleGID);
|
|
|
|
|
|
|
|
|
|
if (moduleEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
iResult = -2;//表示当前模板下有子模板不能删除,需要将所有子模板删除后,才能删除此模板
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iResult = moduleDA.DeleteModule(tempModuleGID);
|
|
|
|
|
}
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 获取模块列表总页数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取模块列表总页数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回总页数</returns>
|
|
|
|
|
private int GetModulesListPage()
|
|
|
|
|
{
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
string strSql = "SELECT COUNT(*) FROM sys_module WHERE 1>0 ";
|
|
|
|
|
|
|
|
|
|
string strCondition = "";
|
|
|
|
|
if (strSearch != null)
|
|
|
|
|
{
|
|
|
|
|
if (!strSearch.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
string tempSearch = strSearch;
|
|
|
|
|
tempSearch = tempSearch.Replace("{", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("}", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("[", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("]", "");
|
|
|
|
|
|
|
|
|
|
string[] searchArg = tempSearch.Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < searchArg.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = searchArg[i].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "name"://Customer
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND (NAME LIKE '%{0}%' OR DESCRIPTION LIKE '%{0}%') ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "url"://BillNO
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND MODULEURL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "parent"://ETD BeginDate
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND PARENTID IN (SELECT GID FROM sys_module WHERE NAME LIKE '%{0}%' OR DESCRIPTION LIKE '%{0}%') ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSql += strCondition;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int iTotal = int.Parse(moduleDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
|
|
|
|
|
|
|
|
|
|
return iTotal;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取模块列表信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取模块列表信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回JSON列表信息</returns>
|
|
|
|
|
private string GetModulesList()
|
|
|
|
|
{
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
DataTable sourceTable;
|
|
|
|
|
|
|
|
|
|
string strCondition = "";
|
|
|
|
|
string strTopInclude = "";
|
|
|
|
|
string strTopNotInclude = "";
|
|
|
|
|
|
|
|
|
|
if (strSearch != null)
|
|
|
|
|
{
|
|
|
|
|
if (!strSearch.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
string tempSearch = strSearch;
|
|
|
|
|
tempSearch = tempSearch.Replace("{", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("}", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("[", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("]", "");
|
|
|
|
|
|
|
|
|
|
string[] searchArg = tempSearch.Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < searchArg.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = searchArg[i].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "name"://Customer
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND (NAME LIKE '%{0}%' OR DESCRIPTION LIKE '%{0}%') ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "url"://BillNO
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND MODULEURL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "parent"://ETD BeginDate
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
strCondition += String.Format(" AND PARENTID IN (SELECT GID FROM sys_module WHERE NAME LIKE '%{0}%' OR DESCRIPTION LIKE '%{0}%') ", strArg[1].Replace("\"", ""));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string strSql = "";
|
|
|
|
|
if (iCurrentPage > 0 && iShowPage > 0)
|
|
|
|
|
{
|
|
|
|
|
if (iCurrentPage == 1)
|
|
|
|
|
{
|
|
|
|
|
strSql = String.Format(" SELECT {0} A.GID, A.NAME, A.DESCRIPTION, A.MODULEURL,A.MODULEICON, A.STATE, A.SORT, '查看',B.SHOWNAME, A.CREATETIME,A.TYPE "
|
|
|
|
|
+ " FROM sys_module as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE 1>0 " + strCondition + " ORDER BY A.NAME ASC ", "top " + iShowPage.ToString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
|
|
|
|
|
strTopInclude = "top " + iShowPage.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql = String.Format(" SELECT {0} A.GID, A.NAME, A.DESCRIPTION, A.MODULEURL,A.MODULEICON, A.STATE, A.SORT, '查看',B.SHOWNAME, A.CREATETIME,A.TYPE "
|
|
|
|
|
+ " FROM sys_module as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE 1>0 AND A.GID NOT IN "
|
|
|
|
|
+ " (SELECT {1} GID FROM sys_module WHERE 1>0 " + strCondition + " ORDER BY NAME ASC ) " + strCondition
|
|
|
|
|
+ " ORDER BY A.NAME ASC ", strTopInclude, strTopNotInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = " SELECT A.GID, A.NAME, A.DESCRIPTION, A.MODULEURL,A.MODULEICON, A.STATE, A.SORT, '查看',B.SHOWNAME, A.CREATETIME,A.TYPE "
|
|
|
|
|
+ " FROM sys_module as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE 1>0 " + strCondition + " ORDER BY A.NAME ASC ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sourceTable = moduleDA.GetExcuteSql(strSql).Tables[0];
|
|
|
|
|
|
|
|
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
|
|
|
sourceBuilder.Append("{");
|
|
|
|
|
sourceBuilder.Append("rows:[");
|
|
|
|
|
for (int i = 0; i < sourceTable.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
|
|
|
|
|
sourceBuilder.Append("data:[");
|
|
|
|
|
sourceBuilder.Append("\"0\",");
|
|
|
|
|
for (int j = 1; j < sourceTable.Columns.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (j == sourceTable.Columns.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i == sourceTable.Rows.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append("]}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append("]},");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sourceBuilder.Append("]");
|
|
|
|
|
sourceBuilder.Append("}");
|
|
|
|
|
|
|
|
|
|
return sourceBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取树JSON信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取树JSON信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回树JSON信息</returns>
|
|
|
|
|
private string GetModuleTree()
|
|
|
|
|
{
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
IList<ModuleEntity> moduleEntities = new List<ModuleEntity>();
|
|
|
|
|
moduleEntities = moduleDA.GetAll();
|
|
|
|
|
|
|
|
|
|
IList<ModuleEntity> parentModuleEntities = new List<ModuleEntity>();
|
|
|
|
|
parentModuleEntities = moduleDA.GetParentModule();
|
|
|
|
|
List<ModuleEntity> tempEntities = moduleDA.GetAllSubModules();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder leftNav = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
|
|
|
StringBuilder subBuilder = new StringBuilder();
|
|
|
|
|
sourceBuilder.Append("{id:0");
|
|
|
|
|
|
|
|
|
|
if (parentModuleEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append(",item:[");
|
|
|
|
|
|
|
|
|
|
foreach (ModuleEntity parentModuleEntity in parentModuleEntities)
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append("{id:\"" + parentModuleEntity.Gid + "\",");
|
|
|
|
|
subBuilder.Append("text:\"" + parentModuleEntity.ModuleDescription + "\"");
|
|
|
|
|
string strItems = "";
|
|
|
|
|
|
|
|
|
|
strItems = GetSubJs(parentModuleEntity.Gid, tempEntities, "");
|
|
|
|
|
|
|
|
|
|
if (!strItems.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append(",item:[");
|
|
|
|
|
subBuilder.Append(strItems);
|
|
|
|
|
subBuilder.Append("]},");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string strChilds = subBuilder.ToString();
|
|
|
|
|
strChilds = strChilds.Substring(0, strChilds.Length - 1);//去除末尾逗号
|
|
|
|
|
|
|
|
|
|
sourceBuilder.Append(strChilds);
|
|
|
|
|
sourceBuilder.Append("]");
|
|
|
|
|
}
|
|
|
|
|
sourceBuilder.Append("}");
|
|
|
|
|
return sourceBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取树JSON信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取树JSON信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回树JSON信息</returns>
|
|
|
|
|
private string GetUserModuleTree(string tempSelectedUserID)
|
|
|
|
|
{
|
|
|
|
|
ModuleDA moduleDA = new ModuleDA();
|
|
|
|
|
IList<ModuleEntity> moduleEntities = new List<ModuleEntity>();
|
|
|
|
|
moduleEntities = moduleDA.GetUserAll(tempSelectedUserID);
|
|
|
|
|
|
|
|
|
|
IList<ModuleEntity> parentModuleEntities = new List<ModuleEntity>();
|
|
|
|
|
parentModuleEntities = moduleDA.GetUserParentModule(tempSelectedUserID);
|
|
|
|
|
List<ModuleEntity> tempEntities = moduleDA.GetUserAllSubModules(tempSelectedUserID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder leftNav = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
|
|
|
StringBuilder subBuilder = new StringBuilder();
|
|
|
|
|
sourceBuilder.Append("{id:0");
|
|
|
|
|
|
|
|
|
|
if (parentModuleEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
sourceBuilder.Append(",item:[");
|
|
|
|
|
|
|
|
|
|
foreach (ModuleEntity parentModuleEntity in parentModuleEntities)
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append("{id:\"" + parentModuleEntity.Gid + "\",");
|
|
|
|
|
subBuilder.Append("text:\"" + parentModuleEntity.ModuleDescription + "\"");
|
|
|
|
|
string strItems = "";
|
|
|
|
|
|
|
|
|
|
strItems = GetSubJs(parentModuleEntity.Gid, tempEntities, "");
|
|
|
|
|
|
|
|
|
|
if (!strItems.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append(",item:[");
|
|
|
|
|
subBuilder.Append(strItems);
|
|
|
|
|
subBuilder.Append("]},");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
subBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string strChilds = subBuilder.ToString();
|
|
|
|
|
strChilds = strChilds.Substring(0, strChilds.Length - 1);//去除末尾逗号
|
|
|
|
|
|
|
|
|
|
sourceBuilder.Append(strChilds);
|
|
|
|
|
sourceBuilder.Append("]");
|
|
|
|
|
}
|
|
|
|
|
sourceBuilder.Append("}");
|
|
|
|
|
return sourceBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取所有子模块信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有子模块信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parentGid">父节点GID</param>
|
|
|
|
|
/// <param name="tempEntities">全部子节点实体类</param>
|
|
|
|
|
/// <param name="tempJSON">返回值</param>
|
|
|
|
|
/// <returns>JSON树信息</returns>
|
|
|
|
|
public String GetSubJs(string parentGid, List<ModuleEntity> 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 = GetJSON(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("{0}", strChilds);
|
|
|
|
|
valBuilder.Append(tempJSON);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
valBuilder.Append(strChilds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return valBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取节点JSON信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取节点JSON信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempModuleEntity"></param>
|
|
|
|
|
/// <param name="tempIsParent"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetJSON(ModuleEntity tempModuleEntity, bool tempIsParent)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder jsonBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
jsonBuilder.Append("{id:\"" + tempModuleEntity.Gid + "\",");
|
|
|
|
|
jsonBuilder.Append("text:\"" + tempModuleEntity.ModuleDescription + "\"");
|
|
|
|
|
|
|
|
|
|
if (tempIsParent)//如果当前节点有子节点,则增加子节点信息 item[{0}]
|
|
|
|
|
{
|
|
|
|
|
jsonBuilder.Append(",item:[{0}]},");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
jsonBuilder.Append("},");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return jsonBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 获取
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="tempModuleEntity"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//private string GetNodeJSON(ModuleEntity tempModuleEntity)
|
|
|
|
|
//{
|
|
|
|
|
// StringBuilder NodeBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
// NodeBuilder.Append("id:" + tempModuleEntity.Gid + ",");
|
|
|
|
|
// NodeBuilder.Append("text:" + tempModuleEntity.ModuleDescription + ",");
|
|
|
|
|
|
|
|
|
|
// return NodeBuilder.ToString();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 遍历模块查看此模块是否为父模块
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 遍历模块查看此模块是否为父模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempEntities">所有节点信息实体类</param>
|
|
|
|
|
/// <param name="strGID">要查询的模块GID</param>
|
|
|
|
|
/// <returns>True-存在子节点 False-不存在子节点</returns>
|
|
|
|
|
public bool IsParent(List<ModuleEntity> tempEntities, string strGID)
|
|
|
|
|
{
|
|
|
|
|
bool IsExist = false;
|
|
|
|
|
foreach (ModuleEntity mdle in tempEntities)
|
|
|
|
|
{
|
|
|
|
|
if (mdle.ParentID.Trim().Equals(strGID))
|
|
|
|
|
{
|
|
|
|
|
IsExist = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return IsExist;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|