Browse Source

增加删除操作

master
luanhui 8 years ago
parent
commit
5392f9388d
2 changed files with 48 additions and 1 deletions
  1. +3
    -0
      B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs
  2. +45
    -1
      B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs

+ 3
- 0
B3ClientService/BO/Bill/GradeAndWeight/GradeAndWeight_Detail.cs View File

@ -27,5 +27,8 @@ namespace BWP.B3ClientService.BO
public decimal? Weight { get; set; } public decimal? Weight { get; set; }
public DateTime Time { get; set; } public DateTime Time { get; set; }
[NonDmoProperty]
public bool IsDeleted { get; set; }
} }
} }

+ 45
- 1
B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs View File

@ -64,11 +64,55 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
return serializer.Serialize(list); 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] [Rpc]
public static long UpdateOrInsertDetail(string json)
public static long UpdateOrInsertDetailOrDelete(string json)
{ {
json = json.ESerializeDateTime(); json = json.ESerializeDateTime();
var entity = serializer.Deserialize<GradeAndWeight_Detail>(json); var entity = serializer.Deserialize<GradeAndWeight_Detail>(json);
if (entity.IsDeleted)
{
return DeleteDetail(entity);
}
else
{
return UpdateOrInsertDetail(entity);
}
}
static long UpdateOrInsertDetail(GradeAndWeight_Detail entity)
{
using (var session = Dmo.NewSession()) using (var session = Dmo.NewSession())
{ {
if (entity.ID == 0) if (entity.ID == 0)


Loading…
Cancel
Save