CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/ProjectData/Installation.aspx.cs

810 lines
38 KiB
C#
Raw Normal View History

2021-04-30 10:28:37 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Newtonsoft.Json.Linq;
2021-10-19 17:50:34 +08:00
using Newtonsoft.Json;
2021-04-30 10:28:37 +08:00
namespace FineUIPro.Web.ProjectData
{
public partial class Installation : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();
InitTreeMenu();
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
2025-02-14 11:53:03 +08:00
//this.btnMenuDown.Hidden = false;
2021-04-30 10:28:37 +08:00
this.btnMenuAdd.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDelete.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.trProjects.Nodes.Clear();
this.trProjects.ShowBorder = false;
this.trProjects.ShowHeader = false;
this.trProjects.EnableIcons = true;
this.trProjects.AutoScroll = true;
this.trProjects.EnableSingleClickExpand = true;
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
TreeNode node = new TreeNode();
node.Text = project.ProjectName;
node.NodeID = project.ProjectId;
node.CommandName = "project";
node.EnableClickEvent = true;
node.EnableExpandEvent = true;
this.trProjects.Nodes.Add(node);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
node.Nodes.Add(emptyNode);
}
}
#endregion
#region
/// <summary>
/// 展开树
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trProjects_NodeExpand(object sender, TreeNodeEventArgs e)
{
e.Node.Nodes.Clear();
if (e.Node.CommandName == "project") //展开项目节点
{
var installations = from x in Funs.DB.Project_Installation
where x.ProjectId == e.Node.NodeID && x.SuperInstallationId == "0"
orderby x.InstallationCode
select x;
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
2021-10-22 10:10:15 +08:00
newNode.Text = "[" + installation.InstallationCode + "]" + installation.InstallationName;
2021-04-30 10:28:37 +08:00
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var installation2s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation.InstallationId orderby x.InstallationCode select x;
if (installation2s.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
else if (e.Node.CommandName == "installation") //展开装置/单元节点
{
var installations = from x in Funs.DB.Project_Installation
where x.SuperInstallationId == e.Node.NodeID
orderby x.InstallationCode
select x;
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
2021-10-22 10:10:15 +08:00
newNode.Text = "[" + installation.InstallationCode + "]" + installation.InstallationName;
2021-04-30 10:28:37 +08:00
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation.InstallationId orderby x.InstallationCode select x;
if (installation3s.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
}
#endregion
#region Tree点击事件
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trProjects_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (this.Grid1.Rows.Count > 0)
{
SaveData();
}
BindGrid();
}
#endregion
#region
/// <summary>
/// 保存方法
/// </summary>
private void SaveData()
{
//string rowId = this.Grid1.Rows[0].RowID;
//string type = this.Grid1.Rows[0].Values[4].ToString();
//if (type == "unitProject")
//{
// Model.Wbs_UnitProjectInit unitProject = BLL.UnitProjectInitService.GetUnitProjectInitByUnitProjectCode(rowId);
// if (unitProject != null)
// {
// BLL.UnitProjectInitService.UpdateUnitProjectInit(unitProject);
// }
//}
//else if (type == "wbsSet")
//{
// Model.WBS_WbsSetInit wbsSet = BLL.WbsSetInitService.GetWbsSetInitByWbsSetCode(rowId);
// if (wbsSet != null)
// {
// var childWbsSets = BLL.WbsSetInitService.GetWbsSetInitsBySuperWbsSetCode(this.trProjects.SelectedNodeID);
// //wbsSet.StartDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
// //wbsSet.EndDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
// BLL.WbsSetInitService.UpdateWbsSetInit(wbsSet);
// }
//}
}
#endregion
#region
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
ShowNotify("修改成功!", MessageBoxIcon.Success);
getWBSSet();
}
#endregion
#region
/// <summary>
/// 拷贝关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window2_Close(object sender, WindowCloseEventArgs e)
{
ShowNotify("增加成功!", MessageBoxIcon.Success);
getWBSSet();
}
#endregion
2021-10-19 17:50:34 +08:00
#region
/// <summary>
/// 抽取
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDown_Click(object sender, EventArgs e)
{
if (this.trProjects.SelectedNode != null)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnAdd))
{
2025-02-11 09:19:08 +08:00
Model.SGGLDB db = Funs.DB;
Model.JDGL_WBS wbs1 = db.JDGL_WBS.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId);
if (wbs1 != null)
2022-01-10 10:55:18 +08:00
{
2025-02-11 09:19:08 +08:00
ShowNotify("项目已存在数据,无法抽取!", MessageBoxIcon.Warning);
2022-01-10 10:55:18 +08:00
return;
}
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
2021-10-19 17:50:34 +08:00
string contenttype = "application/json;charset=utf-8";
2025-02-11 09:19:08 +08:00
var returndata0 = BLL.APIGetHttpService.ControlHttp(Funs.ControlApiUrl + "/project/api/hcoud-wuhuan/projectwbsconstruct/constructionTree?wuId=" + project.KZProjectCode, "GET", contenttype, null, null);
var returndata1 = BLL.APIGetHttpService.ControlHttp(Funs.ControlApiUrl + "/project/api/hcoud-wuhuan/projectwbsconstruct/checkPointList?wuId=" + project.KZProjectCode, "GET", contenttype, null, null);
List<Model.JDGL_WBS> wbss = new List<Model.JDGL_WBS>();
List<Model.JDGL_WBSDetail> wbsDetails = new List<Model.JDGL_WBSDetail>();
2023-10-07 16:58:43 +08:00
if (!string.IsNullOrEmpty(returndata0))
2021-10-22 10:10:15 +08:00
{
2023-10-07 16:58:43 +08:00
JObject obj0 = JObject.Parse(returndata0);
2025-02-11 09:19:08 +08:00
if (obj0["code"].ToString() == "200")
2021-10-22 10:10:15 +08:00
{
2025-02-11 09:19:08 +08:00
JArray arr0 = JArray.Parse(obj0["data"].ToString());
string proId = string.Empty;
List<string> list = new List<string>();
foreach (var item in arr0)
2021-10-22 10:10:15 +08:00
{
2025-02-11 09:19:08 +08:00
Model.JDGL_WBS wBS = new Model.JDGL_WBS();
wBS.Id = item["id"].ToString();
wBS.ProjectId = this.CurrUser.LoginProjectId;
wBS.ParentId = item["parentId"].ToString();
wBS.Leave = Funs.GetNewInt(item["leave"].ToString());
wBS.PathCode = item["pathCode"].ToString();
wBS.ItemName = item["itemName"].ToString();
wBS.PlanQuantities = Funs.GetNewDecimal(item["planQuantities"].ToString());
wBS.PlanEnd = Funs.GetNewDateTime(item["planEnd"].ToString());
wBS.RealityEnd = Funs.GetNewDateTime(item["realityEnd"].ToString());
wBS.RealityPrice = Funs.GetNewDecimal(item["realityPrice"].ToString());
wBS.Total= Funs.GetNewDecimal(item["total"].ToString());
wBS.Num = Funs.GetNewDecimal(item["num"].ToString());
wBS.Cycle = item["cycle"].ToString();
wBS.PlanPrice= Funs.GetNewDecimal(item["planPrice"].ToString());
if (!list.Contains(wBS.Id))
{
wbss.Add(wBS);
list.Add(wBS.Id);
}
2021-10-22 10:10:15 +08:00
}
2025-02-11 09:19:08 +08:00
//InitTreeMenu();
2023-10-07 16:58:43 +08:00
}
2025-02-11 09:19:08 +08:00
}
if (!string.IsNullOrEmpty(returndata1))
{
JObject obj0 = JObject.Parse(returndata1);
if (obj0["code"].ToString() == "200")
2023-10-07 16:58:43 +08:00
{
2025-02-11 09:19:08 +08:00
JArray arr0 = JArray.Parse(obj0["data"].ToString());
string proId = string.Empty;
List<string> list = new List<string>();
foreach (var item in arr0)
2021-10-22 10:10:15 +08:00
{
2025-02-11 09:19:08 +08:00
Model.JDGL_WBSDetail wBSDetail = new Model.JDGL_WBSDetail();
wBSDetail.Id = item["id"].ToString();
wBSDetail.ProjectId = this.CurrUser.LoginProjectId;
wBSDetail.CompletionTime = Funs.GetNewDateTime(item["completionTime"].ToString());
wBSDetail.WorkPackageId = item["workPackageId"].ToString();
wBSDetail.Name = item["name"].ToString();
wBSDetail.RealityCompletePercent = Funs.GetNewDecimal(item["realityCompletePercent"].ToString());
2025-02-14 11:53:03 +08:00
if (!list.Contains(wBSDetail.Id))
{
wbsDetails.Add(wBSDetail);
list.Add(wBSDetail.Id);
}
2021-10-22 10:10:15 +08:00
}
2025-02-11 09:19:08 +08:00
//InitTreeMenu();
2021-10-22 10:10:15 +08:00
}
}
2025-02-11 09:19:08 +08:00
db.JDGL_WBS.InsertAllOnSubmit(wbss);
2025-02-14 11:53:03 +08:00
db.JDGL_WBSDetail.InsertAllOnSubmit(wbsDetails);
2025-02-11 09:19:08 +08:00
db.SubmitChanges();
ShowNotify("抽取成功!", MessageBoxIcon.Success);
2021-10-19 17:50:34 +08:00
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
2021-04-30 10:28:37 +08:00
/// <summary>
/// 右键修改事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (this.trProjects.SelectedNode != null && this.trProjects.SelectedNode.CommandName != "project")
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnModify))
{
if (this.trProjects.SelectedNode.Text != "总图") //非专业节点可以修改
{
this.hdSelectId.Text = this.trProjects.SelectedNode.NodeID;
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("InstallationSave.aspx?operating=modify&Id={0}", this.trProjects.SelectedNode.NodeID, "编辑 - ")));
}
else
{
ShowNotify("总图节点无法修改!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("项目节点无法修改!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 增加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuAdd_Click(object sender, EventArgs e)
{
if (this.trProjects.SelectedNode != null)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnAdd))
{
if (BLL.Project_InstallationService.IsCanAddInstallation(this.trProjects.SelectedNode.NodeID) && this.trProjects.SelectedNode.Text != "总图") //可增加子级
{
string openUrl = String.Format("InstallationSave.aspx?operating=add&SuperId={0}", this.trProjects.SelectedNode.NodeID, "增加 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
//PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WBSSetCopy.aspx?Id={0}&Type={1}", this.trProjects.SelectedNode.NodeID, this.trProjects.SelectedNode.CommandName, "拷贝 - ")));
}
else
{
2021-08-13 11:15:59 +08:00
ShowNotify("总图和末级节点无法增加子级!", MessageBoxIcon.Warning);
2021-04-30 10:28:37 +08:00
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (this.trProjects.SelectedNode != null)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnDelete))
{
if (this.trProjects.SelectedNode.CommandName != "project") //非专业节点可以删除
{
string id = this.trProjects.SelectedNode.NodeID;
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(id);
if (installation.SuperInstallationId == "0") //删除一级装置
{
2022-03-23 09:55:32 +08:00
if (installation.InstallationName == "总图" || installation.InstallationName == "防腐绝热" || installation.InstallationName == "地勘" || installation.InstallationName == "临时设施" || installation.InstallationName == "全厂地下主管网")
2021-04-30 10:28:37 +08:00
{
DeleteZTData(installation.InstallationId);
}
else
{
2021-08-13 11:15:59 +08:00
DeleteBaseData(id);
2021-04-30 10:28:37 +08:00
}
}
else
{
2021-08-13 11:15:59 +08:00
DeleteBaseData(id);
2021-04-30 10:28:37 +08:00
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
InitTreeMenu();
}
else
{
ShowNotify("项目节点无法删除!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
2021-08-13 11:15:59 +08:00
private void DeleteBaseData(string installationId)
{
2021-10-19 17:50:34 +08:00
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(installationId);
2021-08-13 11:15:59 +08:00
if (installation.IsEnd == false)
{
BLL.Project_InstallationService.DeleteInstallation(installationId);
var installations = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installationId select x;
foreach (var item in installations)
{
DeleteBaseData(item.InstallationId);
}
}
else
{
DeleteData(installationId);
}
}
2021-04-30 10:28:37 +08:00
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData(string installationId)
{
var wbsSets = (from x in Funs.DB.Wbs_WbsSet join y in Funs.DB.WBS_CnProfession on x.CnProfessionId equals y.CnProfessionId where y.InstallationId == installationId && x.CnProfessionId != null select x).ToList();
foreach (var wbsSet in wbsSets)
{
2021-08-13 11:15:59 +08:00
BLL.CostControlService.DeleteCostControlByWbsSetId(wbsSet.WbsSetId); //删除费控项
2021-04-30 10:28:37 +08:00
BLL.WbsDetailHistoryService.DeleteWbsDetailHistoryByToWbs(wbsSet.WbsSetId); //删除进度历史版本记录
BLL.WbsDetailService.DeleteWbsDetailByToWbs(wbsSet.WbsSetId); //删除进度记录
BLL.WbsSetService.DeleteWbsSet(wbsSet.WbsSetId);
2021-08-13 11:15:59 +08:00
BLL.WbsSetMatchCostControlService.DeleteWbsSetMatchCostControlByWbsSetId(wbsSet.WbsSetId); //删除费控项对应关系
2021-04-30 10:28:37 +08:00
}
//删除单位工程及子单位工程
var unitProjects = from x in Funs.DB.Wbs_UnitProject join y in Funs.DB.WBS_CnProfession on x.CnProfessionId equals y.CnProfessionId where y.InstallationId == installationId && x.CnProfessionId != null select x;
foreach (var unitProject in unitProjects)
{
BLL.WbsDetailService.DeleteWbsDetailByToWbs(unitProject.UnitProjectId); //删除进度记录
BLL.UnitProjectService.DeleteUnitProject(unitProject.UnitProjectId);
}
//删除专业
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == installationId select x;
foreach (var cnProfession in cnProfessions)
{
BLL.WbsDetailService.DeleteWbsDetailByToWbs(cnProfession.CnProfessionId); //删除进度记录
BLL.CnProfessionService.DeleteCnProfession(cnProfession.CnProfessionId);
}
BLL.WbsDetailService.DeleteWbsDetailByToWbs(installationId); //删除进度记录
BLL.Project_InstallationService.DeleteInstallation(installationId);
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteZTData(string installationId)
{
var wbsSets = (from x in Funs.DB.Wbs_WbsSet where x.InstallationId == installationId && x.CnProfessionId == null select x).ToList();
foreach (var wbsSet in wbsSets)
{
2022-03-23 09:55:32 +08:00
BLL.CostControlService.DeleteCostControlByWbsSetId(wbsSet.WbsSetId); //删除费控项
2021-04-30 10:28:37 +08:00
BLL.WbsDetailHistoryService.DeleteWbsDetailHistoryByToWbs(wbsSet.WbsSetId); //删除进度历史版本记录
BLL.WbsDetailService.DeleteWbsDetailByToWbs(wbsSet.WbsSetId); //删除进度记录
BLL.WbsSetService.DeleteWbsSet(wbsSet.WbsSetId);
2022-03-23 09:55:32 +08:00
BLL.WbsSetMatchCostControlService.DeleteWbsSetMatchCostControlByWbsSetId(wbsSet.WbsSetId); //删除费控项对应关系
2021-04-30 10:28:37 +08:00
}
//删除单位工程及子单位工程
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.InstallationId == installationId && x.CnProfessionId == null select x;
foreach (var unitProject in unitProjects)
{
BLL.WbsDetailService.DeleteWbsDetailByToWbs(unitProject.UnitProjectId); //删除进度记录
BLL.UnitProjectService.DeleteUnitProject(unitProject.UnitProjectId);
}
//删除专业
//var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == installationId select x;
//foreach (var cnProfession in cnProfessions)
//{
// BLL.WbsDetailService.DeleteWbsDetailByToWbs(cnProfession.CnProfessionId); //删除进度记录
// BLL.CnProfessionService.DeleteCnProfession(cnProfession.CnProfessionId);
//}
BLL.WbsDetailService.DeleteWbsDetailByToWbs(installationId); //删除进度记录
BLL.Project_InstallationService.DeleteInstallation(installationId);
}
#endregion
#region
/// <summary>
/// 保存事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnSave))
{
if (this.Grid1.Rows.Count > 0)
{
SaveData();
Alert.ShowInTop("保存成功!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 绑定数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// Grid1排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
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>
/// 加载Grid
/// </summary>
private void BindGrid()
{
List<Model.WBSSetInitItem> items = new List<Model.WBSSetInitItem>();
if (this.trProjects.SelectedNode != null)
{
if (this.trProjects.SelectedNode.CommandName == "installation")
{
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(this.trProjects.SelectedNode.NodeID);
Model.WBSSetInitItem item = new Model.WBSSetInitItem();
if (installation != null)
{
item.Code = installation.InstallationCode;
item.Name = installation.InstallationName;
item.StartDate = installation.StartDate;
item.EndDate = installation.EndDate;
item.Type = "installation";
items.Add(item);
}
}
this.Grid1.DataSource = items;
this.Grid1.DataBind();
}
}
#endregion
#region Id定位到对应装置
/// <summary>
/// 根据所给Id定位到对应装置
/// </summary>
private void getWBSSet()
{
string installationId = string.Empty;
string pInstallationId = string.Empty;
string ppInstallationId = string.Empty;
string projectId = this.CurrUser.LoginProjectId;
string id = this.hdSelectId.Text;
2021-08-13 11:15:59 +08:00
//Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(id);
//if (installation.SuperInstallationId == "0") //一级装置
//{
// ppInstallationId = id;
//}
//else
//{
// if (BLL.Project_InstallationService.IsCanAddInstallation(id)) //二级装置
// {
// pInstallationId = id;
// ppInstallationId = installation.SuperInstallationId;
// }
// else //三级装置
// {
// installationId = id;
// pInstallationId = installation.SuperInstallationId;
// Model.Project_Installation pInstallation = BLL.Project_InstallationService.GetInstallationByInstallationId(installation.SuperInstallationId);
// if (pInstallation != null)
// {
// ppInstallationId = pInstallation.SuperInstallationId;
// }
// }
//}
string ids = BLL.Project_InstallationService.GetParentInstallationIds(id);
2021-04-30 10:28:37 +08:00
this.trProjects.Nodes.Clear();
this.trProjects.ShowBorder = false;
this.trProjects.ShowHeader = false;
this.trProjects.EnableIcons = true;
this.trProjects.AutoScroll = true;
this.trProjects.EnableSingleClickExpand = true;
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
TreeNode node = new TreeNode();
node.Text = project.ProjectName;
node.NodeID = project.ProjectId;
node.EnableClickEvent = true;
this.trProjects.Nodes.Add(node);
node.Expanded = true;
var installation1s = from x in Funs.DB.Project_Installation
where x.ProjectId == projectId && x.SuperInstallationId == "0"
orderby x.InstallationCode
select x;
foreach (var installation1 in installation1s)
{
TreeNode newNode1 = new TreeNode();
newNode1.Text = installation1.InstallationName;
newNode1.NodeID = installation1.InstallationId;
newNode1.CommandName = "installation";
newNode1.EnableExpandEvent = true;
newNode1.EnableClickEvent = true;
node.Nodes.Add(newNode1);
2021-08-13 11:15:59 +08:00
if (ids.Contains(installation1.InstallationId))
2021-04-30 10:28:37 +08:00
{
newNode1.Expanded = true;
var installation2s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation1.InstallationId orderby x.InstallationCode select x;
foreach (var installation2 in installation2s)
{
TreeNode newNode2 = new TreeNode();
newNode2.Text = installation2.InstallationName;
newNode2.NodeID = installation2.InstallationId;
newNode2.CommandName = "installation";
newNode2.EnableExpandEvent = true;
newNode2.EnableClickEvent = true;
newNode1.Nodes.Add(newNode2);
2021-08-13 11:15:59 +08:00
if (ids.Contains(installation2.InstallationId))
2021-04-30 10:28:37 +08:00
{
newNode2.Expanded = true;
var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation2.InstallationId orderby x.InstallationCode select x;
foreach (var installation3 in installation3s)
{
TreeNode newNode3 = new TreeNode();
newNode3.Text = installation3.InstallationName;
newNode3.NodeID = installation3.InstallationId;
newNode3.CommandName = "installation";
newNode3.EnableExpandEvent = true;
newNode3.EnableClickEvent = true;
newNode2.Nodes.Add(newNode3);
2021-08-13 11:15:59 +08:00
if (ids.Contains(installation3.InstallationId))
{
newNode3.Expanded = true;
var installation4s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation3.InstallationId orderby x.InstallationCode select x;
foreach (var installation4 in installation4s)
{
TreeNode newNode4 = new TreeNode();
newNode4.Text = installation4.InstallationName;
newNode4.NodeID = installation4.InstallationId;
newNode4.CommandName = "installation";
newNode4.EnableExpandEvent = true;
newNode4.EnableClickEvent = true;
newNode3.Nodes.Add(newNode4);
if (ids.Contains(installation4.InstallationId))
{
newNode4.Expanded = true;
var installation5s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation4.InstallationId orderby x.InstallationCode select x;
foreach (var installation5 in installation5s)
{
TreeNode newNode5 = new TreeNode();
newNode5.Text = installation5.InstallationName;
newNode5.NodeID = installation5.InstallationId;
newNode5.CommandName = "installation";
newNode5.EnableExpandEvent = true;
newNode5.EnableClickEvent = true;
newNode4.Nodes.Add(newNode5);
}
}
else
{
if (BLL.Project_InstallationService.IsExitsInstallationsBySuperInstallationId(installation4.InstallationId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode4.Nodes.Add(emptyNode);
}
}
}
}
else
{
if (BLL.Project_InstallationService.IsExitsInstallationsBySuperInstallationId(installation3.InstallationId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode3.Nodes.Add(emptyNode);
}
}
2021-04-30 10:28:37 +08:00
}
}
else
{
if (BLL.Project_InstallationService.IsExitsInstallationsBySuperInstallationId(installation2.InstallationId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode2.Nodes.Add(emptyNode);
}
}
}
}
else
{
if (BLL.Project_InstallationService.IsExitsInstallationsBySuperInstallationId(installation1.InstallationId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode1.Nodes.Add(emptyNode);
}
}
}
}
this.trProjects.SelectedNodeID = this.hdSelectId.Text;
BindGrid();
}
#endregion
}
}