SaveMattressExtraExcutor.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.LJException;
  9. using JLHHJSvr.Tools;
  10. using LJLib.DAL.SQL;
  11. using LJLib.Net.SPI.Server;
  12. namespace JLHHJSvr.Excutor
  13. {
  14. internal sealed class SaveMattressExtraExcutor : ExcutorBase<SaveMattressExtraRequest, SaveMattressExtraResponse>
  15. {
  16. protected override void ExcuteInternal(SaveMattressExtraRequest request, object state, SaveMattressExtraResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (tokendata == null)
  20. {
  21. rslt.ErrMsg = "会话已经中断,请重新登录";
  22. return;
  23. }
  24. if (request.data == null)
  25. {
  26. rslt.ErrMsg = "未提交数据定义";
  27. return;
  28. }
  29. if (string.IsNullOrEmpty(request.data.extratypename))
  30. {
  31. rslt.ErrMsg = "请填写项目类型名称";
  32. return;
  33. }
  34. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  35. using (var cmd = con.CreateCommand())
  36. {
  37. con.Open();
  38. var dtNow = DateTime.Now;
  39. AutoInit.AutoInitS(cmd, request.data);
  40. using (cmd.Transaction = con.BeginTransaction())
  41. {
  42. try
  43. {
  44. var fields = "extratypename,extraname,typeid,price,dscrp,inuse,ifinit,inputtype";
  45. if (request.data.extraid <= 0)
  46. {
  47. request.data.extraid = BllHelper.GetID(cmd, "u_mattress_extra");
  48. DbSqlHelper.Insert(cmd, "u_mattress_extra", null, request.data, "extraid," + fields);
  49. }
  50. else
  51. {
  52. //修改
  53. DbSqlHelper.Update(cmd, "u_mattress_extra", null, request.data, "extraid", fields);
  54. }
  55. cmd.Transaction.Commit();
  56. }
  57. catch (Exception e)
  58. {
  59. cmd.Transaction.Rollback();
  60. rslt.ErrMsg = e.ToString();
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }