From 5392f9388d80d2049ba46dd60ac7ae6118c0b66b Mon Sep 17 00:00:00 2001 From: luanhui <1029149336@qq.com> Date: Mon, 13 Nov 2017 13:38:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GradeAndWeight/GradeAndWeight_Detail.cs | 3 ++ .../Rpcs/BillRpc/GradeAndWeightRpc.cs | 46 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs b/B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs index dff5178..2193401 100644 --- a/B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs +++ b/B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs @@ -27,5 +27,8 @@ namespace BWP.B3ClientService.BO public decimal? Weight { get; set; } public DateTime Time { get; set; } + + [NonDmoProperty] + public bool IsDeleted { get; set; } } } diff --git a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs index 7da64c6..610ae14 100644 --- a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs @@ -64,11 +64,55 @@ namespace BWP.B3ClientService.Rpcs.BillRpc return serializer.Serialize(list); } + + static long DeleteDetail(GradeAndWeight_Detail entity) + { + using (var session = Dmo.NewSession()) + { + if(entity.ID>0) + { + session.Delete(new DmoIdentity(typeof(GradeAndWeight_Detail), entity.ID)); + if (entity.OrderDetail_ID.HasValue) + { + SubAlready(session, entity.OrderDetail_ID.Value, entity.Technics); + } + } + session.Commit(); + return entity.ID; + } + } + + static void SubAlready(IDmoSession session, long orderDetailID, short technics) + { + var entity = GetRelate(orderDetailID, technics); + if (entity != null) + { + entity.Already -= 1; + session.Update(entity); + } + + } + + + [Rpc] - public static long UpdateOrInsertDetail(string json) + public static long UpdateOrInsertDetailOrDelete(string json) { json = json.ESerializeDateTime(); var entity = serializer.Deserialize(json); + if (entity.IsDeleted) + { + return DeleteDetail(entity); + } + else + { + return UpdateOrInsertDetail(entity); + } + } + + + static long UpdateOrInsertDetail(GradeAndWeight_Detail entity) + { using (var session = Dmo.NewSession()) { if (entity.ID == 0)