uo_billdef.sru 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. $PBExportHeader$uo_billdef.sru
  2. forward
  3. global type uo_billdef from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_billdef from nonvisualobject
  7. end type
  8. global uo_billdef uo_billdef
  9. type variables
  10. s_rpt_bill s_bill
  11. long billid
  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 save (boolean arg_ifcommit, ref string arg_msg)
  20. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  21. public function integer newbegin (integer arg_billid)
  22. end prototypes
  23. public subroutine p_reset ();s_bill.BillID = 0
  24. s_bill.BillName = ''
  25. s_bill.WinName = ''
  26. s_bill.WhereSql = ''
  27. s_bill.arguments = ''
  28. s_bill.tablename = ''
  29. s_bill.ifuse = 1
  30. end subroutine
  31. public function integer save (boolean arg_ifcommit, ref string arg_msg);long rslt =1
  32. long ls_newid
  33. if isnull(s_bill.BillID) then s_bill.BillID = 0
  34. if isnull(s_bill.BillName) then s_bill.BillName = ''
  35. if isnull(s_bill.WinName) then s_bill.WinName = ''
  36. if isnull(s_bill.WhereSql) then s_bill.WhereSql = ''
  37. if isnull(s_bill.arguments) then s_bill.arguments = ''
  38. if isnull(s_bill.tablename) then s_bill.tablename = ''
  39. if isnull(s_bill.ifuse) then s_bill.ifuse = 0
  40. ////////////////////////////////////////////////开始区分:新建/更新 处理
  41. if s_bill.BillID = 0 then //新建
  42. ls_newid = f_sys_scidentity_rpt(0,"u_report_bill","billid",arg_msg,if_getid_ture,commit_transaction)
  43. if ls_newid <= 0 then
  44. rslt = 0
  45. goto ext
  46. end if
  47. insert into u_report_bill
  48. (BillID,
  49. BillName,
  50. WinName,
  51. WhereSql,
  52. arguments,
  53. tablename,
  54. ifuse)
  55. values
  56. (:ls_newid,
  57. :s_bill.BillName,
  58. :s_bill.WinName,
  59. :s_bill.WhereSql,
  60. :s_bill.arguments,
  61. :s_bill.tablename,
  62. :s_bill.ifuse) using commit_transaction ;
  63. if commit_transaction.sqlcode <> 0 then
  64. rslt = 0
  65. arg_msg = "因网络或其它原因导致报表插入操作失败"+"~n"+commit_transaction.sqlerrtext
  66. goto ext
  67. end if
  68. billid = ls_newid
  69. else //////////////////////////////////////////////////更新
  70. update u_report_bill
  71. set BillName = :s_bill.BillName,
  72. WinName = :s_bill.WinName,
  73. WhereSql = :s_bill.WhereSql,
  74. arguments = :s_bill.arguments,
  75. tablename = :s_bill.tablename,
  76. ifuse = :s_bill.ifuse
  77. where billid = :s_bill.billid using commit_transaction;
  78. if commit_transaction.sqlcode <> 0 or commit_transaction.sqlnrows <= 0 then
  79. rslt = 0
  80. arg_msg = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.sqlerrtext
  81. goto ext
  82. end if
  83. billid = s_bill.billid
  84. end if
  85. it_newbegin = false
  86. it_updatebegin = false
  87. ext:
  88. if rslt = 0 then
  89. rollback using commit_transaction;
  90. elseif rslt = 1 and arg_ifcommit then
  91. commit using commit_transaction;
  92. end if
  93. return rslt
  94. end function
  95. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  96. int rslt = 1
  97. long ls_long
  98. if arg_billid = 0 then
  99. rslt = 0
  100. arg_msg = "没有删除对象,操作取消"
  101. goto ext
  102. end if
  103. delete from u_report_bill
  104. where billid = :arg_billid using commit_transaction;
  105. if commit_transaction.sqlcode <> 0 then
  106. rslt = 0
  107. arg_msg = "删除物料操作失败"+"~n"+commit_transaction.sqlerrtext
  108. goto ext
  109. end if
  110. it_newbegin = false
  111. it_updatebegin = false
  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. p_reset()
  119. return rslt
  120. end function
  121. public function integer newbegin (integer arg_billid);long rslt = 1
  122. it_newbegin =true
  123. it_updatebegin =false
  124. billid = arg_billid
  125. return rslt
  126. end function
  127. on uo_billdef.create
  128. call super::create
  129. TriggerEvent( this, "constructor" )
  130. end on
  131. on uo_billdef.destroy
  132. TriggerEvent( this, "destructor" )
  133. call super::destroy
  134. end on