/// <summary>
        /// 初始化treeView
        /// </summary>
        void InitTreeView()
        {
            // 清除树节点
            this.treeView.Nodes.Clear();

            // 添加一个根节点
            TreeNode parentNode = new TreeNode();

            parentNode.Name = "仓库";
            parentNode.Text = "仓库";

            treeView.Nodes.Add(parentNode);

            List <MaterialTypeData> depotInfo;

            // 获取所有部门信息
            if (!m_depotServer.GetAllMaterialType(out depotInfo, out m_err))
            {
                return;
            }

            // 克隆一份
            m_listDepotInfo = m_depotServer.Clone(depotInfo);

            // 是否是叶子节点
            bool isLeaf = false;

            for (int i = 0; i < depotInfo.Count; i++)
            {
                TreeNode node = new TreeNode();

                UpdateTreeNode(node, depotInfo[i]);

                isLeaf = (bool)depotInfo[i].IsEnd;

                parentNode.Nodes.Add(node);

                depotInfo.RemoveAt(i);

                i--;

                if (!isLeaf)
                {
                    BuildTree(node, depotInfo);
                }
            }

            TreeNode newNode = new TreeNode();

            newNode.Name = "其他";
            newNode.Text = "其他";

            treeView.Nodes[0].Nodes.Add(newNode);

            treeView.ExpandAll();
        }
Example #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public FormDepotType()
        {
            InitializeComponent();

            IQueryable <View_S_Depot> depot = null;
            string error = null;

            if (m_depotServer.GetAllMaterialType(out depot, out error))
            {
                InitTreeView(depot.ToList());
            }

            string[] dataItems = m_autoCompleteSource.ToArray();

            cmbCode.DataSource         = m_autoCompleteSource;
            cmbCode.AutoCompleteSource = AutoCompleteSource.ListItems;

            PositioningNode(cmbCode.Text);
        }
        /// <summary>
        /// 构建材料类别树
        /// </summary>
        /// <param name="treeView">要构建的树</param>
        /// <returns>成功返回true</returns>
        static public bool BuildTree(TreeView treeView)
        {
            // 仓库信息服务
            IMaterialTypeServer depotServer = ServerModuleFactory.GetServerModule <IMaterialTypeServer>();

            try
            {
                IQueryable <View_S_Depot> depot = null;
                string error = null;

                if (depotServer.GetAllMaterialType(out depot, out error))
                {
                    InitTreeView(treeView, depot.ToList());
                }

                return(true);
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
                return(false);
            }
        }
        /// <summary>
        /// 初始化treeView
        /// </summary>
        void InitTreeView()
        {
            // 清除树节点
            this.treeView.Nodes.Clear();

            // 添加一个根节点
            TreeNode parentNode = new TreeNode();

            parentNode.Name = "仓库";
            parentNode.Text = "仓库";

            treeView.Nodes.Add(parentNode);

            List <MaterialTypeData> depotInfo;

            // 获取所有部门信息
            if (!m_depotServer.GetAllMaterialType(out depotInfo, out m_err))
            {
                return;
            }

            if (BasicInfo.ListRoles.Contains(CE_RoleEnum.营销仓库管理员.ToString()))
            {
                for (int i = 0; i < depotInfo.Count; i++)
                {
                    if (depotInfo[i].MaterialTypeCode.Substring(0, 2) != "YX")
                    {
                        depotInfo.RemoveAt(i);
                        i--;
                    }
                }
            }
            else if (BasicInfo.ListRoles.Contains(CE_RoleEnum.制造仓库管理员.ToString()))
            {
                for (int i = 0; i < depotInfo.Count; i++)
                {
                    if (depotInfo[i].MaterialTypeCode.Substring(0, 2) == "YX")
                    {
                        depotInfo.RemoveAt(i);
                        i--;
                    }
                }
            }

            // 克隆一份
            m_listDepotInfo = m_depotServer.Clone(depotInfo);

            // 是否是叶子节点
            bool isLeaf = false;

            for (int i = 0; i < depotInfo.Count; i++)
            {
                TreeNode node = new TreeNode();

                UpdateTreeNode(node, depotInfo[i]);

                isLeaf = (bool)depotInfo[i].IsEnd;

                parentNode.Nodes.Add(node);

                depotInfo.RemoveAt(i);

                i--;

                if (!isLeaf)
                {
                    BuildTree(node, depotInfo);
                }
            }

            TreeNode newNode = new TreeNode();

            newNode.Name = "其他";
            newNode.Text = "其他";

            treeView.Nodes[0].Nodes.Add(newNode);

            treeView.ExpandAll();
        }
        /// <summary>
        /// 初始化treeView
        /// </summary>
        void InitTreeView()
        {
            // 清除树节点
            this.treeView.Nodes.Clear();

            // 添加一个根节点
            TreeNode parentNode = new TreeNode();

            parentNode.Name = "仓库";
            parentNode.Text = "仓库";

            treeView.Nodes.Add(parentNode);



            List <MaterialTypeData> depotInfo;

            // 获取所有仓库信息
            if (!m_depotServer.GetAllMaterialType(out depotInfo, out m_err))
            {
                MessageDialog.ShowErrorMessage(m_err);
                return;
            }

            int len = 0;

            for (int i = 0; i < depotInfo.Count; i++)
            {
                len = depotInfo[i].MaterialTypeCode.Length;
                var result = m_depotForPersonnel.Find(p => p.类型ID.Length >= len &&
                                                      p.类型ID.Substring(0, len) == depotInfo[i].MaterialTypeCode);

                if (result == null)
                {
                    depotInfo.RemoveAt(i--);
                }
            }

            // 克隆一份
            m_listDepotInfo = m_depotServer.Clone(depotInfo);

            // 是否是叶子节点
            bool isLeaf = false;

            for (int i = 0; i < depotInfo.Count; i++)
            {
                TreeNode node = new TreeNode();

                UpdateTreeNode(node, depotInfo[i]);

                isLeaf = (bool)depotInfo[i].IsEnd;

                parentNode.Nodes.Add(node);

                depotInfo.RemoveAt(i);

                i--;

                if (!isLeaf)
                {
                    BuildTree(node, depotInfo);
                }
            }

            treeView.ExpandAll();
        }