Ejemplo n.º 1
0
        private void BuscarHijos(int perfilID, string opcionPadreID, squishyTREE.TreeNode n)
        {
            IOpcion opcion = OpcionFactory.GetOpcion();

            opcion.OpcionPadreID = opcionPadreID;
            DsOpcion ds = opcion.GetOpcionesByPerfilID(perfilID);

            int i = 2;

            foreach (DsOpcion.DatosRow dr in ds.Datos)
            {
                string key = "n" + i;
                // obtengo el nodo padre
                squishyTREE.TreeNode n1 = n.AddNode(dr.OpcionID, key);
                n1.AddTaggedValue("val1", dr.Descripcion);

                // busco los hijos de este padre
                this.BuscarHijos(perfilID, dr.OpcionID, n1);
                i++;
            }
        }
        private void buscarHijos(string opcionPadreID, squishyTREE.TreeNode n)
        {
            IOpcion  opcion = OpcionFactory.GetOpcion();
            DsOpcion ds     = opcion.GetOpcionesHijos(opcionPadreID, Utiles.Validaciones.obtieneEntero(this.txtPerfilID.Text));
            int      i      = 2;

            foreach (DsOpcion.DatosRow dr in ds.Datos)
            {
                string key = "n" + i;
                // obtengo el nodo padre
                squishyTREE.TreeNode n1 = n.AddNode(dr.OpcionID, key, true);
                n1.AddTaggedValue("val1", dr.Descripcion);
                if (dr.Asignado)
                {
                    n1.Check();
                }
                // busco los hijos de este padre
                buscarHijos(dr.OpcionID, n1);
                i++;
            }
        }
Ejemplo n.º 3
0
        private void addChildNode(XmlNode node, string textAttribute, string keyAttribute, TreeNode tNode, string checkAttribute, string checkDefaultsAttribute)
        {
            string text;
            string key       = "";
            bool   checkbox  = false;
            bool   isChecked = false;

            text = node.Attributes[textAttribute].Value;
            if (node.Attributes[keyAttribute] != null)
            {
                key = node.Attributes[keyAttribute].Value;
            }
            if (node.Attributes[checkAttribute] != null)
            {
                checkbox = Convert.ToBoolean(node.Attributes[checkAttribute].Value);
            }
            if (node.Attributes[checkDefaultsAttribute] != null)
            {
                isChecked = Convert.ToBoolean(node.Attributes[checkDefaultsAttribute].Value);
            }

            TreeNode n;

            if (tNode == null)
            {            //add to the TreeView
                n = this.AddNode(text, key, checkbox);
            }
            else
            {            //add to the TreeNode
                n = tNode.AddNode(text, key, checkbox);
            }
            //get the tagged values
            XmlNodeList taggedValues = node.SelectNodes("taggedValue");
            int         tagCount     = 0;

            foreach (XmlNode tg in taggedValues)
            {
                tagCount++;
                string tagName  = tg.Attributes["tagName"].Value;
                string tagValue = tg.Attributes["tagValue"].Value;

                n.AddTaggedValue(tagName, tagValue);
            }
            if (node.ChildNodes.Count - tagCount > 0)
            {
                //add the child nodes of this node
                foreach (XmlNode child in node.ChildNodes)
                {
                    if (child.Name != "taggedValue")
                    {
                        this.addChildNode(child, textAttribute, keyAttribute, n, checkAttribute, checkDefaultsAttribute);
                    }
                }
            }
            if (checkDefaultsAttribute != "" && node.Attributes[checkDefaultsAttribute] != null &&
                node.Attributes[checkDefaultsAttribute].Value.Trim() != "")
            {
                if (!this.Page.IsPostBack)
                {
                    n.Check(isChecked);
                }
            }
        }
Ejemplo n.º 4
0
        private void AddChildNode(DataRow row, string textColumn, string keyColumn, string checkColumn,
                                  string checkDefaultsColumn, TreeNode node)
        {
            string text;
            string key;
            bool   checkbox  = false;
            bool   isChecked = false;

            text = row[textColumn].ToString();
            key  = row[keyColumn].ToString();
            if (checkColumn != "")
            {
                if (row[checkColumn] != DBNull.Value)
                {
                    checkbox = Convert.ToBoolean(row[checkColumn]);
                }
                if (row[checkDefaultsColumn] != DBNull.Value)
                {
                    isChecked = Convert.ToBoolean(row[checkDefaultsColumn]);
                }
            }

            TreeNode n;

            if (node == null)
            {            //add to the treeview
                n = this.AddNode(text, key, checkbox);
            }
            else
            {            //add to the node
                n = node.AddNode(text, key, checkbox);
            }
            //now add the tagged values
            if (this.headers.Count != 0)
            {
                foreach (object[] o in this.headers)
                {
                    //only add the tagged value if this row contains the column in question
                    if (row.Table.Columns.Contains(o[0].ToString()))
                    {
                        //o[0] is the column name
                        n.AddTaggedValue(o[0].ToString(), row[o[0].ToString()].ToString());
                    }
                }
            }
            //now look for child rows
            if (row.Table.ChildRelations.Count > 0)
            {
                foreach (DataRelation r in row.Table.ChildRelations)
                {
                    DataRow[] childRows = row.GetChildRows(r);
                    foreach (DataRow childRow in childRows)
                    {
                        this.AddChildNode(childRow, textColumn, keyColumn, checkColumn, checkDefaultsColumn,
                                          n);
                    }
                }
            }
            if (checkbox)
            {
                if (!this.Page.IsPostBack)
                {
                    n.Check(isChecked);
                }
            }
        }