From d3116638f63b7696b93b498c29501c9d280a223d Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Mon, 20 Feb 2023 16:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=A0=E9=99=A4=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectData/Installation.aspx.cs | 98 ++++++++++++------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/SGGL/FineUIPro.Web/ProjectData/Installation.aspx.cs b/SGGL/FineUIPro.Web/ProjectData/Installation.aspx.cs index 7d206f3e..2097a054 100644 --- a/SGGL/FineUIPro.Web/ProjectData/Installation.aspx.cs +++ b/SGGL/FineUIPro.Web/ProjectData/Installation.aspx.cs @@ -9,6 +9,7 @@ using System.Web.UI.WebControls; using BLL; using Newtonsoft.Json.Linq; using Model; +using FineUIPro.Web.BaseInfo; namespace FineUIPro.Web.ProjectData { @@ -313,45 +314,72 @@ namespace FineUIPro.Web.ProjectData { string id = this.trProjects.SelectedNode.NodeID; Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(id); - if (installation.SuperInstallationId == "0") //删除一级装置 + if (installation != null) { - if (installation.InstallationName == "总图") - { - DeleteZTData(installation.InstallationId); - } - else - { - BLL.Project_InstallationService.DeleteInstallation(id); - var installation2s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == id select x; - foreach (var installation2 in installation2s) - { - BLL.Project_InstallationService.DeleteInstallation(installation2.InstallationId); - var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation2.InstallationId select x; - foreach (var installation3 in installation3s) - { - DeleteData(installation3.InstallationId); - } - } - } + ShowNotify("已关联项目无法删除!", MessageBoxIcon.Warning); + return; } - else + var cnProfession = Funs.DB.WBS_CnProfession.FirstOrDefault(x => x.InstallationId == id); + if (cnProfession != null) { - Model.Project_Installation installation2 = BLL.Project_InstallationService.GetInstallationByInstallationId(id); - Model.Project_Installation installation1 = BLL.Project_InstallationService.GetInstallationByInstallationId(installation2.SuperInstallationId); - if (installation1.SuperInstallationId == "0") //删除二级装置 - { - BLL.Project_InstallationService.DeleteInstallation(id); - var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == id select x; - foreach (var installation3 in installation3s) - { - DeleteData(installation3.InstallationId); - } - } - else //删除二级装置 - { - DeleteData(id); - } + ShowNotify("已关联专业无法删除!", MessageBoxIcon.Warning); + return; } + var unitWorks = (from x in Funs.DB.WBS_UnitWork where x.InstallationId == id select x).ToList(); + if (unitWorks != null) + { + ShowNotify("已关联单位工程无法删除!", MessageBoxIcon.Warning); + return; + } + + var workArea = (from x in Funs.DB.ProjectData_WorkArea where x.InstallationId == id select x).ToList(); + if (workArea != null) + { + ShowNotify("已关联施工区域无法删除!", MessageBoxIcon.Warning); + return; + } + + //if (installation.SuperInstallationId == "0") //删除一级装置 + //{ + // if (installation.InstallationName == "总图") + // { + // DeleteZTData(installation.InstallationId); + // } + // else + // { + // BLL.Project_InstallationService.DeleteInstallation(id); + // var installation2s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == id select x; + // foreach (var installation2 in installation2s) + // { + // BLL.Project_InstallationService.DeleteInstallation(installation2.InstallationId); + // var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == installation2.InstallationId select x; + // foreach (var installation3 in installation3s) + // { + // DeleteData(installation3.InstallationId); + // } + // } + // } + //} + //else + //{ + // Model.Project_Installation installation2 = BLL.Project_InstallationService.GetInstallationByInstallationId(id); + // Model.Project_Installation installation1 = BLL.Project_InstallationService.GetInstallationByInstallationId(installation2.SuperInstallationId); + // if (installation1.SuperInstallationId == "0") //删除二级装置 + // { + // BLL.Project_InstallationService.DeleteInstallation(id); + // var installation3s = from x in Funs.DB.Project_Installation where x.SuperInstallationId == id select x; + // foreach (var installation3 in installation3s) + // { + // DeleteData(installation3.InstallationId); + // } + // } + // else //删除二级装置 + // { + // DeleteData(id); + // } + //} + + BLL.Project_InstallationService.DeleteInstallation(id); ShowNotify("删除成功!", MessageBoxIcon.Success); InitTreeMenu(); }