diff --git a/HJGL_DS/BLL/Common/SysManage/Sys_UserSettingsService.cs b/HJGL_DS/BLL/Common/SysManage/Sys_UserSettingsService.cs index 1939117..31a9522 100644 --- a/HJGL_DS/BLL/Common/SysManage/Sys_UserSettingsService.cs +++ b/HJGL_DS/BLL/Common/SysManage/Sys_UserSettingsService.cs @@ -260,17 +260,21 @@ namespace BLL { foreach (var item in unitItemList) { - var pUnit = new Model.Project_Unit(); - pUnit.ProjectUnitId = Guid.NewGuid().ToString(); - pUnit.ProjectId = projectid; - pUnit.UnitId = item.UnitId; - //单位类型 - var bresult = bUnit.FirstOrDefault(x => x.UnitId == item.UnitId && x.UnitType != null && x.UnitType != ""); - if (bresult != null) + var projectUnit = from x in Funs.DB.Project_Unit where x.ProjectId == projectid && x.UnitId == item.UnitId select x; + if (projectUnit == null) { - pUnit.UnitType = bresult.UnitType; + var pUnit = new Model.Project_Unit(); + pUnit.ProjectUnitId = Guid.NewGuid().ToString(); + pUnit.ProjectId = projectid; + pUnit.UnitId = item.UnitId; + //单位类型 + var bresult = bUnit.FirstOrDefault(x => x.UnitId == item.UnitId && x.UnitType != null && x.UnitType != ""); + if (bresult != null) + { + pUnit.UnitType = bresult.UnitType; + } + AddProject_Unit.Add(pUnit); } - AddProject_Unit.Add(pUnit); } } }