Example #1
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuAdd_Click(object sender, EventArgs e)
        {
            string nodecode;
            //{FF5503FA-0057-413e-BF08-5A8C1DCF7ED8}  药理作用级别校验
            int girdLevel;

            //如果选择了节点,则选择的节点作为父节点,否则添加到根节点下
            if (this.tvFunction.SelectedNode != null)
            {
                nodecode  = this.tvFunction.SelectedNode.Tag.ToString();
                girdLevel = this.tvFunction.SelectedNode.Level;             //根据树节点层次设置药理作用级别  {FF5503FA-0057-413e-BF08-5A8C1DCF7ED8}
            }
            else
            {
                nodecode  = "-1";
                girdLevel = 0;            //根节点下 药理作用级别为 1        {FF5503FA-0057-413e-BF08-5A8C1DCF7ED8}
            }
            if (girdLevel == 3)           //父节点已经是三级节点
            {
                MessageBox.Show("药理作最多支持三级分类,不能再进行四级分类添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //初始化实体
            functionObject = new Neusoft.HISFC.Models.Pharmacy.PhaFunction();
            //初始化控件  {FF5503FA-0057-413e-BF08-5A8C1DCF7ED8} 此时增加的是当前节点的下一级节点 Level + 1
            ucProperty = new ucPharmacyFunctionProperty(nodecode, "INSERT", girdLevel + 1);
            //窗口标题
            Neusoft.FrameWork.WinForms.Classes.Function.PopForm.Text = "添加药理作用";
            DialogResult dlg = Neusoft.FrameWork.WinForms.Classes.Function.PopShowControl(ucProperty);

            if (dlg == DialogResult.OK)
            {
                TreeNode tn = new TreeNode();
                //获取最近插入的实体
                functionObject = (Neusoft.HISFC.Models.Pharmacy.PhaFunction) this.pharmacyConstant.QueryPhaFunctionNodeName()[0];
                //插入新加节点
                tn.Tag                = functionObject.ID;
                tn.Text               = functionObject.Name;
                tn.ImageIndex         = 0;
                tn.SelectedImageIndex = 0;
                if (this.tvFunction.SelectedNode != null)
                {
                    this.tvFunction.SelectedNode.Nodes.Add(tn);
                    this.tvFunction.SelectedNode.ImageIndex         = 2;
                    this.tvFunction.SelectedNode.SelectedImageIndex = 1;
                }
                else
                {
                    this.tvFunction.Nodes.Add(tn);
                }

                //添加到ListView
                ListViewItem lvi = new ListViewItem();
                lvi.Text       = tn.Text;
                lvi.Tag        = tn.Tag;
                lvi.ImageIndex = tn.ImageIndex;
                this.lvFunctionList.Items.Add(lvi);
            }
        }
Example #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuDelete_Click(object sender, EventArgs e)
        {
            //如果树节点数为零则不触发
            if (this.tvFunction.Nodes.Count == 0)
            {
                return;
            }

            TreeNode node = null;

            //如果列表中有选中的节点
            if (this.lvFunctionList.Focused == true && this.lvFunctionList.SelectedItems.Count > 0)
            {
                node = this.lvFunctionList.SelectedItems[0].Tag as TreeNode;
            }
            else //列表中没有选中的节点,则取树当前选中的节点
            {
                node = this.tvFunction.SelectedNode;
            }
            //如果该节点下没有子节点则可以删除,否则不允许删除
            if (node != null)//{5893E516-AD85-49b7-BAA9-652B2124B13C}
            {
                if (node.Nodes.Count == 0)
                {
                    //初始化控件
                    ucProperty = new ucPharmacyFunctionProperty(node.Tag.ToString(), "DELETE", this.tvFunction.SelectedNode.Level);
                    //窗口标题
                    Neusoft.FrameWork.WinForms.Classes.Function.PopForm.Text = "删除药理作用";
                    DialogResult dlg = Neusoft.FrameWork.WinForms.Classes.Function.PopShowControl(ucProperty);
                    if (dlg == DialogResult.OK)
                    {
                        TreeNode tn = new TreeNode();
                        tn = node.Parent;
                        node.Remove();                       //删除树节点
                        if (this.tvFunction.Nodes.Count > 0) //判断如果不是删除根节点
                        {
                            if (this.lvFunctionList.SelectedItems.Count > 0)
                            {
                                this.lvFunctionList.SelectedItems[0].Remove();//删除listview 节点
                            }
                            if (tn.Nodes.Count == 0)
                            {
                                tn.ImageIndex         = 0;
                                tn.SelectedImageIndex = 0;
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("请点击左侧节点,再删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Example #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuModify_Click(object sender, EventArgs e)
        {
            //如果当前树没有节点则不能显示
            if (this.tvFunction.Nodes.Count == 0)
            {
                return;
            }
            //定义当前节点和父节点
            TreeNode node, nodep;

            if (this.lvFunctionList.Focused == true && this.lvFunctionList.SelectedItems.Count > 0)
            {
                node  = this.lvFunctionList.SelectedItems[0].Tag as TreeNode;
                nodep = node.Parent;
            }
            else
            {
                node = this.tvFunction.SelectedNode;
            }

            //初始化实体
            functionObject = new Neusoft.HISFC.Models.Pharmacy.PhaFunction();
            //初始化控件
            ucProperty = new ucPharmacyFunctionProperty(node.Tag.ToString(), "UPDATE", this.tvFunction.SelectedNode.Level);
            //窗口标题
            Neusoft.FrameWork.WinForms.Classes.Function.PopForm.Text = "修改作用维护";
            DialogResult dlg = Neusoft.FrameWork.WinForms.Classes.Function.PopShowControl(ucProperty);

            object myobj = new object();

            if (dlg == DialogResult.OK)
            {
                functionObject = (Neusoft.HISFC.Models.Pharmacy.PhaFunction) this.pharmacyConstant.QueryPhaFunctionNodeName()[0];
                //取出最新更改的节点的名称
                node.Text = functionObject.Name;
                //如果更新的不是根节点
                if (this.lvFunctionList.SelectedItems.Count > 0)
                {
                    this.lvFunctionList.SelectedItems[0].Text = functionObject.Name;
                    //新更改节点的父节点和原来父节点不同则重新LOAD
                    if (functionObject.ParentNode != node.Parent.Tag.ToString())
                    {
                        myobj = node;
                        nodep = node.Parent;
                        node.Remove();
                        //从当前列表种删除
                        this.lvFunctionList.SelectedItems[0].Remove();
                        //递归遍历整个树,添加到新根节点下
                        GetAllNode(this.tvFunction.Nodes, functionObject.ParentNode, (TreeNode)myobj);
                        //如果当前修改的节点的父节点没有子节点,则更新子节点标志为0(因为当前节点的的节点类别已经更改)
                        if (nodep.Nodes.Count == 0)
                        {
                            //叶子节点更改nodekind
                            this.pharmacyConstant.UpdateFunctionnNodekind(nodep.Tag.ToString(), 0);
                            SettreeImage(nodep, true);
                        }
                    }
                }
                else
                {
                    this.tvFunction.InitTreeView();

                    if (this.tvFunction.Nodes.Count > 0)
                    {
                        this.tvFunction.Nodes[0].Expand();
                    }
                }
            }
        }