158 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			158 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Web;
 | 
						|
using System.Web.UI;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
 | 
						|
namespace FineUIPro.Web.TestRun.DriverReport
 | 
						|
{
 | 
						|
    public partial class MonthReportPush : PageBase
 | 
						|
    {
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                string id = Request.Params["id"];
 | 
						|
                if (!string.IsNullOrEmpty(id))
 | 
						|
                {
 | 
						|
                    this.hdId.Text = id;
 | 
						|
                }
 | 
						|
                InitMenuTree();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #region 初始化树
 | 
						|
        /// <summary>
 | 
						|
        /// 初始化树
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="menuList">单位集合</param>
 | 
						|
        private void InitMenuTree()
 | 
						|
        {
 | 
						|
            this.tvPerson.Nodes.Clear();
 | 
						|
            var units = BLL.UnitService.GetUnitByProjectIdList(this.CurrUser.LoginProjectId);
 | 
						|
            foreach (var item in units)
 | 
						|
            {
 | 
						|
                TreeNode rootNode = new TreeNode
 | 
						|
                {
 | 
						|
                    Text = item.UnitName,
 | 
						|
                    NodeID = item.UnitId,
 | 
						|
                    EnableCheckBox = true,
 | 
						|
                    EnableCheckEvent = true,
 | 
						|
                    Expanded = true
 | 
						|
                };
 | 
						|
                this.tvPerson.Nodes.Add(rootNode);
 | 
						|
                this.BoundTree(rootNode.Nodes, rootNode.NodeID);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 遍历增加子节点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="nodes"></param>
 | 
						|
        /// <param name="menuId"></param>
 | 
						|
        private void BoundTree(TreeNodeCollection nodes, string superMenuId)
 | 
						|
        {
 | 
						|
            var menus = BLL.UserService.GetUserByUnitId(this.CurrUser.LoginProjectId, superMenuId);
 | 
						|
            foreach (var item in menus)
 | 
						|
            {
 | 
						|
                TreeNode chidNode = new TreeNode
 | 
						|
                {
 | 
						|
                    Text = item.Text,
 | 
						|
                    NodeID = item.Value,
 | 
						|
                    EnableCheckBox = true,
 | 
						|
                    EnableCheckEvent = true
 | 
						|
                };
 | 
						|
                var monthReport = BLL.TestRun_MonthReportService.GetMonthReportById(this.hdId.Text.Trim());
 | 
						|
                if (monthReport != null)
 | 
						|
                {
 | 
						|
                    if (!string.IsNullOrEmpty(monthReport.PushPerson))
 | 
						|
                    {
 | 
						|
                        if (monthReport.PushPerson.Contains(item.Value))
 | 
						|
                        {
 | 
						|
                            chidNode.Checked = true;
 | 
						|
                            chidNode.Expanded = true;
 | 
						|
                            chidNode.Selectable = true;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                nodes.Add(chidNode);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 全选、全不选
 | 
						|
        /// <summary>
 | 
						|
        /// 全选、全不选
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void tvPerson_NodeCheck(object sender, FineUIPro.TreeCheckEventArgs e)
 | 
						|
        {
 | 
						|
            if (e.Checked)
 | 
						|
            {
 | 
						|
                this.tvPerson.CheckAllNodes(e.Node.Nodes);
 | 
						|
                SetCheckParentNode(e.Node);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                this.tvPerson.UncheckAllNodes(e.Node.Nodes);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 选中父节点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="node"></param>
 | 
						|
        private void SetCheckParentNode(TreeNode node)
 | 
						|
        {
 | 
						|
            if (node.ParentNode != null && node.ParentNode.NodeID != "0")
 | 
						|
            {
 | 
						|
                node.ParentNode.Checked = true;
 | 
						|
                if (node.ParentNode.ParentNode.NodeID != "0")
 | 
						|
                {
 | 
						|
                    SetCheckParentNode(node.ParentNode);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 提交推送人员
 | 
						|
        /// <summary>
 | 
						|
        /// 提交推送人员
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSubmit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            #region 保存推送人员
 | 
						|
            string users = string.Empty;
 | 
						|
            TreeNode[] nodes = this.tvPerson.GetCheckedNodes();
 | 
						|
            if (nodes.Length > 0)
 | 
						|
            {
 | 
						|
                foreach (TreeNode tn in nodes)
 | 
						|
                {
 | 
						|
                    if (tn.NodeID != "0")
 | 
						|
                    {
 | 
						|
                        users += tn.NodeID + ",";
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (!string.IsNullOrEmpty(users))
 | 
						|
                {
 | 
						|
                    users = users.Substring(0, users.LastIndexOf(','));
 | 
						|
                }
 | 
						|
                var monthReport = BLL.TestRun_MonthReportService.GetMonthReportById(this.hdId.Text.Trim());
 | 
						|
                if (monthReport != null)
 | 
						|
                {
 | 
						|
                    monthReport.PushPerson = users;
 | 
						|
                    Funs.DB.SubmitChanges();
 | 
						|
                    ShowNotify("提交成功!", MessageBoxIcon.Success);
 | 
						|
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						|
                }
 | 
						|
            }
 | 
						|
            #endregion
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |