diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs index 40d7779..2bda638 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -182,6 +182,13 @@ namespace Sinvo.EplanHpD.Plugin.Service try { var motor = GetMotorByFlag(motorUniqueFlag);//.FirstOrDefault(m => m.OccPartId == Motor.OccPartId); + // 电机不为空 且不等于当前电机的型号,则清空再重新加入 + if(motor != null && motor.MotorModelStr != data.Motor.MotorModelStr) + { + db.Deleteable().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand(); + motor = null; + } + if (motor == null) { motor = new Motor @@ -197,7 +204,9 @@ namespace Sinvo.EplanHpD.Plugin.Service MotorUniqueFlag = motorUniqueFlag, CableLectotypeLines = [] }; - AddMotor(motor); + //AddMotor(motor); + // 插入新电机信息 + db.Insertable(motor).ExecuteCommand(); } else {