Exemplo n.º 1
0
        private static PropertyNodeItem GetNodeItem(XZDM xzdm)
        {
            PropertyNodeItem item = new PropertyNodeItem();

            if (xzdm.DJZQDM.Length == 14)
            {
                item.DisplayName = xzdm.Zu;
            }
            else if (xzdm.DJZQDM.Length == 12)
            {
                item.DisplayName = xzdm.Cun;
            }
            else if (xzdm.DJZQDM.Length == 9)
            {
                item.DisplayName = xzdm.XiangZheng;
            }
            else if (xzdm.DJZQDM.Length == 6)
            {
                item.DisplayName = xzdm.Shi;
            }

            item.data = xzdm;
            item.Name = xzdm.DJZQDM;
            item.data = xzdm;
            return(item);
        }
Exemplo n.º 2
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            var c = tvProperties.SelectedItem as PropertyNodeItem;

            if (c == null)
            {
                c = new PropertyNodeItem();
                if (MessageAlert.Alter("是否添加顶级部门!"))
                {
                    c.id = 0;
                }
                else
                {
                    MessageAlert.Alert("请选则上级部门");
                    return;
                }
            }


            winDepartment wd = new winDepartment(c.id, c.id, true);

            wd.ShowDialog();
            this.tvProperties.ItemsSource = null;
            lt.TreeLoad();
            this.dataGrid1.ItemsSource = GetDepartmentModel();
        }
Exemplo n.º 3
0
        public void TreeLoad()
        {
            //_treeview.Items.Clear();//加载根节点前先清除Treeview控件项
            List <PropertyNodeItem> itemList = new List <PropertyNodeItem>();
            DataTable dt = dtd.ToDatatable(); // webDict.GetArticles();

            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }
            DataView dv = dt.DefaultView;

            dv.RowFilter = "ParentId=0";
            for (int i = 0; i < dv.Count; i++)
            {
                PropertyNodeItem node = new PropertyNodeItem()
                {
                    DisplayName = dv[i].Row["title"].ToString(),
                    Name        = dv[i].Row["title"].ToString(),
                    id          = Convert.ToInt32(dv[i].Row["id"].ToString()),
                    parentId    = Convert.ToInt32(dv[i].Row["ParentId"].ToString()),
                    IsExpanded  = true,
                    Icon        = "/LongTie.Nlbs;component/Images/department.png"
                };
                int id  = Convert.ToInt32(dv[i]["id"].ToString());
                int pid = Convert.ToInt32(dv[i]["ParentId"].ToString());
                ForeachPropertyNode(node, id);
                itemList.Add(node);
            }

            this._treeview.ItemsSource = itemList;
        }
Exemplo n.º 4
0
        //无限接循环子节点添加到根节点下面
        private void ForeachPropertyNode(PropertyNodeItem node, int pid)
        {
            DataTable dtDict = dtd.ToDatatable();// webDict.GetArticles();
            DataView  dvDict = dtDict.DefaultView;

            dvDict.RowFilter = " ParentId=" + pid;

            if (dvDict.Count > 0)
            {
                foreach (DataRowView view in dvDict)
                {
                    int              id            = Convert.ToInt32(view["id"].ToString());
                    string           name          = view["title"].ToString();
                    int              parentId      = Convert.ToInt32(view["ParentId"].ToString());
                    PropertyNodeItem childNodeItem = new PropertyNodeItem()
                    {
                        DisplayName = name,
                        Name        = name,
                        id          = id,
                        parentId    = parentId,
                        IsExpanded  = false,
                        Icon        = "/LongTie.Nlbs;component/Images/department.png"
                    };
                    ForeachPropertyNode(childNodeItem, id);
                    node.Children.Add(childNodeItem);
                }
            }
        }
Exemplo n.º 5
0
        private IJsonTreeNode BuildNode(PropertyNodeItem root, IJsonTreeNode parent)
        {
            TreeNode node = new TreeNode(
                root.JsonName,
                root.EntityName,
                root.DisplayName,
                parent,
                root.MultiReleationShip,
                root.BuildJson,
                root.Selectable,
                root.VirtualNode
                );

            foreach (PropertyNodeItem n in root.Childs)
            {
                node.ChildNodes.Add(n.JsonName, BuildNode(n, node));
            }

            node.Parent = parent;
            node.Sql    = new CustomizedSqlDescriber(
                root.HasCustomizedSql,
                root.CustomizedSql,
                root.CustomizedSqlParameters, node);
            return(node);
        }
Exemplo n.º 6
0
            private List <PropertyNodeItem> ShowTreeView()
            {
                SqlConnection mycon = new SqlConnection(ConnectString.Cstr);         //创建SQL连接对象

                mycon.Open();                                                        //打开
                IList <string>          tablenames = GetTableName.GetTableNames(mycon);
                List <PropertyNodeItem> itemList1  = new List <PropertyNodeItem>();
                {
                    for (int i = 0; i < tablenames.Count(); i++)
                    {
                        PropertyNodeItem temp1 = new PropertyNodeItem();
                        temp1.Name = tablenames[i]; //https://bbs.csdn.net/topics/391542725?page=1

                        //temp[i].Name = tablenames[i];
                        IList <string> tablecolumns = GetColumnName.GetColumnNames(mycon, tablenames[i]);
                        for (int t = 0; t < tablecolumns.Count(); t++)
                        {
                            PropertyNodeItem ctemp = new PropertyNodeItem();
                            ctemp.Name = tablecolumns[t];
                            temp1.Children.Add(ctemp);
                        }
                        itemList1.Add(temp1);
                    }
                    return(itemList1);
                }
            }
Exemplo n.º 7
0
        /// <summary>
        /// 递归填充
        /// </summary>
        /// <param name="root"></param>
        /// <param name="detial"></param>
        /// <returns></returns>
        private PropertyNodeItem FillItems(IJsonTreeNode root, JsonEntityDetial detial)
        {
            PropertyNodeItem item = PropertyNodeItem.Default;

            item.DisplayName             = root.DisplayName;
            item.JsonName                = root.JsonNodeName;
            item.EntityName              = root.DbName;
            item.MultiReleationShip      = root.MultiRelated;
            item.HasChildren             = root.ChildNodes.Count != 0;
            item.BuildJson               = root.BuildSingleFile;
            item.Selectable              = root.Selectable;
            item.HasCustomizedSql        = root.Sql.HasCustomizeSQLString;
            item.CustomizedSql           = root.Sql.CustomizeSQLString;
            item.CustomizedSqlParameters = root.Sql.Params?.ToString();
            item.VirtualNode             = root.IsSelectionParameter;
            item.IsExpanded              = root.Parent == null;

            foreach (IJsonTreeNode n in root.ChildNodes.Values)
            {
                var i = FillItems(n, detial);
                i.Parent = item;
                item.Childs.Add(i);
            }
            return(item);
        }
Exemplo n.º 8
0
        private void Btn_DelExEntity_Click(object sender, RoutedEventArgs e)
        {
            PropertyNodeItem i = Tree_Export.SelectedItem as PropertyNodeItem;

            if (i.Parent != null)
            {
                i.Parent.Childs.Remove(i);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 从选项建立新设置
        /// </summary>
        /// <param name="root"></param>
        /// <param name="constr"></param>
        /// <returns></returns>
        private JsonEntityDetial BuildSetting(PropertyNodeItem root, String constr)
        {
            JsonEntityDetial detial = new JsonEntityDetial();

            detial.DbConnectStr = constr;
            foreach (PropertyNodeItem i in root.Childs)
            {
                detial.roots.Add(BuildNode(i, null));
            }
            return(detial);
        }
Exemplo n.º 10
0
        private void getTree()
        {
            CatalogTreeItems = new ObservableCollection <PropertyNodeItem>();
            PropertyNodeItem node1 = new PropertyNodeItem("检测数据");

            node1.IsExpanded = true;
            PropertyNodeItem node11 = new PropertyNodeItem("数据列表");

            node11.IsExpanded = true;
            CatalogTreeItems.Add(node1);
            node1.AddChild(node11);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_ImNewImEntity_Click(object sender, RoutedEventArgs e)
 {
     if (Tree_Import.SelectedItem != null)
     {
         PropertyNodeItem i = Tree_Import.SelectedItem as PropertyNodeItem;
         var j = PropertyNodeItem.Default;
         j.Parent = i;
         i.Childs.Add(j);
         i.IsExpanded       = true;
         i.HasCustomizedSql = false;
         Tree_Import.Focus();
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// 保存记录并写入文件
        /// </summary>
        private void Save()
        {
            PropertyNodeItem importRoot = (Tree_Import.ItemsSource as ObservableCollection <PropertyNodeItem>)[0];
            PropertyNodeItem exportRoot = (Tree_Export.ItemsSource as ObservableCollection <PropertyNodeItem>)[0];
            String           exdbStr    = Txt_ExportDbConnectStr.Text;
            String           imdbStr    = Txt_ImportDbConnectStr.Text;

            Default.UpdateSetting(Txt_UsernameColumnName.Text,
                                  Txt_PasswordColumnName.Text,
                                  Txt_UserDbTableName.Text,
                                  Txt_UserDbConnectStr.Text,
                                  BuildSetting(exportRoot, exdbStr),
                                  BuildSetting(importRoot, imdbStr),
                                  Txt_DbConnectStr.Text);
            MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 13
0
        private static PropertyNodeItem GetAllNodeItem(XZDM xzdm)
        {
            PropertyNodeItem root  = GetNodeItem(xzdm, 6);
            PropertyNodeItem root1 = GetNodeItem(xzdm, 9);
            PropertyNodeItem root2 = GetNodeItem(xzdm, 12);
            PropertyNodeItem root3 = GetNodeItem(xzdm, 14);

            if (root3 != null)
            {
                root3.Parent = root2;
            }
            if (root2 != null)
            {
                root2.Parent = root1;
            }
            if (root1 != null)
            {
                root1.Parent = root;
            }

            return(root);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 多部件是合并的,指向同一个行政代码
 /// </summary>
 /// <returns></returns>
 public IList <JTSYQ> GetSelectJTSYQS()
 {
     return(JTSYQCustom.GetSelectJTSYQ(PropertyNodeItem.FindSelect(tvProperty.Items)));
 }
Exemplo n.º 15
0
 public IList <PropertyNodeItem> GetSelectItem()
 {
     return(PropertyNodeItem.FindSelect(tvProperty.Items));
 }
Exemplo n.º 16
0
        private void TextBlock_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PropertyNodeItem current = (sender as TextBlock).DataContext as PropertyNodeItem;

            current.SetIsSelectAll(!current.IsSelected.Value);
        }
Exemplo n.º 17
0
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            PropertyNodeItem current = (sender as CheckBox).DataContext as PropertyNodeItem;

            current.SetIsSelectAll(current.IsSelected.Value);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 只适用于只有一个根节点
        /// </summary>
        /// <param name="xzdms"></param>
        /// <returns></returns>

        /* public static IList<PropertyNodeItem> XZDMToItem(IList<XZDM> xzdms)
         * {
         *   OrderByBM(xzdms);
         *   List<PropertyNodeItem> list = new List<PropertyNodeItem>();
         *   if (xzdms.Count == 0)
         *   {
         *       return list;
         *   }
         *
         *   XZDM xzdm1 = xzdms[0];
         *   PropertyNodeItem item1 = GetNodeItem(xzdm1,6);
         *   list.Add(item1);
         *   Dictionary<string, PropertyNodeItem> dic = new Dictionary<string, PropertyNodeItem>();
         *   dic.Add(item1.Name, item1);
         *    PropertyNodeItem parent;
         *   for (int a = 0; a < xzdms.Count; a++)
         *   {
         *       XZDM xzdm = xzdms[a];
         *       string bm = xzdm.DJZQDM;
         *       PropertyNodeItem child = GetNodeItem(xzdm);
         *       if (bm.Length == 14)
         *       {
         *
         *           if (dic.TryGetValue(bm.Substring(0, 12), out parent))
         *           {
         *
         *               if(!dic.ContainsKey(bm))
         *               {
         *                   parent.AddChild(child);
         *                   dic.Add(bm, child);
         *               }
         *
         *           }
         *       }
         *       else
         *       if (bm.Length == 12)
         *       {
         *           if (dic.TryGetValue(bm.Substring(0, 9), out parent))
         *           {
         *
         *               if (!dic.ContainsKey(bm))
         *               {
         *                   parent.AddChild(child);
         *                   dic.Add(bm, child);
         *               }
         *           }
         *       }
         *       else
         *        if (bm.Length == 9)
         *       {
         *          if (dic.TryGetValue(bm.Substring(0, 6), out parent))
         *           {
         *
         *               if (!dic.ContainsKey(bm))
         *               {
         *                   parent.AddChild(child);
         *                   dic.Add(bm, child);
         *               }
         *           }
         *
         *       }
         *       else if (bm.Length == 6)
         *       {
         *           if (dic.TryGetValue(bm.Substring(0, 6), out parent))
         *           {
         *
         *
         *               if (!dic.ContainsKey(bm))
         *               {
         *                   parent.AddChild(child);
         *                   dic.Add(bm, child);
         *               }
         *           }
         *       }
         *   }
         *   return list;
         * }*/

        /// <summary>
        /// 只适用于只有一个根节点
        /// </summary>
        /// <param name="xzdms"></param>
        /// <returns></returns>
        public static IList <PropertyNodeItem> XZDMToItem(IList <XZDM> xzdms)
        {
            OrderByBM(xzdms);
            List <PropertyNodeItem> list = new List <PropertyNodeItem>();

            if (xzdms.Count == 0)
            {
                return(list);
            }

            XZDM             xzdm1 = xzdms[0];
            PropertyNodeItem item1 = GetNodeItem(xzdm1, 6);

            list.Add(item1);
            Dictionary <string, PropertyNodeItem> dic = new Dictionary <string, PropertyNodeItem>();

            dic.Add(item1.Name, item1);
            PropertyNodeItem parent;

            for (int a = 0; a < xzdms.Count; a++)
            {
                XZDM             xzdm  = xzdms[a];
                string           bm    = xzdm.DJZQDM;
                PropertyNodeItem child = GetNodeItem(xzdm);
                if (bm.Length == 14)
                {
                    if (dic.TryGetValue(bm.Substring(0, 12), out parent))
                    {
                        if (!dic.ContainsKey(bm))
                        {
                            parent.AddChild(child);
                            dic.Add(bm, child);
                        }
                    }
                }
                else
                if (bm.Length == 12)
                {
                    if (dic.TryGetValue(bm.Substring(0, 9), out parent))
                    {
                        if (!dic.ContainsKey(bm))
                        {
                            parent.AddChild(child);
                            dic.Add(bm, child);
                        }
                    }
                }
                else
                if (bm.Length == 9)
                {
                    if (dic.TryGetValue(bm.Substring(0, 6), out parent))
                    {
                        if (!dic.ContainsKey(bm))
                        {
                            parent.AddChild(child);
                            dic.Add(bm, child);
                        }
                    }
                }
                else if (bm.Length == 6)
                {
                    if (dic.TryGetValue(bm.Substring(0, 6), out parent))
                    {
                        if (!dic.ContainsKey(bm))
                        {
                            parent.AddChild(child);
                            dic.Add(bm, child);
                        }
                    }
                }
            }
            return(list);
        }