Exemple #1
0
        public static TypeClass GetRootType(int id)
        {
            TypeClass parent   = GetType(id);
            int       parentId = parent.ParentId;

            while (parentId > 0)
            {
                parent   = GetType(parentId);
                parentId = parent.ParentId;
            }
            return(parent);
        }
Exemple #2
0
        public static TypeClass GetType(int id)
        {
            string    sql = "select * from T_Type where ID = " + id.ToString();
            DataTable ti  = OleDAL.GetRecords(sql);

            if (ti != null && ti.Rows.Count > 0)
            {
                TypeClass type = new TypeClass(id, ti.Rows[0]["TypeName"].ToString(), ti.Rows[0]["Description"].ToString(), (int)ti.Rows[0]["ParentID"]);
                return(type);
            }
            return(null);
        }
Exemple #3
0
        public static List <TypeClass> GetSubTypes(int parentID)
        {
            string           sql   = "select * from T_Type where ParentID=" + parentID.ToString();
            DataTable        types = OleDAL.GetRecords(sql);
            List <TypeClass> ts    = new List <TypeClass>();

            for (int i = 0; i < types.Rows.Count; i++)
            {
                TypeClass tc = new TypeClass((int)types.Rows[i]["ID"], types.Rows[i]["TypeName"].ToString(), types.Rows[i]["Description"].ToString(), (int)types.Rows[i]["ParentID"]);
                ts.Add(tc);
            }
            return(ts);
        }
Exemple #4
0
        public static string GetTypeNameOfInfo(int infoID)
        {
            List <string> typeArray = new List <string>();
            TypeClass     type      = GetType(GetInfo(infoID).TypeId);

            typeArray.Add(type.TypeName);
            int parentId = type.ParentId;

            while (parentId > 0)
            {
                TypeClass parent = GetType(parentId);
                typeArray.Add(parent.TypeName);
                parentId = parent.ParentId;
            }
            typeArray.Reverse();
            return(string.Join(".", typeArray.ToArray()));
        }
Exemple #5
0
        private static string GetAllParentIds(int typeId)
        {
            string    typeIdStr = "";
            TypeClass type      = GetType(typeId);
            int       parentId  = type.ParentId;

            while (parentId > 0)
            {
                TypeClass parent = GetType(parentId);
                if (typeIdStr == "")
                {
                    typeIdStr += parent.Id;
                }
                else
                {
                    typeIdStr += "," + parent.Id;
                }
                parentId = parent.ParentId;
            }
            return(typeIdStr);
        }
Exemple #6
0
        public static List <TypeClass> GetTypes(string where)
        {
            string sql = "select * from T_Type";

            if (!string.IsNullOrEmpty(where))
            {
                where = where.Trim().ToLower();
                if (where.StartsWith("and "))
                {
                    where = where.Substring(4);
                }
                sql += " where (1=1) and " + where;
            }
            DataTable        types = OleDAL.GetRecords(sql);
            List <TypeClass> ts    = new List <TypeClass>();

            for (int i = 0; i < types.Rows.Count; i++)
            {
                TypeClass tc = new TypeClass((int)types.Rows[i]["ID"], types.Rows[i]["TypeName"].ToString(), types.Rows[i]["Description"].ToString(), (int)types.Rows[i]["ParentID"]);
                ts.Add(tc);
            }
            return(ts);
        }
Exemple #7
0
 public TypeNode(List <TypeClass> types)
     : base()
 {
     this.type  = null;
     this.types = types;
 }
Exemple #8
0
 public TypeNode(TypeClass type)
     : base(type.Id.ToString())
 {
     this.type = type;
 }