对比新文件 |
| | |
| | | 锘縰sing Yw.DAL.PostgreSql; |
| | | |
| | | namespace HStation.DAL.PostgreSql |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class PumpSeries : BaseDAL_Paras_Flags_TagName_Sorter_UseStatus<Entity.PumpSeries>, IPumpSeries |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public override ConnectionConfig ConnectionConfig |
| | | { |
| | | get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } |
| | | } |
| | | |
| | | //鍒犻櫎鎷撳睍 |
| | | public bool DeleteEx(long ID) |
| | | { |
| | | if (ID < 0) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var project = db.Queryable<Entity.PumpSeries>().ToList().Find(x => x.ID == ID); |
| | | var result = db.Deleteable(project).ExecuteCommand() > 0; |
| | | if (!result) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | else |
| | | { |
| | | var group = db.Queryable<Entity.PumpGroup>().ToList().Find(x => x.PumpSeriesID == project.ID); |
| | | if (group != null) |
| | | { |
| | | var groupresult = db.Deleteable(group).ExecuteCommand() > 0; |
| | | if (!groupresult) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | else |
| | | { |
| | | var map = db.Queryable<Entity.PumpGroupAndMainMap>() |
| | | .Where(x => x.PumpGroupID == group.ID) |
| | | .ToList(); |
| | | var listid = db.Queryable<Entity.PumpGroupAndMainMap>() |
| | | .Where(x => x.PumpGroupID == group.ID) |
| | | .Select(x => x.PumpMainID) |
| | | .ToList(); |
| | | if (map.Count > 0) |
| | | { |
| | | var Modelresult = db.Deleteable(map).ExecuteCommand() > 0; |
| | | if (!Modelresult) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | else |
| | | { |
| | | var main = db.Queryable<Entity.PumpMain>().ToList(); |
| | | foreach (var item in main) |
| | | { |
| | | if (item.PumpSeriesID == project.ID) |
| | | { |
| | | listid.Add(item.ID); |
| | | } |
| | | } |
| | | var mainresult = db.Deleteable<Entity.PumpMain>() |
| | | .In(x => x.ID, listid) |
| | | .ExecuteCommand() > 0; |
| | | if (!mainresult) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var listid = new List<long>(); |
| | | var main = db.Queryable<Entity.PumpMain>().ToList(); |
| | | foreach (var item in main) |
| | | { |
| | | if (item.PumpSeriesID == project.ID) |
| | | { |
| | | listid.Add(item.ID); |
| | | } |
| | | } |
| | | if (listid.Count > 0) |
| | | { |
| | | var mainresult = db.Deleteable<Entity.PumpMain>() |
| | | .In(x => x.ID, listid) |
| | | .ExecuteCommand() > 0; |
| | | if (!mainresult) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |