From c476c9cf07c1b1920cc4bf51f60a78f5768c30fa Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 23 十二月 2024 19:41:33 +0800 Subject: [PATCH] 实体变化引起变更 --- Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs b/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs index 919c5bc..836c647 100644 --- a/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs +++ b/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs @@ -103,11 +103,16 @@ { //濡傛灉瀹㈡埛缂栫爜涓虹┖ prodTemp = input.Label; - if (ltemp != null && (ltemp.PROD_CODE.IsNullOrEmpty() || ltemp.PROD_CODE != input.Label.PROD_CODE)) + if (ltemp != null && ltemp.PROD_CODE.IsNullOrEmpty() && ltemp.PROD_CODE != input.Label.PROD_CODE) { prodTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); } } + var labelVarIds = input.LabelVars.Select(x => x.VAR_NAME).ToList(); + var labelVars = Biz.Db.Queryable<BAS_LABEL_VAR>() + .Where(q=> q.LABEL_ID == ltemp.ID) + .WhereIF(labelVarIds.Count>0, q=> !labelVarIds.Contains(q.VAR_NAME)) + .ToList(); var db = Biz.Db; var dbTran = db.UseTran(() => { @@ -131,6 +136,11 @@ x.LABEL_CODE == input.Label.LABEL_CODE && x.PROD_CODE == input.Label.PROD_CODE && x.CUST_CODE == input.Label.CUST_CODE).First(); + //鍒犻櫎涓嶅湪浼犲叆鍒楄〃涓殑 + if (labelVars.Count>0) + { + db.Deleteable(labelVars).ExecuteCommand(); + } if (input.LabelVars != null && input.LabelVars.Count > 0) { if (temp != null && temp.ID != input.LabelVars[0].LABEL_ID) @@ -146,6 +156,10 @@ z.AsInsertable.ExecuteCommand(); z.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); } + if (!input.LabelVars.Any()) + { + db.Deleteable(labelVars).ExecuteCommand(); + } if (input.LabelVarWos != null && input.LabelVarWos.Count > 0) { if (temp != null && temp.ID != input.LabelVarWos[0].LABEL_ID) -- Gitblit v1.9.3