DeleteMattressExtraExcutor.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Data.SqlClient;
  3. using System.Linq;
  4. using JLHHJSvr.BLL;
  5. using JLHHJSvr.Com;
  6. using JLHHJSvr.LJException;
  7. using LJLib.DAL.SQL;
  8. using LJLib.Net.SPI.Server;
  9. using LJLib.SQLEX;
  10. namespace JLHHJSvr.Excutor
  11. {
  12. internal sealed class DeleteMattressExtraExcutor : ExcutorBase<DeleteMattressExtraRequest, DeleteMattressExtraResponse>
  13. {
  14. protected override void ExcuteInternal(DeleteMattressExtraRequest request, object state, DeleteMattressExtraResponse rslt)
  15. {
  16. var tokendata = BllHelper.GetToken(request.token);
  17. if (tokendata == null)
  18. {
  19. rslt.ErrMsg = "会话已经中断,请重新登录";
  20. return;
  21. }
  22. if (!request.list.Any())
  23. {
  24. rslt.ErrMsg = "至少提交一条需要删除的记录";
  25. return;
  26. }
  27. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  28. using (var cmd = con.CreateCommand())
  29. {
  30. con.Open();
  31. using (cmd.Transaction = con.BeginTransaction())
  32. {
  33. try
  34. {
  35. foreach (var area in request.list)
  36. {
  37. if (DbSqlHelper.Delete(cmd, area) == 0)
  38. {
  39. throw new LJCommonException($"床垫额外费用类型定义资料不存在");
  40. }
  41. }
  42. cmd.Transaction.Commit();
  43. }
  44. catch (Exception e)
  45. {
  46. cmd.Transaction.Rollback();
  47. rslt.ErrMsg = e.ToString();
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }