DelMattressExcutor.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. }
  63. cmd.Transaction.Commit();
  64. }
  65. catch (Exception e)
  66. {
  67. cmd.Transaction.Rollback();
  68. rslt.ErrMsg = e.ToString();
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }