Exemple #1
0
 /// <summary>
 /// 将树型控件当前被选中节点的儿子节点(用户)显示在listView中
 /// </summary>
 private void ShowListUser()
 {
     Neusoft.HISFC.BizLogic.Manager.UserPowerDetailManager userManager = new Neusoft.HISFC.BizLogic.Manager.UserPowerDetailManager();
     Neusoft.HISFC.Models.Base.DepartmentStat dept = new Neusoft.HISFC.Models.Base.DepartmentStat();
     ParentNodeStat(this.tvDepartmentLevelTree1.SelectedNode, ref dept);
     System.Collections.ArrayList al = userManager.LoadUser(dept.StatCode, dept.PardepCode);
     foreach (Neusoft.HISFC.Models.Admin.UserPowerDetail info in al)
     {
         ListViewItem item = this.neuListView1.Items.Add(info.User.Name);
         item.Tag = info;
         if (info.User01 == "F")
         {
             item.ImageIndex      = 3;
             item.StateImageIndex = 3;
         }
         else
         {
             item.ImageIndex      = 2;
             item.StateImageIndex = 2;
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 删除当前ListView中选中的科室
        /// </summary>
        public void DelDepartment()
        {
            //取得当前ListView中要修改的科室数据信息
            TreeNode node = this.neuListView1.SelectedItems[0].Tag as TreeNode;

            //只能删除科室数据
            if (node == null)
            {
                return;
            }

            //取要删除的科室信息
            Neusoft.HISFC.Models.Base.DepartmentStat dept = node.Tag as Neusoft.HISFC.Models.Base.DepartmentStat;
            if (dept != null)
            {
                if (dept.Childs.Count > 0)
                {
                    MessageBox.Show("此科室有下级科室,不允许删除。\n请先删除下级科室。", "删除无法进行", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //取此科室下级人员信息,如果存在人员则不允许删除。
                Neusoft.HISFC.BizLogic.Manager.UserPowerDetailManager userMgr = new Neusoft.HISFC.BizLogic.Manager.UserPowerDetailManager();
                ArrayList al = userMgr.LoadUser(dept.StatCode, dept.DeptCode);
                if (al == null)
                {
                    MessageBox.Show("取人员信息时出错:" + userMgr.Err);
                    return;
                }

                if (al.Count > 0)
                {
                    MessageBox.Show("此科室有下级人员,不允许删除。\n请先删除下级人员。", "删除无法进行", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (MessageBox.Show("确定要把科室“" + dept.DeptName + "”删除吗?", "确认科室删除", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                //定义管理类,删除科室

                Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

                Neusoft.HISFC.BizLogic.Manager.DepartmentStatManager deptStatMgr = new Neusoft.HISFC.BizLogic.Manager.DepartmentStatManager();
                //Neusoft.FrameWork.Management.Transaction trans = new Neusoft.FrameWork.Management.Transaction(deptStatMgr.Connection);
                //trans.BeginTransaction();
                //deptStatMgr.SetTrans(trans.Trans);
                try
                {
                    //删除一个科室数据
                    int parm = deptStatMgr.Delete(dept.StatCode, dept.DeptCode);
                    if (parm != 1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();;
                        MessageBox.Show("数据保存失败:" + deptStatMgr.Err);
                        return;
                    }
                }
                catch (Exception e)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();;
                    MessageBox.Show("数据保存失败!" + e.Message, "提示");
                    return;
                }
                Neusoft.FrameWork.Management.PublicTrans.Commit();
                //MessageBox.Show("数据保存失败!" + e.Message,"提示");
            }

            //在TreeView中移除被删掉的节点
            this.tvDepartmentLevelTree1.DelDepartment(node);

            //显示当前TreeView中选中节点的下级内容
            this.ShowList();
        }