uo_mtrlware_propel_rule.sru 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. $PBExportHeader$uo_mtrlware_propel_rule.sru
  2. forward
  3. global type uo_mtrlware_propel_rule from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_mtrlware_propel_rule from nonvisualobject
  7. end type
  8. global uo_mtrlware_propel_rule uo_mtrlware_propel_rule
  9. type variables
  10. long uo_ruleid
  11. end variables
  12. forward prototypes
  13. public function integer del (long arg_ruleid, ref string arg_msg, boolean arg_ifcommit)
  14. public function integer save (s_mtrlware_propel_rule arg_s_rule, ref string arg_msg, boolean arg_ifcommit)
  15. end prototypes
  16. public function integer del (long arg_ruleid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  17. IF arg_ruleid <= 0 THEN
  18. rslt = 0
  19. arg_msg = '错误单据唯一码'
  20. GOTO ext
  21. END IF
  22. DELETE FROM u_mtrlware_propel_rule_mx
  23. Where ruleid = :arg_ruleid;
  24. IF sqlca.SQLCode <> 0 THEN
  25. rslt = 0
  26. arg_msg = "删除规则明细操作失败"+"~n"+sqlca.SQLErrText
  27. GOTO ext
  28. END IF
  29. DELETE FROM u_mtrlware_propel_rule
  30. Where ruleid = :arg_ruleid;
  31. IF sqlca.SQLCode <> 0 THEN
  32. rslt = 0
  33. arg_msg = "删除策略操作失败"+"~n"+sqlca.SQLErrText
  34. GOTO ext
  35. END IF
  36. ext:
  37. IF rslt = 0 THEN
  38. ROLLBACK;
  39. ELSEIF rslt = 1 AND arg_ifcommit THEN
  40. COMMIT;
  41. END IF
  42. RETURN rslt
  43. end function
  44. public function integer save (s_mtrlware_propel_rule arg_s_rule, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  45. Long cnt = 0
  46. Long ll_newid
  47. DateTime server_dt
  48. Long it_mxbt,it_mxbt_mtrl
  49. Long i,j
  50. IF IsNull(arg_s_rule.ruleid) THEN arg_s_rule.ruleid = 0
  51. IF IsNull(arg_s_rule.rulename) THEN arg_s_rule.rulename = ''
  52. IF IsNull(arg_s_rule.rulestr) THEN arg_s_rule.rulestr = ''
  53. IF IsNull(arg_s_rule.dscrp) THEN arg_s_rule.dscrp = ''
  54. IF IsNull(arg_s_rule.storageid) THEN arg_s_rule.storageid = 0
  55. IF IsNull(arg_s_rule.handtypestr) THEN arg_s_rule.handtypestr = ''
  56. IF IsNull(arg_s_rule.isrunning) THEN arg_s_rule.isrunning = 0
  57. IF IsNull(arg_s_rule.timertype) THEN arg_s_rule.timertype = 0
  58. IF IsNull(arg_s_rule.timerparm) THEN arg_s_rule.timerparm = ''
  59. SELECT Top 1 getdate() Into :server_dt From u_user;
  60. IF sqlca.SQLCode <> 0 THEN
  61. rslt = 0
  62. arg_msg = "查询操作失败,日期 "
  63. GOTO ext
  64. END IF
  65. IF arg_s_rule.rulename = '' THEN
  66. rslt = 0
  67. arg_msg = '请输入策略名称'
  68. GOTO ext
  69. END IF
  70. //IF arg_s_rule.rulestr = '' THEN
  71. // rslt = 0
  72. // arg_msg = '请填写策略规则'
  73. // GOTO ext
  74. //END IF
  75. IF arg_s_rule.storageid = 0 THEN
  76. rslt = 0
  77. arg_msg = '请选择仓库'
  78. GOTO ext
  79. END IF
  80. it_mxbt = UpperBound(arg_s_rule.arg_s_mx)
  81. IF it_mxbt <= 0 THEN
  82. rslt = 0
  83. arg_msg = "没有正确规则明细内容"
  84. GOTO ext
  85. END IF
  86. IF arg_s_rule.ruleid = 0 THEN
  87. ll_newid = f_sys_scidentity(0,"u_mtrlware_propel_rule","ruleid",arg_msg,True,id_sqlca)
  88. IF ll_newid <= 0 THEN
  89. rslt = 0
  90. GOTO ext
  91. END IF
  92. INSERT INTO u_mtrlware_propel_rule
  93. (ruleid,
  94. rulename,
  95. rulestr,
  96. dscrp,
  97. opemp,
  98. opdate,
  99. storageid,
  100. handtypestr,
  101. isrunning,
  102. nextexectime,
  103. timertype,
  104. timerparm)
  105. VALUES
  106. (:ll_newid,
  107. :arg_s_rule.rulename,
  108. :arg_s_rule.rulestr,
  109. :arg_s_rule.dscrp,
  110. :publ_operator,
  111. getdate(),
  112. :arg_s_rule.storageid,
  113. :arg_s_rule.handtypestr,
  114. :arg_s_rule.isrunning,
  115. :arg_s_rule.nextexectime,
  116. :arg_s_rule.timertype,
  117. :arg_s_rule.timerparm);
  118. IF sqlca.SQLCode <> 0 THEN
  119. rslt = 0
  120. arg_msg = '新增策略失败'+sqlca.SQLErrText
  121. GOTO ext
  122. END IF
  123. FOR i = 1 To it_mxbt
  124. INSERT INTO u_mtrlware_propel_rule_mx
  125. (ruleid,
  126. cusid,
  127. ifmatch)
  128. VALUES
  129. (:ll_newid,
  130. :arg_s_rule.arg_s_mx[i].cusid,
  131. :arg_s_rule.arg_s_mx[i].ifmatch);
  132. IF sqlca.SQLCode <> 0 THEN
  133. rslt = 0
  134. arg_msg = '插入明细失败'+sqlca.SQLErrText
  135. GOTO ext
  136. END IF
  137. NEXT
  138. uo_ruleid = ll_newid
  139. ELSE
  140. UPDATE u_mtrlware_propel_rule
  141. SET rulename = :arg_s_rule.rulename,
  142. rulestr = :arg_s_rule.rulestr,
  143. dscrp = :arg_s_rule.dscrp,
  144. storageid = :arg_s_rule.storageid,
  145. moddate = getdate(),
  146. modemp = :publ_operator,
  147. handtypestr = :arg_s_rule.handtypestr,
  148. isrunning = :arg_s_rule.isrunning,
  149. nextexectime = :arg_s_rule.nextexectime,
  150. timertype = :arg_s_rule.timertype,
  151. timerparm = :arg_s_rule.timerparm
  152. Where ruleid = :arg_s_rule.ruleid;
  153. IF sqlca.SQLCode <> 0 THEN
  154. rslt = 0
  155. arg_msg = '更新策略失败'+sqlca.SQLErrText
  156. GOTO ext
  157. END IF
  158. DELETE FROM u_mtrlware_propel_rule_mx
  159. Where ruleid = :arg_s_rule.ruleid;
  160. IF sqlca.SQLCode <> 0 THEN
  161. rslt = 0
  162. arg_msg = "删除旧有规则明细操作失败"+"~n"+sqlca.SQLErrText
  163. GOTO ext
  164. END IF
  165. FOR i = 1 To it_mxbt
  166. INSERT INTO u_mtrlware_propel_rule_mx
  167. (ruleid,
  168. cusid,
  169. ifmatch)
  170. VALUES
  171. (:arg_s_rule.ruleid,
  172. :arg_s_rule.arg_s_mx[i].cusid,
  173. :arg_s_rule.arg_s_mx[i].ifmatch);
  174. IF sqlca.SQLCode <> 0 THEN
  175. rslt = 0
  176. arg_msg = '插入明细规则失败'+sqlca.SQLErrText
  177. GOTO ext
  178. END IF
  179. NEXT
  180. uo_ruleid = arg_s_rule.ruleid
  181. END IF
  182. ext:
  183. IF rslt = 0 THEN
  184. ROLLBACK;
  185. ELSEIF arg_ifcommit And rslt = 1 THEN
  186. COMMIT;
  187. END IF
  188. RETURN rslt
  189. end function
  190. on uo_mtrlware_propel_rule.create
  191. call super::create
  192. TriggerEvent( this, "constructor" )
  193. end on
  194. on uo_mtrlware_propel_rule.destroy
  195. TriggerEvent( this, "destructor" )
  196. call super::destroy
  197. end on