DeleteMattressExtraExcutor.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if (!request.list.Any())
  17. {
  18. rslt.ErrMsg = "至少提交一条需要删除的记录";
  19. return;
  20. }
  21. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  22. using (var cmd = con.CreateCommand())
  23. {
  24. con.Open();
  25. using (cmd.Transaction = con.BeginTransaction())
  26. {
  27. try
  28. {
  29. foreach (var area in request.list)
  30. {
  31. if (DbSqlHelper.Delete(cmd, area) == 0)
  32. {
  33. throw new LJCommonException($"床垫额外费用类型定义资料不存在");
  34. }
  35. }
  36. cmd.Transaction.Commit();
  37. }
  38. catch (Exception e)
  39. {
  40. cmd.Transaction?.Rollback();
  41. rslt.ErrMsg = e.Message;
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }