private void SeleccionarNodo(DevExpress.XtraTreeList.Nodes.TreeListNode nodo)
        {
            if (nodo.Id == -100000)
            {
                treeListMenu_x_Usuario_x_Empresa.ExpandAll();
            }
            else if (nodo.Nodes.Count > 0)
            {
                return;
            }
            else
            {
                if ((bool)nodo.GetValue("Tiene_FormularioAsociado"))
                {
                    infoMenu.IdMenu                   = (int)nodo.GetValue("IdMenu");
                    infoMenu.IdMenuPadre              = (int)nodo.GetValue("IdMenuPadre");
                    infoMenu.DescripcionMenu          = (string)nodo.GetValue("DescripcionMenu");
                    infoMenu.PosicionMenu             = (int)nodo.GetValue("PosicionMenu");
                    infoMenu.Habilitado               = (bool)nodo.GetValue("Habilitado");
                    infoMenu.Tiene_FormularioAsociado = (bool)nodo.GetValue("Tiene_FormularioAsociado");
                    infoMenu.nom_Formulario           = (string)nodo.GetValue("nom_Formulario");
                    infoMenu.nom_Asembly              = (string)nodo.GetValue("nom_Asembly");

                    infoMenu.nivel = (int)nodo.GetValue("nivel");

                    LlamarFormulario();
                    if (nodo.ParentNode != null)
                    {
                        nodo.ParentNode.Selected = true;
                    }
                }
            }
        }
Exemple #2
0
        private void TreeNodeToDataObject <T>(T dataObject, DevExpress.XtraTreeList.Nodes.TreeListNode treeNode)
        {
            Type type = typeof(T);

            foreach (PropertyInfo pi in type.GetProperties())
            {
                if (pi.Name.IndexOf("Col") == 0 && treeNode.GetValue(pi.Name) != DBNull.Value)
                {
                    pi.SetValue(dataObject, treeNode.GetValue(pi.Name), null);
                }
            }
        }
        private void LoadDataObject()
        {
            ITreeListViewHoster treeListHoster = _TreeListHoster;
            IList lstDatas = null;

            try {
                int id = (int)_SortingNode.GetValue(_TreeListHoster.TreeViewCfg.KeyFieldName);
                MB.Util.Model.QueryParameterInfo[] queryParams = new Util.Model.QueryParameterInfo[1];
                queryParams[0] = new Util.Model.QueryParameterInfo(_TreeListHoster.TreeViewCfg.ParentFieldName, id, Util.DataFilterConditions.Equal);
                lstDatas       = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams);
            }
            catch (Exception ex) {
                throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "DefaultTreeListViewForm.GetObjects 出错!");
            }

            if (_BindingSource == null)
            {
                IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas);
                _BindingSource            = new MB.WinBase.Binding.BindingSourceEx();
                _BindingSource.DataSource = bl;
                treeListHoster.CreateTreeListViewDataBinding(trvLstMain, _BindingSource);

                if (trvLstMain.Nodes.Count > 0)
                {
                    trvLstMain.Nodes[0].Expanded = true;
                    trvLstMain.FocusedNode       = trvLstMain.Nodes[0];
                }
            }
            else
            {
                treeListHoster.RefreshTreeListData(trvLstMain, lstDatas);
            }
        }
Exemple #4
0
        public void AddBrother()
        {
            DataRow rowAdd = AddRow();

            DevExpress.XtraTreeList.Nodes.TreeListNode node = this.treeList.FocusedNode;
            if (node != null)
            {
                //rowAdd[BrotherFiledName] = node.GetValue(KeyFieldName) as string;
                rowAdd[ParentFieldName] = node.GetValue(ParentFieldName) as string;
            }
            else
            {
                //rowAdd[BrotherFiledName] = "";
                rowAdd[ParentFieldName] = "root";
            }

            //执行插入操作
            if (InsertRow != null)
            {
                TreeListHelperArgs args = new TreeListHelperArgs();
                args.Row = rowAdd;
                InsertRow(this, args);
                if (args.Result)
                {
                    UpdateTree(rowAdd);
                }
            }
        }
Exemple #5
0
        private void ChangeIPForm_Load(object sender, EventArgs e)
        {
            string myNodeIp = myNode.GetValue("ID").ToString();

            string[] addressSegments = myNodeIp.Split(new char[] { '.' });
            this.spinEdit1.Value = Decimal.Parse(addressSegments[0]);
            this.spinEdit2.Value = Decimal.Parse(addressSegments[1]);
            this.spinEdit3.Value = Decimal.Parse(addressSegments[2]);
            this.spinEdit4.Value = Decimal.Parse(addressSegments[3]);

            //foreach (NodeInfoDS.cpbInfoRow row in myDataset.cpbInfo.Rows)
            //{
            //    if (row.ID == this.richTextBox1.Text && myNode.Level != 2)
            //    {
            //        DevExpress.XtraEditors.XtraMessageBox.Show("名称已经存在,无法修改");
            //        return;
            //    }
            //}
        }
Exemple #6
0
        private void ChangeNodeDesp(string newDespStr)
        {
            try
            {
                if (myNode != null)
                {
                    string dataID = myNode.GetValue("ID").ToString();

                    /// for level 0/1 node, just change ID/Address and ParentID
                    if (myNode.Level < 2)
                    {
                        foreach (NodeInfoDS.cpbInfoRow row in myDataset.cpbInfo.Rows)
                        {
                            if (row.ID == dataID)
                            {
                                row.ID      = newDespStr;
                                row.Address = newDespStr;
                            }

                            // link child to new named node
                            if (row.ParentID == dataID)
                            {
                                row.ParentID = newDespStr;
                            }
                        }
                    }
                    if (myNode.Level == 2)
                    {
                        DataRow[] rows = myDataset.cpbInfo.Select(string.Format("ID = '{0}'", dataID));
                        rows[0]["Address"] = String.Format("({0}){1}", newDespStr, dataID);
                    }
                }

                DevExpress.XtraEditors.XtraMessageBox.Show("修改成功!");
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("修改失败,失败原因:" + ex.Message);
                DialogResult = System.Windows.Forms.DialogResult.Abort;
            }
        }
Exemple #7
0
        static public void TreeNodeToDataObject <T>(T dataObject, DevExpress.XtraTreeList.Nodes.TreeListNode treeNode)
        {
            Type type = typeof(T);

            foreach (PropertyInfo pi in type.GetProperties())
            {
                if (pi.Name.Substring(0, 1) == "y")
                {
                    pi.SetValue(dataObject, treeNode.GetValue(pi.Name), null);
                }
            }
        }
Exemple #8
0
        public void AddChild()
        {
            DataRow rowAdd = AddRow();

            DevExpress.XtraTreeList.Nodes.TreeListNode node = this.treeList.FocusedNode;
            if (node != null)
            {
                rowAdd[ParentFieldName] = node.GetValue(KeyFieldName) as string;
                //rowAdd[BrotherFiledName] = "";  //新加入的节点作为第一个儿子
            }
            else
            {
                MsgBox.Show("请先添加一级节点!");
                return;
            }

            //获取兄弟ID, 为了将新节点变为最后一个儿子

            /*int brotherSortID = 0;
             * //foreach (TreeListNode findNode in node.Nodes)
             * //{
             * //    int nodeSortID = (int)findNode.GetValue(SortIDFiledName);
             * //    if (nodeSortID > brotherSortID && findNode.GetValue(ParentFieldName) == rowAdd[ParentFieldName])
             * //    {
             * //        brotherSortID = nodeSortID;
             * //        rowAdd[BrotherFiledName] = findNode.GetValue(KeyFieldName);
             * //    }
             * //}
             */


            //执行插入操作
            if (InsertRow != null)
            {
                TreeListHelperArgs args = new TreeListHelperArgs();
                args.Row = rowAdd;
                InsertRow(this, args);
                if (args.Result)
                {
                    UpdateTree(rowAdd);
                }
            }
        }