123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- using SysBaseLibs;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SysDataLibs.TableClass
- {
- partial class Sys_Functions_info
- {
- public static string GetAllFunStrByUserId(string pcUserId, DBConnSql poDBConn)
- {
- string lcRetVal = "";
- string lcSql = "select functionID from vwUserHasAllFunctions where userid ='" + pcUserId + "'";
- rsQuery loQuery = poDBConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.MoveFirst();
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- lcRetVal += (lcRetVal == "" ? "" : ",") + "'" + loQuery.GetString("functionID") + "'";
- loQuery.MoveNext();
- }
- }
- if (lcRetVal.Trim().Length == 0)
- lcRetVal = "''";
- return lcRetVal;
- }
- public static bool UpdatePowerOfGroupAndUser(string insertSqlStr, string deleteSqlStr, string FunctionColl, string ObjectID, string ObjectType, DBConnSql poDBConn)
- {
- bool lbRetVal = false;
- string lcSql = deleteSqlStr + " " + insertSqlStr;
- IdCollection loColl = new IdCollection();
- SqlSPPar loSPpar = new SqlSPPar("ObjectID", SqlDbType.NVarChar);
- loSPpar.ParaLength = 20;
- loSPpar.ParameterValue = ObjectID.Trim();
- loColl.Add(loSPpar);
- loSPpar = new SqlSPPar("FunctionColl", SqlDbType.NVarChar);
- loSPpar.ParaLength = 2000;
- loSPpar.ParameterValue = FunctionColl.Trim();
- loColl.Add(loSPpar);
- loSPpar = new SqlSPPar("ObjectType", SqlDbType.VarChar);
- loSPpar.ParaLength = 5;
- loSPpar.ParameterValue = ObjectType;
- loColl.Add(loSPpar);
- if (poDBConn.BeginTrans())
- {
- if (poDBConn.ExecuteSql(lcSql) && poDBConn.ExecuteStoredProc("Pr_AddFatherFunction", loColl))
- {
- poDBConn.CommitTrans();
- lbRetVal = true;
- }
- else
- poDBConn.RollbackTrans();
- }
- return lbRetVal;
- }
- public static bool MoveFunction(string FunctionID, string way, DBConnSql poDBConn)
- {
- bool lbRetVal = false;
- IdCollection loColl = new IdCollection();
- SqlSPPar sqlP = new SqlSPPar("CurItem", SqlDbType.VarChar);
- sqlP.ParaLength = 20;
- sqlP.ParameterValue = FunctionID;
- loColl.Add(sqlP);
- sqlP = new SqlSPPar("way", SqlDbType.VarChar);
- sqlP.ParaLength = 4;
- sqlP.ParameterValue = way;
- loColl.Add(sqlP);
- if (poDBConn.BeginTrans())
- {
- if (poDBConn.ExecuteStoredProc("Pr_FunctionsSort", loColl))
- {
- poDBConn.CommitTrans();
- lbRetVal = true;
- }
- else
- poDBConn.RollbackTrans();
- }
- return lbRetVal;
- }
- public static bool DeleteFunction(string FunctionID, DBConnSql poDBConn)
- {
- bool lbRetVal = false;
- IdCollection loColl = new IdCollection();
- SqlSPPar sqlP = new SqlSPPar("FunctionID", SqlDbType.VarChar);
- sqlP.ParaLength = 20;
- sqlP.ParameterValue = FunctionID;
- loColl.Add(sqlP);
- if (poDBConn.BeginTrans())
- {
- if (poDBConn.ExecuteStoredProc("Pr_deleteFunction_ByFunctionID", loColl))
- {
- poDBConn.CommitTrans();
- lbRetVal = true;
- }
- else
- poDBConn.RollbackTrans();
- }
- return lbRetVal;
- }
- public static rsXmlNode GetFunctionXmlNode(DBConnSql poDBConn)
- {
- rsXmlNode loRetVal = null;
- if (poDBConn != null && poDBConn.IsOpened)
- {
- string lcSql = " select " + Sys_Functions_info.cFunctionID + "," + Sys_Functions_info.cFunctionName + "," + Sys_Functions_info.cFatherID + "," + Sys_Functions_info.cDepth + "," + Sys_Functions_info.cIsLeaf + " from " + Tn.Sys_Functions + " order by depth, Sort ";
- rsQuery loQuery = poDBConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loRetVal = new rsXmlNode("functions", "");
- loQuery.MoveFirst();
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- rsXmlNode loNode = new rsXmlNode(loQuery.GetString("FunctionId"), loQuery.GetBool("isleaf") ? " ◇ " + loQuery.GetString(Sys_Functions_info.cFunctionName) + " " : " ◆ " + loQuery.GetString(Sys_Functions_info.cFunctionName) + " ");
- loNode.Depth = loQuery.GetInt("Depth");
- string lcFather = loQuery.GetString("FatherId");
- rsXmlNode loFather = MyUtils.GetChildNode(loRetVal, lcFather);
- if (loFather != null)
- {
- loFather.AddChild(loNode);
- }
- else
- {
- loRetVal.AddChild(loNode);
- }
- loQuery.MoveNext();
- }
- }
- }
- return loRetVal;
- }
- //------------添加自定义的方法-----------
-
-
- public static Sys_Functions_info CreatTree(rsQuery poQuery)
- {
- Sys_Functions_info loRoot = null;
- poQuery.FilterBy("FunctionID = 'HTSystem'");
- //poQuery.FilterBy("FatherID = '0'");
- if (poQuery.RecCount == 1)
- {
- loRoot = new Sys_Functions_info(poQuery.CurrentRow);
- //poQuery.FilterBy("FatherID='" + loRoot.FunctionID + "' and FatherID <> '0'");
- poQuery.FilterBy("FatherID='" + loRoot.FunctionID + "' and FunctionID <> 'HTSystem'");
- poQuery.MoveFirst();
- for (int i = 0; i < poQuery.RecCount; i++)
- {
- Sys_Functions_info loFunctionNode = new Sys_Functions_info(poQuery.CurrentRow);
- loRoot.ChildNodes.Add(loFunctionNode);
- poQuery.MoveNext();
- }
- if (loRoot.ChildNodes.Count > 0)
- {
- foreach (Sys_Functions_info loFuncInfo in loRoot.ChildNodes)
- {
- CreatTree(poQuery, loFuncInfo);
- }
-
- }
- }
- return loRoot;
- }
- static void CreatTree(rsQuery poQuery, Sys_Functions_info poFatherNode)
- {
- //poQuery.FilterBy("FatherID='" + poFatherNode.FunctionID + "' and FatherID <> '0'");
- poQuery.FilterBy("FatherID='" + poFatherNode.FunctionID + "' and FunctionID <> 'HTSystem'");
- poQuery.MoveFirst();
- for (int i = 0; i < poQuery.RecCount; i++)
- {
- Sys_Functions_info loFunctionNode = new Sys_Functions_info(poQuery.CurrentRow);
- poFatherNode.ChildNodes.Add(loFunctionNode);
- poQuery.MoveNext();
- }
- if (poFatherNode.ChildNodes.Count > 0)
- {
- foreach (Sys_Functions_info loFuncInfo in poFatherNode.ChildNodes)
- CreatTree(poQuery, loFuncInfo);
- }
- }
- List<Sys_Functions_info> _ChildNodes = new List<Sys_Functions_info>();
- public List<Sys_Functions_info> ChildNodes
- {
- get { return _ChildNodes; }
- set { _ChildNodes = value; }
- }
- public string ToJason()
- {
- string lcRetVal = "{";
- lcRetVal += "\"FunctionID\": \"" + this.FunctionID + "\",";
- lcRetVal += "\"FunctionName\": \"" + this.FunctionName + "\",";
- lcRetVal += "\"URL\": \"" + this.URL + "\"";
- if (this.ChildNodes.Count > 0)
- {
- lcRetVal += ",\"children\": [";
- string lcString = "";
- foreach (Sys_Functions_info loChild in this.ChildNodes)
- {
- lcString += (lcString == "" ? "" : ",") + loChild.ToJason();
- }
- lcRetVal += lcString;
- lcRetVal += "]";
- }
- lcRetVal += "}";
- return lcRetVal;
- }
- }
- }
|