/// <summary>
        /// select process procedure model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            List <ProcessCardModule> processCardModuleList
                = new List <ProcessCardModule>();

            ProcessPlanningModuleBLL processPlanningModuleBLL = new ProcessPlanningModuleBLL();

            List <Guid> processPlanningModuleIdList = new List <Guid>();



            try
            {
                ///根据规程模板Id,得到卡片模版的Id
                foreach (var kv in selecedProcessProcedureDic)
                {
                    processPlanningModuleIdList.Add(kv.Key);
                }

                /// 得到选中的卡片模板列表
                processCardModuleList = ProcessPlanningModuleBLL
                                        .GetProcessCardModuleListByProcessPlanningModuleIds(processPlanningModuleIdList);

                NewProcessProcedure.SetCklProcessCardModuleName(processCardModuleList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            /// Close Current window and show Process Procedure TreeView
            Close();
        }
        /// <summary>
        /// Add ProcessPlanning module
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProcessPlanningModule processPlanningModule = new ProcessPlanningModule();

            processPlanningModule.BusinessId = ProcessPlanningMod.BusinessId;
            processPlanningModule.BType      = BusinessType.Folder;
            processPlanningModule.Name       = txtBusinessName.Text.Trim();
            processPlanningModule.ParentNode = ProcessPlanningMod.ParentNode;
            processPlanningModule.ProcessPlanningModuleId = Guid.NewGuid();

            try
            {
                int currentNode
                    = ProcessPlanningModuleBLL.AddProcessPlanningModule(processPlanningModule);

                NewNodeNameDic
                    = new Dictionary <string, ProcessPlanningModule>()
                    {
                    { txtBusinessName.Text.Trim(), processPlanningModule }
                    };
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = DialogResult.Cancel;
            }
        }
        /// <summary>
        /// 获取规程模版
        /// </summary>
        /// <param name="nodeName"></param>
        /// <returns></returns>
        private List <Model.ProcessPlanningModule> GetPlaningTreeData(string nodeName)
        {
            List <Model.ProcessPlanningModule> processPlanningModuleList =
                ProcessPlanningModuleBLL.GetProcesPlanningModuleList(int.Parse(nodeName));

            return(processPlanningModuleList);
        }
        /// <summary>
        /// get data from dic or database
        /// </summary>
        /// <param name="nodeName"></param>
        /// <returns></returns>
        public List <Model.ProcessPlanningModule> GetTreeData(string nodeName)
        {
            List <Model.ProcessPlanningModule> processPlanningModuleList = processPlanningModuleList =
                ProcessPlanningModuleBLL.GetProcesPlanningModuleList(int.Parse(nodeName));

            if (!processPlanningModuleDic.ContainsKey(nodeName))
            {
                processPlanningModuleDic.Add(nodeName, processPlanningModuleList);
            }
            else
            {
                processPlanningModuleDic[nodeName] = processPlanningModuleList;
            }
            //else
            //{
            //    processPlanningModuleList = processPlanningModuleDic[nodeName];

            //    var items = from planningModule in processPlanningModuleList
            //                orderby planningModule.Sort ascending
            //                select planningModule;

            //    processPlanningModuleList = new List<ProcessPlanningModule>();
            //    foreach (var item in items)
            //    {
            //        processPlanningModuleList.Add(item);
            //    }
            //}

            return(processPlanningModuleList);
        }
        /// <summary>
        /// 事件说明:双击打开对应节点的工艺规程模板
        /// 作    者:jason.tang
        /// 完成时间:2013-01-21
        /// </summary>
        private void tvProcessPlanningModule_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node != null && e.Node.Tag != null)
            {
                if (e.Node.ImageKey != "planning")
                {
                    return;
                }

                WeifenLuo.WinFormsUI.Docking.DockContent content = MainFrm.mainFrm.CheckContentIsOpened(e.Node.Tag.ToString().Substring(0, e.Node.Tag.ToString().IndexOf("@")));
                if (content != null)
                {
                    MainFrm.mainFrm.OpenModule(content);
                    return;
                }

                List <ProcessCardModule> listProcessCardModule =
                    ProcessPlanningModuleBLL.GetProcesCardModuleList(int.Parse(e.Node.Tag.ToString().Substring(e.Node.Tag.ToString().IndexOf("@") + 1)));

                if (listProcessCardModule.Count > 0)
                {
                    ProcessPlanningModuleDetailFrm form = new ProcessPlanningModuleDetailFrm();
                    form.Name     = e.Node.Tag.ToString().Substring(0, e.Node.Tag.ToString().IndexOf("@"));
                    form.FormText = string.Format("{0}-{1}", e.Node.Text, e.Node.Tag.ToString().Substring(e.Node.Tag.ToString().IndexOf("@")));
                    form.ProcessPlanningModules = listProcessCardModule;
                    MainFrm.mainFrm.OpenPlanningModule(form);
                }
            }
        }
        /// <summary>
        /// bind process procedure to datagridview
        /// </summary>
        /// <param name="name"></param>
        private void BindProcessProcedure(string name)
        {
            try
            {
                List <ProcessPlanningModule> processPlanningModuleList
                    = ProcessPlanningModuleBLL.GetProcesPlanningModuleListByName(name);

                dgvProcessProcedure.DataSource = processPlanningModuleList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Get card manager list
        /// </summary>
        /// <param name="nodeName"></param>
        /// <returns></returns>
        public void LoadTreeData()
        {
            //if (tvProcessPlanningModule.InvokeRequired)
            //{
            //    LoadTreeEventHandler loadtreeEventHandler = new LoadTreeEventHandler(() =>
            //    {
            try
            {
                List <Model.ProcessPlanningModule> processPlanningModuleList =
                    ProcessPlanningModuleBLL.GetProcesPlanningModuleList(0);

                //if (processPlanningModuleList.Count <= 0) return;
                //如果数据库内没有工艺规程模版记录,则默认增加一条root记录
                if (processPlanningModuleList.Count <= 0)
                {
                    processPlanningModuleList = new List <ProcessPlanningModule>();
                    ProcessPlanningModule planningModule = new ProcessPlanningModule();
                    planningModule.BusinessId = Guid.NewGuid();
                    planningModule.Name       = "工艺规程模板";
                    planningModule.BType      = 0;
                    planningModule.ParentNode = 0;
                    planningModule.Sort       = 1;

                    int currentNode = ProcessPlanningModuleBLL.AddProcessPlanningModule(planningModule);

                    planningModule.CurrentNode = currentNode;
                    processPlanningModuleList.Add(planningModule);
                }

                Model.ProcessPlanningModule processPlanningModule = processPlanningModuleList[0];

                TreeNode root = new TreeNode();
                root.Text     = processPlanningModule.Name;
                root.Tag      = processPlanningModule.BusinessId + "@" + processPlanningModule.CurrentNode.ToString();
                root.ImageKey = "folder";
                root.Name     = processPlanningModule.Sort.ToString(); //processPlanningModule.CurrentNode.ToString();
                root.Expand();

                ShowChildNode(root);

                tvProcessPlanningModule.Nodes.Add(root);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //});
            //tvProcessPlanningModule.BeginInvoke(loadtreeEventHandler, new object[] { });
            //}
        }
Exemple #8
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (selecedCardModuleNameIdDic.Count <= 0)
            {
                this.DialogResult = DialogResult.Cancel;
            }
            else
            {
                List <ProcessPlanningModule> _processCardModuleList = new List <ProcessPlanningModule>();
                try
                {
                    List <ProcessPlanningModule> listPlanningModules = ProcessPlanningModuleBLL.GetProcesPlanningModuleList(_processPlanningMod.ParentNode);
                    int sort = listPlanningModules.Count + 1;

                    /// add process planning module
                    foreach (var kv in selecedCardModuleNameIdDic)
                    {
                        ProcessPlanningModule p = new ProcessPlanningModule();
                        p.ProcessPlanningModuleId = Guid.NewGuid();
                        p.BType      = BusinessType.Card;
                        p.ParentNode = ProcessPlanningMod.ParentNode;
                        p.Name       = kv.Value;
                        p.BusinessId = new Guid(kv.Key);
                        p.Sort       = sort;

                        _processCardModuleList.Add(p);

                        sort++;
                    }

                    ProcessPlanningModuleBLL.AddProcessPlanningModule(_processCardModuleList);

                    Dictionary <string, ProcessPlanningModule> pDic = new Dictionary <string, ProcessPlanningModule>();
                    foreach (ProcessPlanningModule p in _processCardModuleList)
                    {
                        pDic.Add(p.Name, p);
                    }

                    ProcessPlanningModuleDic = pDic;

                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    this.DialogResult = DialogResult.Cancel;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// load process card module list
        /// defalut 100 row
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddProcessCardModuleFrm_Load(object sender, EventArgs e)
        {
            try
            {
                List <ProcessCardModule> processCardModuleList
                    = ProcessCardModuleBLL.GetDefaultProcessCardList();
                this.dgvModuleCardList.AutoGenerateColumns = false;
                this.dgvModuleCardList.DataSource          = processCardModuleList;

                procesPlanningModuleList = ProcessPlanningModuleBLL.GetProcesPlanningModuleList(_processPlanningMod.ParentNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 加载规程模版卡片
        /// </summary>
        private void LoadPlanningTreeData()
        {
            try
            {
                List <Model.ProcessPlanningModule> processPlanningModuleList =
                    ProcessPlanningModuleBLL.GetProcesPlanningModuleList(0);

                //if (processPlanningModuleList.Count <= 0) return;
                //如果数据库内没有工艺规程模版记录,则默认增加一条root记录
                if (processPlanningModuleList.Count <= 0)
                {
                    processPlanningModuleList = new List <Model.ProcessPlanningModule>();
                    Model.ProcessPlanningModule planningModule = new Model.ProcessPlanningModule();
                    planningModule.BusinessId = Guid.NewGuid();
                    planningModule.Name       = "工艺规程模板";
                    planningModule.BType      = 0;
                    planningModule.ParentNode = 0;
                    planningModule.Sort       = 1;

                    int currentNode = ProcessPlanningModuleBLL.AddProcessPlanningModule(planningModule);

                    planningModule.CurrentNode = currentNode;
                    processPlanningModuleList.Add(planningModule);
                }

                Model.ProcessPlanningModule processPlanningModule = processPlanningModuleList[0];

                TreeNode root = new TreeNode();
                root.Text     = processPlanningModule.Name;
                root.Tag      = processPlanningModule.BusinessId;
                root.ImageKey = "folder";
                root.Name     = processPlanningModule.CurrentNode.ToString();
                root.Expand();

                ShowPlanningChildNode(root);

                tvProcessPlanningModule.Nodes.Add(root);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 方法说明:根据BusinessId删除模版或文件夹
        /// 作      者:jason.tang
        /// 完成时间:2013-07-24
        /// </summary>
        /// <param name="Id">业务ID</param>
        private void RemoveTreeNode(TreeNode currentNode)
        {
            if (currentNode == null)
            {
                return;
            }

            int splitIndex = currentNode.Tag.ToString().IndexOf("@");

            Guid businessId = new Guid(currentNode.Tag.ToString().Substring(0, splitIndex));
            bool result     = ProcessPlanningModuleBLL.DeleteBusiness(businessId);

            if (result)
            {
                //Remove oneself Cache
                processPlanningModuleDic.Remove(currentNode.Tag.ToString().Substring(splitIndex + 1));

                List <ProcessPlanningModule> cardList = processPlanningModuleDic[currentNode.Parent.Tag.ToString().Substring(currentNode.Parent.Tag.ToString().IndexOf("@") + 1)];
                var afterCardList = cardList.Where <ProcessPlanningModule>(
                    x => x.CurrentNode.ToString() != currentNode.Tag.ToString().Substring(splitIndex + 1))
                                    .ToList <ProcessPlanningModule>();

                processPlanningModuleDic[currentNode.Parent.Tag.ToString().Substring(currentNode.Parent.Tag.ToString().IndexOf("@") + 1)] = afterCardList;


                if (!string.IsNullOrEmpty(currentNode.Parent.ImageKey))
                {
                    tvProcessPlanningModule.SelectedNode     = currentNode.Parent;
                    tvProcessPlanningModule.SelectedImageKey = currentNode.Parent.ImageKey;
                }
                else
                {
                    tvProcessPlanningModule.SelectedNode = tvProcessPlanningModule.Nodes[0];
                    ///  如果选中的节点为空,默认为卡片
                    tvProcessPlanningModule.SelectedImageKey = tvProcessPlanningModule.Nodes[0].ImageKey;
                }

                //Remove treeview
                tvProcessPlanningModule.Nodes.Remove(currentNode);
                tvProcessPlanningModule.SelectedNode.Expand();
            }
        }
 private void UpdatePlanningModule(string parentNode, string prevParentNode, object businessId)
 {
     ProcessPlanningModuleBLL.UpdatePlanningModuleData(parentNode, prevParentNode, businessId);
 }
        private void tvProcessPlanningModule_DragDrop(object sender, DragEventArgs e)
        {
            //获得拖放中的节点
            TreeNode moveNode   = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
            TreeNode parentNode = moveNode.Parent;

            ///如果该节点不是卡片模版时,则不允许进行拖动
            if (moveNode.SelectedImageKey != "card")
            {
                return;
            }

            //根据鼠标坐标确定要移动到的目标节点
            Point    pt;
            TreeNode targeNode;

            pt        = ((TreeView)(sender)).PointToClient(new Point(e.X, e.Y));
            targeNode = this.tvProcessPlanningModule.GetNodeAt(pt);
            TreeNode targeParent = targeNode.Parent;

            //如果目标节点无子节点则添加为同级节点,反之添加到下级节点的未端
            TreeNode NewMoveNode = (TreeNode)moveNode.Clone();

            int    moveIndex = moveNode.Tag.ToString().IndexOf("@");
            string moveId    = string.Empty;

            if (moveIndex > 0)
            {
                moveId = moveNode.Tag.ToString().Substring(0, moveIndex);
            }

            int    targeIndex = targeNode.Tag.ToString().IndexOf("@");
            string tagId      = string.Empty;

            if (targeIndex > 0)
            {
                tagId = targeNode.Tag.ToString().Substring(0, targeIndex);
            }

            int    parentIndex = parentNode.Tag.ToString().IndexOf("@");
            string parentName  = string.Empty;

            if (parentIndex > 0)
            {
                parentName = parentNode.Tag.ToString().Substring(parentIndex + 1);
            }

            if (targeNode.Parent == moveNode.Parent)
            {
                tvProcessPlanningModule.BeginUpdate();
                ProcessPlanningModuleBLL.ChangeTwoCardSortOrder(moveId, moveNode.Name, tagId, targeNode.Name, parentName);
                parentNode.Nodes.Clear();
                ShowCardModuleByParentCode(parentName, parentNode);
                tvProcessPlanningModule.TreeViewNodeSorter = new Kingdee.CAPP.UI.Common.NodeSorter();
                tvProcessPlanningModule.EndUpdate();

                tvProcessPlanningModule.Focus();
                tvProcessPlanningModule.SelectedNode = targeParent;
                if (tvProcessPlanningModule.SelectedNode != null)
                {
                    tvProcessPlanningModule.SelectedNode.EnsureVisible();
                }

                return;
            }

            object             busiessId      = moveId;
            string             prevParentNode = parentName;
            TreeNodeCollection targeNodes     = null;

            if (targeNode.ImageKey == "card")
            {
                targeNodes = targeNode.Parent.Nodes;
            }
            else if (targeNode.ImageKey == "planning")
            {
                targeNodes = targeNode.Nodes;
            }

            foreach (TreeNode nod in targeNodes)
            {
                if (nod.Tag.ToString().StartsWith(moveId))
                {
                    MessageBox.Show("目标节点下已包含相同的模版,无法移动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            if (targeNode.Nodes.Count == 0)
            {
                if (targeNode.ImageKey == "card")
                {
                    targeNode.Parent.Nodes.Insert(targeNode.Index, NewMoveNode);
                }
                else if (targeNode.ImageKey == "planning")
                {
                    targeNode.Nodes.Insert(targeNode.Index, NewMoveNode);
                    targeNode.Expand();
                }
            }
            else
            {
                targeNode.Nodes.Insert(targeNode.Nodes.Count, NewMoveNode);
            }

            //更新数据库内节点的从属关系
            UpdatePlanningModule(targeNode.Parent.Tag.ToString().Substring(targeNode.Parent.Tag.ToString().IndexOf("@") + 1), prevParentNode, busiessId);

            tvProcessPlanningModule.SelectedNode = NewMoveNode;
            //展开目标节点,便于显示拖放效果
            targeNode.Expand();
            //移除拖放的节点
            moveNode.Remove();

            tvProcessPlanningModule.TreeViewNodeSorter = new Kingdee.CAPP.UI.Common.NodeSorter();

            tvProcessPlanningModule.Focus();
            tvProcessPlanningModule.SelectedNode = targeParent;
            if (tvProcessPlanningModule.SelectedNode != null)
            {
                tvProcessPlanningModule.SelectedNode.EnsureVisible();
            }
        }