Exemple #1
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindData()
        {
            XmlNodeList            xmlNodeLst       = xmlhelper.Read("datatype");
            List <SysFunctionInfo> functionInfoList = new List <SysFunctionInfo>();

            foreach (XmlNode xn1 in xmlNodeLst)
            {
                SysFunctionInfo functionInfo = new SysFunctionInfo();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;

                // 得到DataTypeInfo节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                functionInfo.Gid          = xnl0.Item(0).InnerText;
                functionInfo.Pgid         = xnl0.Item(1).InnerText;
                functionInfo.Name         = xnl0.Item(2).InnerText;
                functionInfo.FunctionGid  = xnl0.Item(3).InnerText;
                functionInfo.SystemtypeId = xnl0.Item(4).InnerText;
                functionInfo.Seq          = xnl0.Item(5).InnerText;
                functionInfo.lstInfo      = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();

                functionInfoList.Add(functionInfo);
            }

            treelstFunction.KeyFieldName    = "Gid";
            treelstFunction.ParentFieldName = "Pgid";
            treelstFunction.DataSource      = functionInfoList;

            treelstFunction.Columns["lstInfo"].Visible = false;

            treelstFunction.OptionsBehavior.DragNodes = true;

            treelstFunction.ForceInitialize();
            treelstFunction.BestFitColumns();
        }
Exemple #2
0
        /// <summary>
        /// 添加同级节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRoot_Click(object sender, EventArgs e)
        {
            SysFunctionInfo functionInfo = new SysFunctionInfo();

            if (string.Equals(treelstFunction.FocusedNode.GetValue("Pgid").ToString(), Const.Num_MinusOne.ToString()))
            {
                functionInfo.Gid            = Guid.NewGuid().ToString();
                functionInfo.Pgid           = Const.Num_MinusOne.ToString();
                functionInfo.lstInfo        = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();
                treelstFunction.FocusedNode = treelstFunction.AppendNode(functionInfo, null);
                treelstFunction.FocusedNode.SetValue("Gid", functionInfo.Gid);
                treelstFunction.FocusedNode.SetValue("Pgid", functionInfo.Pgid);
                treelstFunction.FocusedNode.SetValue("lstInfo", functionInfo.lstInfo);
            }
            else
            {
                functionInfo.Gid            = Guid.NewGuid().ToString();
                functionInfo.Pgid           = treelstFunction.FocusedNode.GetValue("Pgid").ToString();
                functionInfo.lstInfo        = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();
                treelstFunction.FocusedNode = treelstFunction.AppendNode(functionInfo, treelstFunction.FocusedNode.ParentNode);
                treelstFunction.FocusedNode.SetValue("Gid", functionInfo.Gid);
                treelstFunction.FocusedNode.SetValue("Pgid", functionInfo.Pgid);
                treelstFunction.FocusedNode.SetValue("lstInfo", functionInfo.lstInfo);
            }
            xmlhelper.InsertElement("datatype", "item", string.Format(xmlModel, functionInfo.Gid, functionInfo.Pgid, functionInfo.Name, functionInfo.FunctionGid, functionInfo.SystemtypeId, functionInfo.Seq));

            xmlhelper.Save(false);
        }
Exemple #3
0
        /// <summary>
        /// 添加子节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnAddNodes_Click(object sender, EventArgs e)
        {
            if (treelstFunction.FocusedNode != null)
            {
                SysFunctionInfo functionInfo = new SysFunctionInfo();
                functionInfo.Gid            = Guid.NewGuid().ToString();
                functionInfo.Pgid           = treelstFunction.FocusedNode.GetValue("Gid").ToString();
                functionInfo.lstInfo        = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();
                treelstFunction.FocusedNode = treelstFunction.AppendNode(null, treelstFunction.FocusedNode);
                treelstFunction.FocusedNode.SetValue("Gid", functionInfo.Gid);
                treelstFunction.FocusedNode.SetValue("Pgid", functionInfo.Pgid);

                xmlhelper.InsertElement("datatype", "item", string.Format(xmlModel, functionInfo.Gid, functionInfo.Pgid, functionInfo.Name, functionInfo.FunctionGid, functionInfo.SystemtypeId, functionInfo.Seq));

                xmlhelper.Save(false);
            }
        }
Exemple #4
0
        private void MakeNodel(IList <SysFunctionDTO.Node> root, SysFunctionInfo currentSource
                               , IList <SysFunctionInfo> allSource)
        {
            var node = currentSource.MapTo <SysFunctionDTO.Node>();

            root.Add(node);
            var childList = allSource.Where(c => c.Parent == currentSource.Id);

            if (childList.Count() > 0)
            {
                IList <SysFunctionDTO.Node> child = new List <SysFunctionDTO.Node>();
                node.children = child;
                foreach (var item in childList)
                {
                    MakeNodel(child, item, allSource);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (treelstFunction.Nodes.Count != Const.Num_Zero)
            {
                if (MessageDxUtil.ShowYesNoAndTips("系统功能有原始数据,此次导入会清空原始数据,是否继续?") == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            string importFile = FileDialogHelper.OpenExcel(false);

            if (!string.IsNullOrEmpty(importFile))
            {
                // 判断文件是否被占用
                if (FileUtil.FileIsUsing(importFile))
                {
                    MessageDxUtil.ShowWarning(string.Format("文件[{0}]被占用,请先关闭文件后再重试!", importFile));
                    return;
                }

                DataTable dt = MyXlsHelper.Import(importFile, "系统功能", 2, 1);
                List <SysFunctionInfo> lstsysFunctionInfo = new List <SysFunctionInfo>();

                // 如果没有结果集就不在继续
                if (dt == null)
                {
                    return;
                }

                Int32         addRows      = 0;
                List <String> pushFunction = new List <string>();
                pushFunction.Add("-1");

                // 先清除全部节点
                Int32 rowCount = xmlhelper.Read("datatype").Count;
                for (Int32 i = 0; i < rowCount; i++)
                {
                    xmlhelper.DeleteByPathNode("datatype/item");
                    xmlhelper.Save(false);
                }

                for (Int32 i = 0; i < dt.Rows.Count; i++)
                {
                    var sysFunctionInfo = new SysFunctionInfo();
                    sysFunctionInfo.Gid          = Guid.NewGuid().ToString();
                    sysFunctionInfo.Pgid         = pushFunction.Last <string>();
                    sysFunctionInfo.Name         = dt.Rows[i][0].ToString().TrimStart('﹂');
                    sysFunctionInfo.FunctionGid  = dt.Rows[i][1].ToString();
                    sysFunctionInfo.SystemtypeId = dt.Rows[i][2].ToString();
                    sysFunctionInfo.Seq          = dt.Rows[i][3].ToString();
                    sysFunctionInfo.lstInfo      = new Dictionary <string, DevExpress.XtraEditors.DXErrorProvider.ErrorInfo>();

                    if ((i + 1) < dt.Rows.Count && dt.Rows[i][0].ToString().LastIndexOf("﹂") < dt.Rows[i + 1][0].ToString().LastIndexOf("﹂"))
                    {
                        pushFunction.Add(sysFunctionInfo.Gid);
                    }

                    // 返回到了某个父节点
                    if ((i + 1) < dt.Rows.Count && dt.Rows[i][0].ToString().LastIndexOf("﹂") > dt.Rows[i + 1][0].ToString().LastIndexOf("﹂"))
                    {
                        // 需要多次弹出操作
                        for (Int32 j = 0; j < (dt.Rows[i][0].ToString().LastIndexOf("﹂") - dt.Rows[i + 1][0].ToString().LastIndexOf("﹂")); j++)
                        {
                            pushFunction.RemoveAt(pushFunction.Count - 1);
                        }
                    }

                    addRows++;

                    lstsysFunctionInfo.Add(sysFunctionInfo);
                    xmlhelper.InsertElement("datatype", "item", string.Format(xmlModel, sysFunctionInfo.Gid, sysFunctionInfo.Pgid, sysFunctionInfo.Name, sysFunctionInfo.FunctionGid, sysFunctionInfo.SystemtypeId, sysFunctionInfo.Seq));
                    xmlhelper.Save(false);
                }

                treelstFunction.DataSource = lstsysFunctionInfo;
                treelstFunction.Refresh();
                ClearValidate();
                treelstFunction.ForceInitialize();
                treelstFunction.BestFitColumns();

                MessageDxUtil.ShowTips(string.Format("成功导入功能数据{0}条数据", addRows));
            }
        }