| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using Newtonsoft.Json.Linq; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Data.SqlClient; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.CQMS.ProcessControl | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class ShowUnitWork : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 被选择项列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public List<string> SelectedList | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (List<string>)ViewState["SelectedList"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["SelectedList"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 未被选择项列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public List<string> NoSelectedList | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (List<string>)ViewState["NoSelectedList"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["NoSelectedList"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.SelectedList = new List<string>(); | 
					
						
							|  |  |  |  |                 this.NoSelectedList = new List<string>(); | 
					
						
							|  |  |  |  |                 string cnProfessionalId = Request.Params["CNPrefessionalId"]; | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 InitTreeMenu(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载树 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="cnProfessionalId"></param> | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |         private void InitTreeMenu() | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |             this.trWBS.Nodes.Clear(); | 
					
						
							|  |  |  |  |             this.trWBS.ShowBorder = false; | 
					
						
							|  |  |  |  |             this.trWBS.ShowHeader = false; | 
					
						
							|  |  |  |  |             this.trWBS.EnableIcons = true; | 
					
						
							|  |  |  |  |             this.trWBS.AutoScroll = true; | 
					
						
							|  |  |  |  |             this.trWBS.EnableSingleClickExpand = true; | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |             if (this.CurrUser.UserId == BLL.Const.hfnbdId)//测试账号用 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                 var unitWorks = from x in Funs.DB.WBS_UnitWork | 
					
						
							|  |  |  |  |                                 join y in Funs.DB.WBS_DivisionDivide on x.UnitWorkId equals y.UnitWorkId | 
					
						
							|  |  |  |  |                                 where x.ProjectId == this.CurrUser.LoginProjectId  | 
					
						
							|  |  |  |  |                                 && (x.SuperUnitWork == null || x.SuperUnitWork == "0") | 
					
						
							|  |  |  |  |                                 orderby x.UnitWorkCode select new | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     x.UnitWorkId, | 
					
						
							|  |  |  |  |                                     x.UnitWorkName | 
					
						
							|  |  |  |  |                                 }; | 
					
						
							|  |  |  |  |                 foreach (var q in unitWorks.Distinct()) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     newNode.Text = q.UnitWorkName; | 
					
						
							|  |  |  |  |                     newNode.NodeID = q.UnitWorkId; | 
					
						
							|  |  |  |  |                     newNode.CommandName = "UnitWork"; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                     this.trWBS.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                     TreeNode emptyNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     emptyNode.Text = ""; | 
					
						
							|  |  |  |  |                     emptyNode.NodeID = ""; | 
					
						
							|  |  |  |  |                     newNode.Nodes.Add(emptyNode); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var unitWorks = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId && (x.SuperUnitWork == null || x.SuperUnitWork == "0") orderby x.UnitWorkCode select x; | 
					
						
							|  |  |  |  |                 foreach (var q in unitWorks) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     newNode.Text = q.UnitWorkName; | 
					
						
							|  |  |  |  |                     newNode.NodeID = q.UnitWorkId; | 
					
						
							|  |  |  |  |                     newNode.CommandName = "UnitWork"; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                     this.trWBS.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                     TreeNode emptyNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     emptyNode.Text = ""; | 
					
						
							|  |  |  |  |                     emptyNode.NodeID = ""; | 
					
						
							|  |  |  |  |                     newNode.Nodes.Add(emptyNode); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |         #region  展开树 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 展开树 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void trWBS_NodeExpand(object sender, TreeNodeEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             e.Node.Nodes.Clear(); | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             if (e.Node.CommandName == "UnitWork")   //展开工程类型 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string cnProfessionalId = Request.Params["CNPrefessionalId"]; | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                 if (this.CurrUser.UserId == BLL.Const.hfnbdId) | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                     string professionalName = string.Empty; | 
					
						
							|  |  |  |  |                     var pointCropping = from x in db.Control_PointCropping where x.ControlId == cnProfessionalId select x; | 
					
						
							|  |  |  |  |                     if (pointCropping.FirstOrDefault(x => x.DetectionItems.Contains("设备")) != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         professionalName = "设备"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         professionalName = pointCropping.FirstOrDefault().DetectionItems; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     var divisions = (from x in db.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                      join y in db.Base_CNProfessional on x.CNProfessionalId equals y.CNProfessionalId | 
					
						
							|  |  |  |  |                                      where y.ProfessionalName == professionalName | 
					
						
							|  |  |  |  |                                      && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                      && x.SuperDivisionId == null | 
					
						
							|  |  |  |  |                                      && x.UnitWorkId == e.NodeID | 
					
						
							|  |  |  |  |                                      && x.IsSelected == true | 
					
						
							|  |  |  |  |                                      orderby x.SortIndex | 
					
						
							|  |  |  |  |                                      select x).ToList(); | 
					
						
							|  |  |  |  |                     //} | 
					
						
							|  |  |  |  |                     //if (this.CurrUser.UserId == BLL.Const.hfnbdId)//测试阶段,仅hfnbd账号使用 | 
					
						
							|  |  |  |  |                     //{ | 
					
						
							|  |  |  |  |                     //Model.Control_PointCropping pc = new Model.Control_PointCropping(); | 
					
						
							|  |  |  |  |                     Model.Base_CNProfessional cNProfessional = new Model.Base_CNProfessional(); | 
					
						
							|  |  |  |  |                     var pc = Funs.DB.Control_PointCropping.FirstOrDefault(x => (x.ParentId == null || x.ParentId == "") && x.DetectionItems == "土建"); | 
					
						
							|  |  |  |  |                     if (divisions.Count() == 0 && pc != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         cNProfessional = (from x in db.Base_CNProfessional where x.ProfessionalName == "土建" orderby x.SortIndex select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                         //pc = (from x in db.Control_PointCropping where (x.ParentId == null || x.ParentId == "") && x.ControlId == "E9AC9563-E338-48B7-867D-488222AD0557" orderby x.OperateTime select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         cNProfessional = (from x in db.Base_CNProfessional | 
					
						
							|  |  |  |  |                                           where x.ProfessionalName.Contains(professionalName) | 
					
						
							|  |  |  |  |                                           orderby x.SortIndex | 
					
						
							|  |  |  |  |                                           select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                         //pc = (from x in db.Control_PointCropping where (x.ParentId == null || x.ParentId == "") && x.ControlId == cnProfessionalId orderby x.OperateTime select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (pc != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         newNode.Text = cNProfessional.ProfessionalName; | 
					
						
							|  |  |  |  |                         newNode.NodeID = cNProfessional.CNProfessionalId + "|" + e.NodeID; | 
					
						
							|  |  |  |  |                         newNode.CommandName = "CNProfessional"; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         e.Node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                         TreeNode tempNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         tempNode.NodeID = ""; | 
					
						
							|  |  |  |  |                         tempNode.Text = ""; | 
					
						
							|  |  |  |  |                         newNode.Nodes.Add(tempNode); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                     var divisions = (from x in db.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                      where x.CNProfessionalId == cnProfessionalId | 
					
						
							|  |  |  |  |     && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |     && x.SuperDivisionId == null | 
					
						
							|  |  |  |  |     && x.UnitWorkId == e.NodeID | 
					
						
							|  |  |  |  |     && x.IsSelected == true | 
					
						
							|  |  |  |  |                                      orderby x.SortIndex | 
					
						
							|  |  |  |  |                                      select x).ToList(); | 
					
						
							|  |  |  |  |                     Model.Base_CNProfessional cNProfessional = new Model.Base_CNProfessional(); | 
					
						
							|  |  |  |  |                     if (divisions.Count() == 0 && cnProfessionalId == BLL.Const.CNProfessionalCVId) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         cNProfessional = (from x in db.Base_CNProfessional where x.CNProfessionalId == BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         cNProfessional = (from x in db.Base_CNProfessional where x.CNProfessionalId == cnProfessionalId orderby x.SortIndex select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (cNProfessional != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         newNode.Text = cNProfessional.ProfessionalName; | 
					
						
							|  |  |  |  |                         newNode.NodeID = cNProfessional.CNProfessionalId + "|" + e.NodeID; | 
					
						
							|  |  |  |  |                         newNode.CommandName = "CNProfessional"; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         e.Node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                         TreeNode tempNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         tempNode.NodeID = ""; | 
					
						
							|  |  |  |  |                         tempNode.Text = ""; | 
					
						
							|  |  |  |  |                         newNode.Nodes.Add(tempNode); | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (e.Node.CommandName == "CNProfessional")   //展开专业 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string unitWorkId = e.Node.ParentNode.NodeID; | 
					
						
							|  |  |  |  |                 string cNProfessionalId = Request.Params["CNPrefessionalId"]; | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                 if (this.CurrUser.UserId == BLL.Const.hfnbdId) | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                     string professionalName = string.Empty; | 
					
						
							|  |  |  |  |                     var pointCropping = from x in db.Control_PointCropping where x.ControlId == cNProfessionalId select x; | 
					
						
							|  |  |  |  |                     if (pointCropping.FirstOrDefault(x => x.DetectionItems.Contains("设备")) != null) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2025-01-15 18:48:03 +08:00
										 |  |  |  |                         professionalName = "设备"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         professionalName = pointCropping.FirstOrDefault().DetectionItems; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     var divisions = (from x in db.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                      join y in db.Base_CNProfessional on x.CNProfessionalId equals y.CNProfessionalId | 
					
						
							|  |  |  |  |                                      where y.ProfessionalName.Contains(professionalName) && x.ProjectId == this.CurrUser.LoginProjectId && x.SuperDivisionId == null && x.UnitWorkId == unitWorkId && x.IsSelected == true | 
					
						
							|  |  |  |  |                                      orderby x.SortIndex | 
					
						
							|  |  |  |  |                                      select x).ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     foreach (var q in divisions) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         newNode.Text = q.DivisionName; | 
					
						
							|  |  |  |  |                         newNode.NodeID = q.DivisionProjectId; | 
					
						
							|  |  |  |  |                         newNode.CommandName = "DivisionProject"; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         e.Node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                         var list = (from x in Funs.DB.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                     where x.SuperDivisionId == q.DivisionProjectId && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                      && x.IsSelected == true | 
					
						
							|  |  |  |  |                                     orderby x.SortIndex | 
					
						
							|  |  |  |  |                                     select x).ToList(); | 
					
						
							|  |  |  |  |                         if (list.Count > 0) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             TreeNode tempNode = new TreeNode(); | 
					
						
							|  |  |  |  |                             tempNode.NodeID = ""; | 
					
						
							|  |  |  |  |                             tempNode.Text = ""; | 
					
						
							|  |  |  |  |                             newNode.Nodes.Add(tempNode); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var divisions = (from x in db.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                      where x.CNProfessionalId==cNProfessionalId && x.ProjectId == this.CurrUser.LoginProjectId && x.SuperDivisionId == null && x.UnitWorkId == unitWorkId && x.IsSelected == true | 
					
						
							|  |  |  |  |                                      orderby x.SortIndex | 
					
						
							|  |  |  |  |                                      select x).ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     foreach (var q in divisions) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         newNode.Text = q.DivisionName; | 
					
						
							|  |  |  |  |                         newNode.NodeID = q.DivisionProjectId; | 
					
						
							|  |  |  |  |                         newNode.CommandName = "DivisionProject"; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                         newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                         e.Node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                         var list = (from x in Funs.DB.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                     where x.SuperDivisionId == q.DivisionProjectId && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                      && x.IsSelected == true | 
					
						
							|  |  |  |  |                                     orderby x.SortIndex | 
					
						
							|  |  |  |  |                                     select x).ToList(); | 
					
						
							|  |  |  |  |                         if (list.Count > 0) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             TreeNode tempNode = new TreeNode(); | 
					
						
							|  |  |  |  |                             tempNode.NodeID = ""; | 
					
						
							|  |  |  |  |                             tempNode.Text = ""; | 
					
						
							|  |  |  |  |                             newNode.Nodes.Add(tempNode); | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (e.Node.CommandName == "DivisionProject")   //展开分部节点 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string parentId = e.NodeID; | 
					
						
							|  |  |  |  |                 var childDivisions = (from x in db.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                       where x.SuperDivisionId == parentId && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                       && x.IsSelected == true | 
					
						
							|  |  |  |  |                                       orderby x.SortIndex | 
					
						
							|  |  |  |  |                                       select x).ToList(); | 
					
						
							|  |  |  |  |                 foreach (var q in childDivisions) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     newNode.Text = q.DivisionName; | 
					
						
							|  |  |  |  |                     newNode.NodeID = q.DivisionProjectId; | 
					
						
							|  |  |  |  |                     newNode.CommandName = "DivisionProject"; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     e.Node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                     var list = (from x in Funs.DB.WBS_DivisionProject | 
					
						
							|  |  |  |  |                                 where x.SuperDivisionId == q.DivisionProjectId && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                  && x.IsSelected == true | 
					
						
							|  |  |  |  |                                 orderby x.SortIndex | 
					
						
							|  |  |  |  |                                 select x).ToList(); | 
					
						
							|  |  |  |  |                     if (list.Count > 0) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                         TreeNode tempNode = new TreeNode(); | 
					
						
							|  |  |  |  |                         tempNode.NodeID = ""; | 
					
						
							|  |  |  |  |                         tempNode.Text = ""; | 
					
						
							|  |  |  |  |                         newNode.Nodes.Add(tempNode); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 遍历节点 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 遍历节点 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="nodes"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         /// <param name="node"></param> | 
					
						
							|  |  |  |  |         /// <param name="unitWorkId"></param> | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |         private void GetNodes(TreeNodeCollection nodes, string parentId, TreeNode node, string unitWorkId,Model.SGGLDB db) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(unitWorkId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 var divisions = (from x in db.WBS_DivisionProject | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                                  where x.CNProfessionalId == parentId && x.ProjectId == this.CurrUser.LoginProjectId && x.SuperDivisionId == null && x.UnitWorkId == unitWorkId && x.IsSelected == true | 
					
						
							|  |  |  |  |                                  orderby x.SortIndex | 
					
						
							|  |  |  |  |                                  select x).ToList(); | 
					
						
							|  |  |  |  |                 foreach (var q in divisions) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     newNode.Text = q.DivisionName; | 
					
						
							|  |  |  |  |                     newNode.NodeID = q.DivisionProjectId; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                     newNode.Expanded = true; | 
					
						
							|  |  |  |  |                     node.Nodes.Add(newNode); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 var childDivisions = (from x in db.WBS_DivisionProject | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |                                       where x.SuperDivisionId == parentId && x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                       && x.IsSelected == true | 
					
						
							|  |  |  |  |                                       orderby x.SortIndex | 
					
						
							|  |  |  |  |                                       select x).ToList(); | 
					
						
							|  |  |  |  |                 foreach (var q in childDivisions) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     TreeNode newNode = new TreeNode(); | 
					
						
							|  |  |  |  |                     newNode.Text = q.DivisionName; | 
					
						
							|  |  |  |  |                     newNode.NodeID = q.DivisionProjectId; | 
					
						
							|  |  |  |  |                     newNode.EnableExpandEvent = true; | 
					
						
							|  |  |  |  |                     newNode.EnableClickEvent = true; | 
					
						
							|  |  |  |  |                     newNode.Expanded = true; | 
					
						
							|  |  |  |  |                     nodes.Add(newNode); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             for (int i = 0; i < nodes.Count; i++) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |                 GetNodes(nodes[i].Nodes, nodes[i].NodeID, nodes[i], string.Empty,db); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 点击树节点 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 点击树节点 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |         protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-10-22 18:11:29 +08:00
										 |  |  |  |             this.hdDivisionProjectId.Text = this.trWBS.SelectedNode.NodeID; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |                 int i = mergedRow.Value<int>("index"); | 
					
						
							|  |  |  |  |                 AspNet.CheckBox ckb = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbSelect")); | 
					
						
							|  |  |  |  |                 if (ckb.Checked) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     SelectedList.Add(this.Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     NoSelectedList.Add(this.Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 数据绑定 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定数据  | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void BindGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string strSql = @"SELECT V.BreakdownProjectId, 
 | 
					
						
							|  |  |  |  |                                      V.ProjectId,  | 
					
						
							|  |  |  |  |                                      V.BreakdownCode,  | 
					
						
							|  |  |  |  |                                      V.BreakdownName,  | 
					
						
							|  |  |  |  |                                      V.DivisionProjectId,  | 
					
						
							|  |  |  |  |                                      V.Basis,  | 
					
						
							|  |  |  |  |                                      V.CheckPoints,  | 
					
						
							|  |  |  |  |                                      V.RecordAndCode,  | 
					
						
							|  |  |  |  |                                      V.Class,  | 
					
						
							|  |  |  |  |                                      V.SortIndex,  | 
					
						
							|  |  |  |  |                                      V.Remark,  | 
					
						
							|  |  |  |  |                                      V.AttachUrl,  | 
					
						
							|  |  |  |  |                                      V.IsAcceptance,  | 
					
						
							|  |  |  |  |                                      V.FenBao,  | 
					
						
							|  |  |  |  |                                      V.WuHuan,  | 
					
						
							|  |  |  |  |                                      V.JianLi,  | 
					
						
							|  |  |  |  |                                      V.YeZhu,  | 
					
						
							|  |  |  |  |                                      V.IsSelected"
 | 
					
						
							|  |  |  |  |                             + @" FROM View_WBS_BreakdownProject AS V " | 
					
						
							|  |  |  |  |                             + @" WHERE V.ProjectId=@ProjectId AND V.DivisionProjectId=@divisionProjectId"; | 
					
						
							|  |  |  |  |             List<SqlParameter> listStr = new List<SqlParameter>(); | 
					
						
							|  |  |  |  |             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); | 
					
						
							|  |  |  |  |             listStr.Add(new SqlParameter("@divisionProjectId", this.hdDivisionProjectId.Text.Trim())); | 
					
						
							|  |  |  |  |             SqlParameter[] parameter = listStr.ToArray(); | 
					
						
							|  |  |  |  |             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); | 
					
						
							|  |  |  |  |             Grid1.RecordCount = tb.Rows.Count; | 
					
						
							|  |  |  |  |             var table = this.GetPagedDataTable(Grid1, tb); | 
					
						
							|  |  |  |  |             Grid1.DataSource = table; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 分页 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 分页 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Grid1.PageIndex = e.NewPageIndex; | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 下拉框分页 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 排序 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Grid1.SortDirection = e.SortDirection; | 
					
						
							|  |  |  |  |             Grid1.SortField = e.SortField; | 
					
						
							|  |  |  |  |             BindGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 确定 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 确定按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSure_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string ids = string.Empty; | 
					
						
							|  |  |  |  |             bool res = false; | 
					
						
							|  |  |  |  |             foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |                 int i = mergedRow.Value<int>("index"); | 
					
						
							|  |  |  |  |                 AspNet.CheckBox ckb = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbSelect")); | 
					
						
							|  |  |  |  |                 if (ckb.Checked) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     res = true; | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (SelectedList.Count == 0 && !res) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("没有选中任何项!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |                 int i = mergedRow.Value<int>("index"); | 
					
						
							|  |  |  |  |                 AspNet.CheckBox ckb = (AspNet.CheckBox)(this.Grid1.Rows[i].FindControl("cbSelect")); | 
					
						
							|  |  |  |  |                 if (ckb.Checked) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     SelectedList.Add(this.Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     if (SelectedList.Contains(this.Grid1.Rows[i].RowID)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         SelectedList.Remove(this.Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     NoSelectedList.Add(this.Grid1.Rows[i].RowID); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             foreach (var item in SelectedList.Distinct()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ids += item + ","; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(ids)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ids = ids.Substring(0, ids.LastIndexOf(",")); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-05-13 14:38:09 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             string scripts = String.Format("F.getActiveWindow().window.reloadGrid('{0}');", ids); | 
					
						
							|  |  |  |  |             PageContext.RegisterStartupScript(scripts + ActiveWindow.GetHidePostBackReference()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(ids) | 
					
						
							|  |  |  |  |             //       + ActiveWindow.GetHidePostBackReference()); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |