public static List <BootstrapTreeNode> GetChilds(int nodeid)
        {
            clsDbGeneral             db       = new clsDbGeneral();
            DataTable                dt       = db.GetData("SELECT   Department_Code, Department_Name, Parent_Department_Code FROM   HRMIS_tblDepartment where Parent_Department_Code=" + nodeid);
            List <BootstrapTreeNode> toreturn = new List <BootstrapTreeNode>();

            foreach (DataRow row in dt.Rows)
            {
                BootstrapTreeNode nd = new BootstrapTreeNode();
                nd.text = row["Department_Name"].ToString();
                if (HaveChildNodes((int)row["Department_Code"]))
                {
                    nd.nodes      = GetChilds((int)row["Department_Code"]);
                    nd.selectable = true;
                    nd.id         = (int)row["Department_Code"];
                }
                else
                {
                    nd.selectable = true;
                    nd.id         = (int)row["Department_Code"];
                }

                toreturn.Add(nd);
            }
            return(toreturn);
        }
        public static bool UpdateNode(int NodeID, string NodeText)
        {
            clsDbGeneral db    = new clsDbGeneral();
            string       query = "Update [HRMIS_tblDepartment] set Department_Name=N'" + NodeText + "' where Department_Code=" + NodeID;

            db.ExecuteQuery(query);
            return(true);
        }
        public static bool AddChildNode(int ParentNodeID, string NodeText)
        {
            clsDbGeneral db     = new clsDbGeneral();
            int          NodeID = db.GetMaxID("Department_Code", "HRMIS_tblDepartment");
            string       query  = "INSERT INTO [HRMIS_tblDepartment](Department_Code, Department_Name, Parent_Department_Code) VALUES(" + NodeID + ",N'" + NodeText + "' ," + ParentNodeID + ")";

            db.ExecuteQuery(query);
            return(true);
        }
        public static bool HaveChildNodes(int nodeid)
        {
            clsDbGeneral db = new clsDbGeneral();

            return(db.GetData("SELECT   Department_Code, Department_Name, Parent_Department_Code FROM   HRMIS_tblDepartment where Parent_Department_Code=" + nodeid).Rows.Count > 0 ? true : false);
        }