uo_reportdef.sru 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. $PBExportHeader$uo_reportdef.sru
  2. forward
  3. global type uo_reportdef from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_reportdef from nonvisualobject
  7. end type
  8. global uo_reportdef uo_reportdef
  9. type variables
  10. s_report s_rpt
  11. long rpid
  12. boolean if_getid_ture=false
  13. transaction commit_transaction //数据commit事务
  14. boolean it_newbegin=false //新建标志
  15. boolean it_updatebegin=false //修改标志
  16. end variables
  17. forward prototypes
  18. public subroutine p_reset ()
  19. public function integer newbegin (integer arg_rpid)
  20. public function integer del (long arg_rpid, boolean arg_ifcommit, ref string arg_msg)
  21. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  22. end prototypes
  23. public subroutine p_reset ();s_rpt.rpid = 0
  24. s_rpt.rpname = ''
  25. s_rpt.ifuse = 1
  26. s_rpt.flag= 0
  27. s_rpt.billid = 0
  28. end subroutine
  29. public function integer newbegin (integer arg_rpid);long rslt = 1
  30. it_newbegin =true
  31. it_updatebegin =false
  32. rpid = arg_rpid
  33. return rslt
  34. end function
  35. public function integer del (long arg_rpid, boolean arg_ifcommit, ref string arg_msg);
  36. int rslt = 1
  37. long ls_long
  38. if arg_rpid = 0 then
  39. rslt = 0
  40. arg_msg = "没有删除对象,操作取消"
  41. goto ext
  42. end if
  43. delete from u_report_list
  44. where rpid = :arg_rpid using commit_transaction;
  45. if commit_transaction.sqlcode <> 0 then
  46. rslt = 0
  47. arg_msg = "删除物料操作失败"+"~n"+commit_transaction.sqlerrtext
  48. goto ext
  49. end if
  50. it_newbegin = false
  51. it_updatebegin = false
  52. ext:
  53. if rslt=0 then
  54. rollback using commit_transaction;
  55. elseif rslt=1 and arg_ifcommit then
  56. commit using commit_transaction;
  57. end if
  58. p_reset()
  59. return rslt
  60. end function
  61. public function integer save (boolean arg_ifcommit, ref string arg_msg);long rslt =1
  62. long ls_newid
  63. if isnull(s_rpt.ifuse) then s_rpt.ifuse = 1
  64. if isnull(s_rpt.rpid) then s_rpt.rpid = 0
  65. if isnull(s_rpt.rpname) then s_rpt.rpname = ''
  66. if isnull(s_rpt.billid) then s_rpt.billid = 0
  67. if isnull(s_rpt.auditprint) then s_rpt.auditprint = 0
  68. ////////////////////////////////////////////////开始区分:新建/更新 处理
  69. if s_rpt.rpid = 0 then //新建
  70. ls_newid = f_sys_scidentity_rpt(0,"u_report_list","rpid",arg_msg,if_getid_ture,commit_transaction)
  71. if ls_newid <= 0 then
  72. rslt = 0
  73. goto ext
  74. end if
  75. insert into u_report_list
  76. (rpid,
  77. RpName,
  78. Ifuse,
  79. Flag,
  80. billid,
  81. auditprint,
  82. descrp)
  83. values
  84. (:ls_newid,
  85. :s_rpt.RpName,
  86. :s_rpt.Ifuse,
  87. 0,
  88. :s_rpt.billid,
  89. :s_rpt.auditprint,
  90. :s_rpt.descrp) using commit_transaction ;
  91. if commit_transaction.sqlcode <> 0 then
  92. rslt = 0
  93. arg_msg = "因网络或其它原因导致报表插入操作失败"+"~n"+commit_transaction.sqlerrtext
  94. goto ext
  95. end if
  96. rpid = ls_newid
  97. else //////////////////////////////////////////////////更新
  98. update u_report_list
  99. set RpName = :s_rpt.RpName,
  100. Ifuse = :s_rpt.Ifuse,
  101. auditprint = :s_rpt.auditprint,
  102. descrp = :s_rpt.descrp
  103. where rpid = :s_rpt.rpid using commit_transaction;
  104. if commit_transaction.sqlcode <> 0 or commit_transaction.sqlnrows <= 0 then
  105. rslt = 0
  106. arg_msg = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.sqlerrtext
  107. goto ext
  108. end if
  109. rpid = s_rpt.rpid
  110. end if
  111. it_newbegin = false
  112. it_updatebegin = false
  113. ext:
  114. if rslt = 0 then
  115. rollback using commit_transaction;
  116. elseif rslt = 1 and arg_ifcommit then
  117. commit using commit_transaction;
  118. end if
  119. return rslt
  120. end function
  121. on uo_reportdef.create
  122. call super::create
  123. TriggerEvent( this, "constructor" )
  124. end on
  125. on uo_reportdef.destroy
  126. TriggerEvent( this, "destructor" )
  127. call super::destroy
  128. end on