private void btnAdd_Click(object sender, EventArgs e)
        {
            TypicalProcess typicalProcess = new TypicalProcess();

            typicalProcess.BusinessId       = Guid.NewGuid();
            typicalProcess.BType            = BusinessType.Folder;
            typicalProcess.Name             = txtBusinessName.Text.Trim();
            typicalProcess.ParentNode       = TypicalProcessMod.ParentNode;
            typicalProcess.TypicalProcessId = Guid.NewGuid();

            try
            {
                int currentNode
                    = TypicalProcessBLL.AddTypicalProcess(typicalProcess);

                NewNodeNameDic
                    = new Dictionary <string, TypicalProcess>()
                    {
                    { txtBusinessName.Text.Trim(), typicalProcess }
                    };
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = DialogResult.Cancel;
            }
        }
Exemple #2
0
        /// <summary>
        /// 方法说明:根据BusinessId删除典型或文件夹
        /// 作      者:jason.tang
        /// 完成时间:2013-07-30
        /// </summary>
        /// <param name="Id">业务ID</param>
        private void RemoveTreeNode(TreeNode currentNode)
        {
            if (currentNode == null)
            {
                return;
            }

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

            if (splitIndex >= 0)
            {
                typicalId = currentNode.Tag.ToString().Substring(0, splitIndex);
            }
            else
            {
                typicalId = currentNode.Tag.ToString();
            }

            bool result = TypicalProcessBLL.DeleteTypicalById(new Guid(typicalId));

            if (result)
            {
                //Remove oneself Cache
                typicalProcessDic.Remove(currentNode.Name.ToString());

                List <TypicalProcess> cardList = typicalProcessDic[currentNode.Parent.Name];
                var afterCardList = cardList.Where <TypicalProcess>(
                    x => x.CurrentNode.ToString() != currentNode.Name)
                                    .ToList <TypicalProcess>();

                typicalProcessDic[currentNode.Parent.Name] = afterCardList;

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

                //Remove treeview
                tvTypicalProcess.Nodes.Remove(currentNode);
                tvTypicalProcess.SelectedNode.Expand();
            }
        }
Exemple #3
0
        private void GetTypicalCategory()
        {
            dt = TypicalProcessBLL.GetTypicalCategory(string.Empty);
            DataRow[] rows  = dt.Select("Type = 4 ");
            DataTable table = dt.Clone();

            foreach (DataRow dr in rows)
            {
                DataRow row = table.NewRow();
                row = dr;
                table.Rows.Add(row.ItemArray);
            }
            dgvTypicalCategory.DataSource = table;
        }
Exemple #4
0
        /// <summary>
        /// 方法说明:获取树节点数据
        /// </summary>
        /// <param name="nodeName">节点名</param>
        /// <returns></returns>
        public List <TypicalProcess> GetTreeData(string nodeName)
        {
            List <TypicalProcess> typicalProcessList = null;

            if (!typicalProcessDic.ContainsKey(nodeName))
            {
                typicalProcessList =
                    TypicalProcessBLL.GetTypicalProcesList(int.Parse(nodeName));
                typicalProcessDic.Add(nodeName, typicalProcessList);
            }
            else
            {
                typicalProcessList = typicalProcessDic[nodeName];
            }
            return(typicalProcessList);
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (selecedCardModuleNameIdDic.Count <= 0)
            {
                this.DialogResult = DialogResult.Cancel;
            }
            else
            {
                List <TypicalProcess> _typicalProcessList = new List <TypicalProcess>();
                try
                {
                    int sort = 1;
                    /// add process planning module
                    foreach (var kv in selecedCardModuleNameIdDic)
                    {
                        TypicalProcess p = new TypicalProcess();
                        p.TypicalProcessId = Guid.NewGuid();
                        p.BType            = BusinessType.Card;
                        p.ParentNode       = TypicalProcessMod.ParentNode;
                        p.Name             = kv.Value;
                        p.BusinessId       = new Guid(kv.Key);
                        p.Sort             = sort;

                        _typicalProcessList.Add(p);

                        sort++;
                    }

                    TypicalProcessBLL.AddTypicalProcess(_typicalProcessList);

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

                    ProcessPlanningModuleDic = pDic;

                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    this.DialogResult = DialogResult.Cancel;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 方法说明:加载数据到树
        /// </summary>
        public void LoadTreeData()
        {
            try
            {
                List <TypicalProcess> typicalProcessList =
                    TypicalProcessBLL.GetTypicalProcesList(0);

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

                    int currentNode = TypicalProcessBLL.AddTypicalProcess(typicalProcess);

                    typicalProcess.CurrentNode = currentNode;
                    typicalProcessList.Add(typicalProcess);
                }

                TypicalProcess typicalProcessModule = typicalProcessList[0];

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

                ShowChildNode(root);

                tvTypicalProcess.Nodes.Add(root);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //});
            //tvProcessPlanningModule.BeginInvoke(loadtreeEventHandler, new object[] { });
            //}
        }
Exemple #7
0
        /// <summary>
        /// 方法说明:增加典型工艺或文件夹
        /// </summary>
        /// <param name="type">类型</param>
        void AddTypicalOrFolder(BusinessType type)
        {
            TreeNode node = tvTypicalProcess.SelectedNode;

            if (node == null)
            {
                return;
            }

            TypicalProcess typicalProcess = new TypicalProcess();

            typicalProcess.BType      = type;
            typicalProcess.ParentNode = int.Parse(node.Name);


            ///批量名称
            Dictionary <string, TypicalProcess> dic = new Dictionary <string, TypicalProcess>();
            DialogResult result;

            if (type == BusinessType.Folder)
            {
                TypicalProcessFolderFrm typicalProcessFolderFrm
                    = new TypicalProcessFolderFrm(typicalProcess);

                result = typicalProcessFolderFrm.ShowDialog();


                if (result == DialogResult.OK)
                {
                    ///当前节点修改缓存且显示在界面上
                    dic = typicalProcessFolderFrm.NewNodeNameDic;
                }
            }
            else if (type == BusinessType.Card)
            {
                //    AddTypicalProcessCardFrm processCardModuleFrm
                //        = new AddTypicalProcessCardFrm(typicalProcess);



                //    result = processCardModuleFrm.ShowDialog();

                //    if (result == DialogResult.OK)
                //    {
                //        ///当前节点修改缓存且显示在界面上
                //        dic = processCardModuleFrm.ProcessPlanningModuleDic;
                //    }

                //}
                //else if (type == BusinessType.Planning)
                //{
                Dictionary <string, TypicalProcess> dicProcessCard = new Dictionary <string, TypicalProcess>();
                List <TypicalProcess> list = new List <TypicalProcess>();

                TypicalProcess typical = new TypicalProcess();
                typical.Name             = processCardInfo.Name;
                typical.BusinessId       = processCardInfo.ID;
                typical.TypicalProcessId = Guid.NewGuid();
                typical.BType            = BusinessType.Card;
                typical.ParentNode       = typicalProcess.ParentNode;
                list.Add(typical);

                TypicalProcessBLL.AddTypicalProcess(list);
                dicProcessCard.Add(typical.Name, typical);
                dic = dicProcessCard;
            }
            else
            {
                AddTypicalProcessFrm addProcessPlanningModuleFrm
                    = new AddTypicalProcessFrm(typicalProcess);


                result = addProcessPlanningModuleFrm.ShowDialog();

                if (result == DialogResult.OK)
                {
                    ///当前节点修改缓存且显示在界面上
                    dic = addProcessPlanningModuleFrm.NewNodeNameDic;
                }
            }

            List <TypicalProcess> processPlanningModuleList = null;

            if (!typicalProcessDic.ContainsKey(node.Name))
            {
                processPlanningModuleList = new List <TypicalProcess>();
                processPlanningModuleList.Add(typicalProcess);
                typicalProcessDic.Add(node.Name, processPlanningModuleList);
            }
            else
            {
                /// 更新字典表内的值
                processPlanningModuleList = typicalProcessDic[node.Name];


                foreach (var kv in dic)
                {
                    processPlanningModuleList.Add(new TypicalProcess()
                    {
                        BType       = type,
                        CurrentNode = kv.Value.CurrentNode,
                        Name        = kv.Key
                    });


                    TreeNode newNode = new TreeNode();
                    newNode.Text = kv.Key;
                    newNode.Tag  = kv.Value.BusinessId;
                    newNode.Name = kv.Value.CurrentNode.ToString();
                    switch (type)
                    {
                    case BusinessType.Root:
                        newNode.ImageKey = "folder";
                        break;

                    case BusinessType.Card:
                        newNode.ImageKey = "card";
                        break;

                    case BusinessType.Planning:
                        newNode.ImageKey = "planning";
                        break;

                    case BusinessType.Folder:
                        newNode.ImageKey = "folder";
                        break;

                    default:
                        break;
                    }

                    node.Nodes.Add(newNode);
                    /// set current node selected image
                    newNode.SelectedImageKey = newNode.ImageKey;
                    /// set current node is selected
                    tvTypicalProcess.SelectedNode = newNode;

                    node.Expand();

                    ///每个新增加的节点也要加入缓存
                    typicalProcessDic.Add(newNode.Name,
                                          new List <TypicalProcess>());
                }

                ///更新当前节点含有的子节点
                typicalProcessDic[node.Name] = processPlanningModuleList;
            }
        }
Exemple #8
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string name       = string.Empty;
            string parentNode = string.Empty;

            foreach (DataGridViewRow row in dgvTypicalCategory.Rows)
            {
                if ((bool)row.Cells[0].EditedFormattedValue == true &&
                    row.Cells["colName"].Value != null)
                {
                    name       = row.Cells["colName"].Value.ToString();
                    parentNode = row.Cells["colCurrentNode"].Value.ToString();
                    break;
                }
            }

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            try
            {
                if (ProcessCardIds != null && ProcessCardIds.Count > 0)
                {
                    foreach (string key in ProcessCardIds.Keys)
                    {
                        Guid cardid = new Guid(key);
                        bool result = TypicalProcessBLL.ExistTypcialProcessCard(cardid, int.Parse(parentNode));
                        if (!result)
                        {
                            TypicalProcess typical = new TypicalProcess();
                            typical.Name        = ProcessCardIds[key];
                            typical.CurrentNode = dt.Rows.Count + 1;
                            typical.BusinessId  = cardid;
                            typical.BType       = BusinessType.Card;
                            typical.ParentNode  = int.Parse(parentNode);
                            TypicalProcessBLL.AddTypicalProcess(typical);
                        }
                    }
                }
                else
                {
                    Guid cardid = new Guid(ProcessCardId);
                    bool result = TypicalProcessBLL.ExistTypcialProcessCard(cardid, int.Parse(parentNode));
                    if (!result)
                    {
                        TypicalProcess typical = new TypicalProcess();
                        typical.Name        = ProcessCardName;
                        typical.CurrentNode = dt.Rows.Count + 1;
                        typical.BusinessId  = cardid;
                        typical.BType       = BusinessType.Card;
                        typical.ParentNode  = int.Parse(parentNode);
                        TypicalProcessBLL.AddTypicalProcess(typical);
                    }
                }

                if (TypicalProcessFrm.typicalProcessForm != null)
                {
                    TypicalProcessFrm.typicalProcessForm.ChangeToTypical();
                }

                MessageBox.Show("卡片转为典型成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch
            {
                MessageBox.Show("卡片转为典型失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// 方法说明:获取树节点数据
        /// </summary>
        /// <param name="nodeName">节点名</param>
        /// <returns></returns>
        private List <Model.TypicalProcess> GetTypicalTreeData(string nodeName)
        {
            List <Model.TypicalProcess> typicalProcessList = TypicalProcessBLL.GetTypicalProcesList(int.Parse(nodeName));

            return(typicalProcessList);
        }