f_update_planprice.srf 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. $PBExportHeader$f_update_planprice.srf
  2. global type f_update_planprice from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_update_planprice (long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, integer arg_buildtype, decimal arg_fprice, ref string arg_msg, boolean arg_ifcommit, transaction commit_transaction)
  6. end prototypes
  7. global function integer f_update_planprice (long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, integer arg_buildtype, decimal arg_fprice, ref string arg_msg, boolean arg_ifcommit, transaction commit_transaction);Int rslt = 1
  8. String ls_status,ls_woodcode,ls_pcode
  9. Int li_pricepztype
  10. String ls_mtrlcode
  11. IF arg_fprice <= 0 THEN
  12. rslt = 1
  13. GOTO ext
  14. END IF
  15. SELECT pricepztype,mtrlcode
  16. INTO :li_pricepztype,:ls_mtrlcode
  17. FROM u_mtrldef
  18. Where mtrlid = :arg_mtrlid Using commit_transaction;
  19. IF commit_transaction.SQLCode <> 0 THEN
  20. rslt = 0
  21. arg_msg = '查询物料计划成本价配置模式失败,'+commit_transaction.SQLErrText
  22. GOTO ext
  23. END IF
  24. CHOOSE CASE li_pricepztype
  25. CASE 0
  26. ls_status = ''
  27. ls_woodcode = ''
  28. ls_pcode = ''
  29. CASE 1
  30. ls_status = arg_status
  31. ls_woodcode = ''
  32. ls_pcode = ''
  33. CASE 2
  34. ls_status = ''
  35. ls_woodcode = arg_woodcode
  36. ls_pcode = ''
  37. CASE 3
  38. ls_status = ''
  39. ls_woodcode = ''
  40. ls_pcode = arg_pcode
  41. CASE 4
  42. ls_status = arg_status
  43. ls_woodcode = arg_woodcode
  44. ls_pcode = ''
  45. CASE 5
  46. ls_status = ''
  47. ls_woodcode = arg_woodcode
  48. ls_pcode = arg_pcode
  49. CASE 6
  50. ls_status = arg_status
  51. ls_woodcode = ''
  52. ls_pcode = arg_pcode
  53. CASE 7
  54. ls_status = arg_status
  55. ls_woodcode = arg_woodcode
  56. ls_pcode = arg_pcode
  57. END CHOOSE
  58. UPDATE u_mtrldef_planprice
  59. SET planprice = :arg_fprice
  60. WHERE mtrlid = :arg_mtrlid
  61. AND status = :ls_status
  62. AND woodcode = :ls_woodcode
  63. And pcode = :ls_pcode Using commit_transaction;
  64. IF commit_transaction.SQLCode = 0 THEN
  65. IF commit_transaction.SQLNRows = 0 THEN
  66. INSERT INTO u_mtrldef_planprice
  67. (mtrlid,
  68. status,
  69. woodcode,
  70. pcode,
  71. planprice)
  72. VALUES
  73. (:arg_mtrlid,
  74. :ls_status,
  75. :ls_woodcode,
  76. :ls_pcode,
  77. :arg_fprice) Using commit_transaction;
  78. IF commit_transaction.SQLCode <> 0 THEN
  79. rslt = 0
  80. arg_msg = '插入物料'+ls_mtrlcode+'计划成本价资料失败,'+commit_transaction.SQLErrText
  81. GOTO ext
  82. END IF
  83. END IF
  84. INSERT INTO u_mtrl_planprice_his
  85. (mtrlid,
  86. cmpldate,
  87. planprice,
  88. buildtype,
  89. status,
  90. woodcode,
  91. pcode)
  92. VALUES
  93. (:arg_mtrlid,
  94. getdate(),
  95. :arg_fprice,
  96. :arg_buildtype,
  97. :ls_status,
  98. :ls_woodcode,
  99. :ls_pcode) Using commit_transaction;
  100. IF commit_transaction.SQLCode <> 0 THEN
  101. rslt = 0
  102. arg_msg = '建立'+ls_mtrlcode+'产品计划成本价历史记录失败 '+commit_transaction.SQLErrText
  103. GOTO ext
  104. END IF
  105. ELSE
  106. IF commit_transaction.SQLCode <> 0 THEN
  107. rslt = 0
  108. arg_msg = '更新物料'+ls_mtrlcode+'计划成本价资料失败,'+commit_transaction.SQLErrText
  109. GOTO ext
  110. END IF
  111. END IF
  112. ext:
  113. IF rslt = 0 THEN
  114. ROLLBACK Using commit_transaction;
  115. ELSEIF rslt = 1 And arg_ifcommit THEN
  116. COMMIT Using commit_transaction;
  117. END IF
  118. RETURN rslt
  119. end function