SaveConfigureCodeMxExcutor.cs 3.0 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.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 SaveConfigureCodeMxExcutor : ExcutorBase<SaveConfigureCodeMxRequest, SaveConfigureCodeMxResponse>
  15. {
  16. protected override void ExcuteInternal(SaveConfigureCodeMxRequest request, object state, SaveConfigureCodeMxResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (tokendata == null)
  20. {
  21. rslt.ErrMsg = "会话已经中断,请重新登录";
  22. return;
  23. }
  24. if (request.configure == null)
  25. {
  26. rslt.ErrMsg = "未提交部件选配项";
  27. return;
  28. }
  29. if (string.IsNullOrEmpty(request.configure.pzcodemx))
  30. {
  31. rslt.ErrMsg = "请输入明细编号";
  32. return;
  33. }
  34. if (string.IsNullOrEmpty(request.configure.namemx))
  35. {
  36. rslt.ErrMsg = "请输入明细名称";
  37. return;
  38. }
  39. if (request.configure.pzid <= 0)
  40. {
  41. rslt.ErrMsg = "部件选配配置id错误";
  42. return;
  43. }
  44. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  45. using (var cmd = con.CreateCommand())
  46. {
  47. con.Open();
  48. var dtNow = DateTime.Now;
  49. AutoInit.AutoInitS(cmd, request.configure);
  50. using (cmd.Transaction = con.BeginTransaction())
  51. {
  52. try
  53. {
  54. if (request.configure.printid <= 0)
  55. {
  56. request.configure.printid = BllHelper.GetID(cmd, "u_configure_codemx");
  57. var fields = @"pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade";
  58. DbSqlHelper.Insert(cmd, "u_configure_codemx", null, request.configure, fields);
  59. }
  60. else
  61. {
  62. //修改
  63. var fields = @"pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade";
  64. DbSqlHelper.Update(cmd, "u_configure_codemx", null, request.configure, "pzid,printid", fields);
  65. }
  66. cmd.Transaction.Commit();
  67. }
  68. catch (Exception e)
  69. {
  70. cmd.Transaction.Rollback();
  71. rslt.ErrMsg = e.ToString();
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }