w_repair_balc.srw 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. $PBExportHeader$w_repair_balc.srw
  2. forward
  3. global type w_repair_balc from w_publ_base
  4. end type
  5. type cb_17 from commandbutton within w_repair_balc
  6. end type
  7. type cb_1 from commandbutton within w_repair_balc
  8. end type
  9. type st_1 from statictext within w_repair_balc
  10. end type
  11. end forward
  12. global type w_repair_balc from w_publ_base
  13. integer width = 1371
  14. integer height = 636
  15. string title = "修复结存金额,库存金额"
  16. boolean minbox = false
  17. windowtype windowtype = response!
  18. cb_17 cb_17
  19. cb_1 cb_1
  20. st_1 st_1
  21. end type
  22. global w_repair_balc w_repair_balc
  23. on w_repair_balc.create
  24. int iCurrent
  25. call super::create
  26. this.cb_17=create cb_17
  27. this.cb_1=create cb_1
  28. this.st_1=create st_1
  29. iCurrent=UpperBound(this.Control)
  30. this.Control[iCurrent+1]=this.cb_17
  31. this.Control[iCurrent+2]=this.cb_1
  32. this.Control[iCurrent+3]=this.st_1
  33. end on
  34. on w_repair_balc.destroy
  35. call super::destroy
  36. destroy(this.cb_17)
  37. destroy(this.cb_1)
  38. destroy(this.st_1)
  39. end on
  40. type cb_func from w_publ_base`cb_func within w_repair_balc
  41. boolean visible = false
  42. integer x = 1431
  43. integer y = 816
  44. end type
  45. type cb_exit from w_publ_base`cb_exit within w_repair_balc
  46. integer x = 1006
  47. integer y = 444
  48. end type
  49. type cb_17 from commandbutton within w_repair_balc
  50. integer x = 32
  51. integer y = 180
  52. integer width = 480
  53. integer height = 84
  54. integer taborder = 10
  55. boolean bringtotop = true
  56. integer textsize = -9
  57. integer weight = 400
  58. fontcharset fontcharset = gb2312charset!
  59. fontpitch fontpitch = variable!
  60. string facename = "宋体"
  61. string text = "2.修复现结存金额"
  62. end type
  63. event clicked;IF MessageBox ("询问","是否确认要执行操作?",question!,yesno! ) = 2 THEN RETURN
  64. //1.用最近一次结存的结余金额更新现结存的期初金额
  65. Long rslt
  66. rslt = 1
  67. Long ll_storageid[]
  68. Long i
  69. Long ll_i
  70. Long ll_balcdateint
  71. String arg_msg
  72. Decimal ld_balcamt
  73. i = 1
  74. DECLARE cur_storage CURSOR FOR
  75. SELECT DISTINCT Storageid
  76. FROM u_warebalc
  77. Order By Storageid;
  78. OPEN cur_storage;
  79. FETCH cur_storage INTO :ll_storageid[i];
  80. DO WHILE sqlca.SQLCode = 0
  81. i++
  82. FETCH cur_storage INTO :ll_storageid[i];
  83. LOOP
  84. CLOSE cur_storage;
  85. FOR ll_i = 1 TO i - 1
  86. SELECT max(balcdateint) INTO :ll_balcdateint
  87. FROM u_warebalc
  88. Where Storageid = :ll_storageid[ll_i];
  89. IF sqlca.SQLCode <> 0 THEN
  90. rslt = 0
  91. arg_msg = '查询仓库'+String(ll_storageid[ll_i])+'最近一次结存日期失败'+sqlca.SQLErrText
  92. GOTO ext
  93. END IF
  94. IF ll_balcdateint = 0 THEN CONTINUE //如果该仓库没有结存过,则跳过
  95. //用物料最近结存的结余金额更新现结存的期初金额
  96. UPDATE u_warebalc
  97. SET u_warebalc.bgamt = a.balcamt
  98. FROM u_warebalc INNER JOIN
  99. (SELECT mtrlid, Storageid, status, pcode, woodcode, balcqty, balcamt
  100. FROM u_warebalc
  101. WHERE (Storageid = :ll_storageid[ll_i]) AND (balcdateint = :ll_balcdateint)) a ON
  102. u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.Storageid AND
  103. u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
  104. u_warebalc.woodcode = a.woodcode
  105. Where (u_warebalc.Storageid = :ll_storageid[ll_i]) And (u_warebalc.balcdateint = 0);
  106. IF sqlca.SQLCode <> 0 THEN
  107. rslt = 0
  108. arg_msg = '更新现结存期初金额失败,仓库:'+String(ll_storageid[ll_i])
  109. GOTO ext
  110. END IF
  111. NEXT
  112. //2.用未结存的进仓单金额汇总出现结存的期间进金额
  113. UPDATE u_warebalc
  114. SET u_warebalc.incamt = a.amt
  115. FROM u_warebalc INNER JOIN
  116. (SELECT u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
  117. u_inwaremx.pcode, ISNULL(SUM(u_inwaremx.qty), 0) AS qty,
  118. ISNULL(SUM(ROUND(u_inwaremx.cost * u_inwaremx.qty, 2)), 0) AS amt,
  119. u_inware.storageid
  120. FROM u_inware INNER JOIN
  121. u_inwaremx ON u_inware.scid = u_inwaremx.scid AND
  122. u_inware.inwareid = u_inwaremx.inwareid
  123. WHERE (u_inware.balcdateint = 0) AND (u_inware.flag = 1)
  124. GROUP BY u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
  125. u_inwaremx.pcode, u_inware.storageid) a ON
  126. u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.storageid AND
  127. u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
  128. u_warebalc.woodcode = a.woodcode
  129. Where (u_warebalc.balcdateint = 0);
  130. IF sqlca.SQLCode <> 0 THEN
  131. rslt = 0
  132. arg_msg = '更新现结存期间进金额失败'
  133. GOTO ext
  134. END IF
  135. ext:
  136. IF rslt = 1 THEN
  137. COMMIT;
  138. MessageBox('提示','操作完成!',information!,ok!)
  139. ELSE
  140. ROLLBACK;
  141. MessageBox('错误',arg_msg,stopsign!,ok!)
  142. END IF
  143. end event
  144. type cb_1 from commandbutton within w_repair_balc
  145. integer x = 27
  146. integer y = 36
  147. integer width = 549
  148. integer height = 84
  149. integer taborder = 10
  150. boolean bringtotop = true
  151. integer textsize = -9
  152. integer weight = 400
  153. fontcharset fontcharset = gb2312charset!
  154. fontpitch fontpitch = variable!
  155. string facename = "宋体"
  156. string text = "1.修复历史结存金额"
  157. end type
  158. event clicked;open(w_repair_balc_before)
  159. end event
  160. type st_1 from statictext within w_repair_balc
  161. integer x = 41
  162. integer y = 324
  163. integer width = 1193
  164. integer height = 48
  165. boolean bringtotop = true
  166. integer textsize = -9
  167. integer weight = 400
  168. fontcharset fontcharset = gb2312charset!
  169. fontpitch fontpitch = variable!
  170. string facename = "宋体"
  171. long textcolor = 33554432
  172. long backcolor = 134217739
  173. string text = "3.执行~"结存预览~"中的~"重算~"功能,更新库存金额"
  174. boolean focusrectangle = false
  175. end type