DelMattressExcutor.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using JLHHJSvr.BLL;
  7. using JLHHJSvr.Com;
  8. using JLHHJSvr.Com.Model;
  9. using JLHHJSvr.LJException;
  10. using JLHHJSvr.Tools;
  11. using LJLib.DAL.SQL;
  12. using LJLib.Net.SPI.Server;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class DelMattressExcutor : ExcutorBase<DelMattressRequest, DelMattressResponse>
  16. {
  17. protected override void ExcuteInternal(DelMattressRequest request, object state, DelMattressResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (tokendata == null)
  21. {
  22. rslt.ErrMsg = "会话已经中断,请重新登录";
  23. return;
  24. }
  25. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  26. using (var cmd = con.CreateCommand())
  27. {
  28. con.Open();
  29. // 初始化属性
  30. //AutoInit.AutoInitS(cmd, request.mattress);
  31. using (cmd.Transaction = con.BeginTransaction())
  32. {
  33. try
  34. {
  35. var power77 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 77);
  36. if (!power77)
  37. {
  38. throw new LJCommonException("你没有删除权限");
  39. }
  40. foreach (int itemid in request.mattressids)
  41. {
  42. var mattressInfo = new u_mattress() { mattressid = itemid };
  43. if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag, js1_flag") != 1)
  44. {
  45. rslt.ErrMsg = "查找报价单据失败:" + itemid;
  46. return;
  47. }
  48. if (mattressInfo.flag == 1)
  49. {
  50. rslt.ErrMsg = "床垫已审核,不能删除!(" + itemid + ")";
  51. return;
  52. }
  53. if (mattressInfo.js1_flag == 1)
  54. {
  55. rslt.ErrMsg = "资料已技术审核不能删除!(" + itemid + ")";
  56. return;
  57. }
  58. if (DbSqlHelper.Delete(cmd, mattressInfo) <= 0)
  59. {
  60. throw new LJCommonException("因网络或其它原因,删除床垫报价操作失败!");
  61. }
  62. cmd.CommandText = @"DELETE u_mattress WHERE parentid = @parentid";
  63. cmd.Parameters.Clear();
  64. cmd.Parameters.AddWithValue("@parentid", itemid);
  65. cmd.ExecuteNonQuery();
  66. }
  67. cmd.Transaction.Commit();
  68. }
  69. catch (Exception e)
  70. {
  71. cmd.Transaction.Rollback();
  72. rslt.ErrMsg = e.ToString();
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }