f_init_billstyle.srf 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. $PBExportHeader$f_init_billstyle.srf
  2. global type f_init_billstyle from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_init_billstyle (ref string arg_msg)
  6. end prototypes
  7. global function integer f_init_billstyle (ref string arg_msg);Int rslt
  8. rslt = 1
  9. datastore ds_billstyle
  10. ds_billstyle = CREATE datastore
  11. ds_billstyle.DataObject = 'ds_sys_billstyle'
  12. ds_billstyle.SetTransObject(sqlca)
  13. Long ll_row
  14. ll_row = ds_billstyle.RowCount()
  15. //DELETE FROM u_billcode
  16. //where id = 49 ;
  17. //IF sqlca.SQLCode = -1 THEN
  18. // arg_msg = '删除单据抬头失败'+sqlca.SQLErrText
  19. // rslt = 0
  20. // GOTO ext
  21. //END IF
  22. //
  23. //DELETE FROM u_billcode
  24. //where id = 60 and firststr = 'FP';
  25. //IF sqlca.SQLCode = -1 THEN
  26. // arg_msg = '删除单据抬头失败'+sqlca.SQLErrText
  27. // rslt = 0
  28. // GOTO ext
  29. //END IF
  30. Long cnt
  31. SELECT count(*) INTO :cnt
  32. FROM u_billcode;
  33. IF sqlca.SQLCode <> 0 THEN
  34. arg_msg = '查询单据抬头失败'+sqlca.SQLErrText
  35. rslt = 0
  36. GOTO ext
  37. END IF
  38. Long ll_id_arr[]
  39. String ls_firststr_arr[]
  40. String ls_datestyle_arr[]
  41. String ls_dscrp_arr[]
  42. Long ll_cnt = 1
  43. IF cnt < ll_row THEN
  44. DECLARE cur_billcode CURSOR FOR
  45. SELECT u_billcode.id,
  46. u_billcode.firststr,
  47. u_billcode.datestyle,
  48. u_billcode.dscrp
  49. FROM u_billcode
  50. WHERE u_billcode.firststr <> ''
  51. OR u_billcode.datestyle <> 'yymmdd';
  52. OPEN cur_billcode;
  53. FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
  54. :ls_firststr_arr[ll_cnt],
  55. :ls_datestyle_arr[ll_cnt],
  56. :ls_dscrp_arr[ll_cnt];
  57. DO WHILE sqlca.SQLCode = 0
  58. ll_cnt++
  59. FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
  60. :ls_firststr_arr[ll_cnt],
  61. :ls_datestyle_arr[ll_cnt],
  62. :ls_dscrp_arr[ll_cnt];
  63. LOOP
  64. CLOSE cur_billcode;
  65. ll_cnt = ll_cnt - 1
  66. DELETE FROM u_billcode;
  67. IF sqlca.SQLCode <> 0 THEN
  68. arg_msg = '删除原系统单据抬头数据失败,'+sqlca.SQLErrText
  69. rslt = 0
  70. GOTO ext
  71. END IF
  72. Long ll_i
  73. Long ll_id
  74. String ls_firststr
  75. String ls_datestyle
  76. String ls_dscrp
  77. String ls_oldfirststr
  78. String ls_billstyle
  79. String ls_win1
  80. String ls_win2
  81. String ls_tablename
  82. String ls_codename
  83. String ls_module
  84. FOR ll_i = 1 TO ds_billstyle.RowCount()
  85. ll_id = ds_billstyle.Object.id[ll_i]
  86. IF IsNull(ds_billstyle.Object.firststr[ll_i]) THEN
  87. ls_firststr = ''
  88. ELSE
  89. ls_firststr = ds_billstyle.Object.firststr[ll_i]
  90. END IF
  91. IF IsNull(ds_billstyle.Object.datestyle[ll_i]) THEN
  92. ls_datestyle = ''
  93. ELSE
  94. ls_datestyle = ds_billstyle.Object.datestyle[ll_i]
  95. END IF
  96. IF IsNull(ds_billstyle.Object.dscrp[ll_i]) THEN
  97. ls_dscrp = ''
  98. ELSE
  99. ls_dscrp = ds_billstyle.Object.dscrp[ll_i]
  100. END IF
  101. IF IsNull(ds_billstyle.Object.oldfirststr[ll_i]) THEN
  102. ls_oldfirststr = ''
  103. ELSE
  104. ls_oldfirststr = ds_billstyle.Object.oldfirststr[ll_i]
  105. END IF
  106. IF IsNull(ds_billstyle.Object.billstyle[ll_i]) THEN
  107. ls_billstyle = ''
  108. ELSE
  109. ls_billstyle = ds_billstyle.Object.billstyle[ll_i]
  110. END IF
  111. IF IsNull(ds_billstyle.Object.win1[ll_i]) THEN
  112. ls_win1 = ''
  113. ELSE
  114. ls_win1 = ds_billstyle.Object.win1[ll_i]
  115. END IF
  116. IF IsNull(ds_billstyle.Object.win2[ll_i]) THEN
  117. ls_win2 = ''
  118. ELSE
  119. ls_win2 = ds_billstyle.Object.win2[ll_i]
  120. END IF
  121. IF IsNull(ds_billstyle.Object.tablename[ll_i]) THEN
  122. ls_tablename = ''
  123. ELSE
  124. ls_tablename = ds_billstyle.Object.tablename[ll_i]
  125. END IF
  126. IF IsNull(ds_billstyle.Object.codename[ll_i]) THEN
  127. ls_codename = ''
  128. ELSE
  129. ls_codename = ds_billstyle.Object.codename[ll_i]
  130. END IF
  131. IF IsNull(ds_billstyle.Object.module[ll_i]) THEN
  132. ls_module = ''
  133. ELSE
  134. ls_module = ds_billstyle.Object.module[ll_i]
  135. END IF
  136. INSERT INTO
  137. u_billcode(id,
  138. firststr,
  139. datestyle,
  140. dscrp,
  141. oldfirststr,
  142. billstyle,
  143. win1,
  144. win2,
  145. tablename,
  146. codename,
  147. module)
  148. VALUES(:ll_id,
  149. :ls_firststr,
  150. :ls_datestyle,
  151. :ls_dscrp,
  152. :ls_oldfirststr,
  153. :ls_billstyle,
  154. :ls_win1,
  155. :ls_win2,
  156. :ls_tablename,
  157. :ls_codename,
  158. :ls_module);
  159. IF sqlca.SQLCode <> 0 THEN
  160. arg_msg = '新增系统单据抬头数据失败,'+sqlca.SQLErrText
  161. rslt = 0
  162. GOTO ext
  163. END IF
  164. NEXT
  165. FOR ll_i = 1 TO ll_cnt
  166. UPDATE u_billcode
  167. SET firststr = :ls_firststr_arr[ll_i],
  168. datestyle = :ls_datestyle_arr[ll_i],
  169. dscrp = :ls_dscrp_arr[ll_i]
  170. Where id = :ll_id_arr[ll_i];
  171. IF sqlca.SQLCode <> 0 THEN
  172. arg_msg = '更新改变系统单据抬头数据失败,'+sqlca.SQLErrText
  173. rslt = 0
  174. GOTO ext
  175. END IF
  176. NEXT
  177. END IF
  178. ext:
  179. IF rslt = 0 THEN
  180. ROLLBACK;
  181. ELSE
  182. COMMIT;
  183. END IF
  184. RETURN rslt
  185. end function