w_repair_balc_before.srw 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. $PBExportHeader$w_repair_balc_before.srw
  2. forward
  3. global type w_repair_balc_before from w_publ_base
  4. end type
  5. type st_1 from statictext within w_repair_balc_before
  6. end type
  7. type st_2 from statictext within w_repair_balc_before
  8. end type
  9. type st_3 from statictext within w_repair_balc_before
  10. end type
  11. type st_4 from statictext within w_repair_balc_before
  12. end type
  13. type st_5 from statictext within w_repair_balc_before
  14. end type
  15. type sle_balcdateint from singlelineedit within w_repair_balc_before
  16. end type
  17. type sle_balcdateint_before from singlelineedit within w_repair_balc_before
  18. end type
  19. type cb_1 from commandbutton within w_repair_balc_before
  20. end type
  21. type ddlb_1 from uo_ddlb_storageid within w_repair_balc_before
  22. end type
  23. end forward
  24. global type w_repair_balc_before from w_publ_base
  25. integer width = 2222
  26. integer height = 892
  27. boolean minbox = false
  28. windowtype windowtype = response!
  29. st_1 st_1
  30. st_2 st_2
  31. st_3 st_3
  32. st_4 st_4
  33. st_5 st_5
  34. sle_balcdateint sle_balcdateint
  35. sle_balcdateint_before sle_balcdateint_before
  36. cb_1 cb_1
  37. ddlb_1 ddlb_1
  38. end type
  39. global w_repair_balc_before w_repair_balc_before
  40. type variables
  41. long cur_storageid = -1
  42. end variables
  43. on w_repair_balc_before.create
  44. int iCurrent
  45. call super::create
  46. this.st_1=create st_1
  47. this.st_2=create st_2
  48. this.st_3=create st_3
  49. this.st_4=create st_4
  50. this.st_5=create st_5
  51. this.sle_balcdateint=create sle_balcdateint
  52. this.sle_balcdateint_before=create sle_balcdateint_before
  53. this.cb_1=create cb_1
  54. this.ddlb_1=create ddlb_1
  55. iCurrent=UpperBound(this.Control)
  56. this.Control[iCurrent+1]=this.st_1
  57. this.Control[iCurrent+2]=this.st_2
  58. this.Control[iCurrent+3]=this.st_3
  59. this.Control[iCurrent+4]=this.st_4
  60. this.Control[iCurrent+5]=this.st_5
  61. this.Control[iCurrent+6]=this.sle_balcdateint
  62. this.Control[iCurrent+7]=this.sle_balcdateint_before
  63. this.Control[iCurrent+8]=this.cb_1
  64. this.Control[iCurrent+9]=this.ddlb_1
  65. end on
  66. on w_repair_balc_before.destroy
  67. call super::destroy
  68. destroy(this.st_1)
  69. destroy(this.st_2)
  70. destroy(this.st_3)
  71. destroy(this.st_4)
  72. destroy(this.st_5)
  73. destroy(this.sle_balcdateint)
  74. destroy(this.sle_balcdateint_before)
  75. destroy(this.cb_1)
  76. destroy(this.ddlb_1)
  77. end on
  78. type cb_func from w_publ_base`cb_func within w_repair_balc_before
  79. boolean visible = false
  80. integer x = 1152
  81. integer y = 832
  82. end type
  83. type cb_exit from w_publ_base`cb_exit within w_repair_balc_before
  84. integer x = 1838
  85. integer y = 684
  86. end type
  87. type st_1 from statictext within w_repair_balc_before
  88. integer x = 357
  89. integer y = 60
  90. integer width = 146
  91. integer height = 56
  92. boolean bringtotop = true
  93. integer textsize = -9
  94. integer weight = 400
  95. fontcharset fontcharset = gb2312charset!
  96. fontpitch fontpitch = variable!
  97. string facename = "宋体"
  98. long textcolor = 33554432
  99. long backcolor = 134217739
  100. string text = "仓库"
  101. boolean focusrectangle = false
  102. end type
  103. type st_2 from statictext within w_repair_balc_before
  104. integer x = 82
  105. integer y = 160
  106. integer width = 402
  107. integer height = 48
  108. boolean bringtotop = true
  109. integer textsize = -9
  110. integer weight = 400
  111. fontcharset fontcharset = gb2312charset!
  112. fontpitch fontpitch = variable!
  113. string facename = "宋体"
  114. long textcolor = 33554432
  115. long backcolor = 134217739
  116. string text = "要修复的结存日"
  117. boolean focusrectangle = false
  118. end type
  119. type st_3 from statictext within w_repair_balc_before
  120. integer x = 64
  121. integer y = 252
  122. integer width = 402
  123. integer height = 56
  124. boolean bringtotop = true
  125. integer textsize = -9
  126. integer weight = 400
  127. fontcharset fontcharset = gb2312charset!
  128. fontpitch fontpitch = variable!
  129. string facename = "宋体"
  130. long textcolor = 33554432
  131. long backcolor = 134217739
  132. string text = "以往的结存日"
  133. alignment alignment = right!
  134. boolean focusrectangle = false
  135. end type
  136. type st_4 from statictext within w_repair_balc_before
  137. integer x = 59
  138. integer y = 388
  139. integer width = 1632
  140. integer height = 60
  141. boolean bringtotop = true
  142. integer textsize = -9
  143. integer weight = 400
  144. fontcharset fontcharset = gb2312charset!
  145. fontpitch fontpitch = variable!
  146. string facename = "宋体"
  147. long textcolor = 16711680
  148. long backcolor = 134217739
  149. string text = "说明:在~"要修复的结存日~"中输入想要修复的结存日,如~"20081031~","
  150. boolean focusrectangle = false
  151. end type
  152. type st_5 from statictext within w_repair_balc_before
  153. integer x = 197
  154. integer y = 444
  155. integer width = 1947
  156. integer height = 208
  157. boolean bringtotop = true
  158. integer textsize = -9
  159. integer weight = 400
  160. fontcharset fontcharset = gb2312charset!
  161. fontpitch fontpitch = variable!
  162. string facename = "宋体"
  163. long textcolor = 16711680
  164. long backcolor = 134217739
  165. string text = "在~"以往的结存日~"中输入要修复的结存日之前的一个结存日,比如要修复的结存日是~"20081031~",~"20081031~"之前的结存日是~"20080930~",则在~"以往结存日~"中输入~"20080930~""
  166. boolean focusrectangle = false
  167. end type
  168. type sle_balcdateint from singlelineedit within w_repair_balc_before
  169. integer x = 512
  170. integer y = 152
  171. integer width = 402
  172. integer height = 84
  173. integer taborder = 20
  174. boolean bringtotop = true
  175. integer textsize = -9
  176. integer weight = 400
  177. fontcharset fontcharset = gb2312charset!
  178. fontpitch fontpitch = variable!
  179. string facename = "宋体"
  180. long textcolor = 33554432
  181. borderstyle borderstyle = stylelowered!
  182. end type
  183. type sle_balcdateint_before from singlelineedit within w_repair_balc_before
  184. integer x = 512
  185. integer y = 256
  186. integer width = 402
  187. integer height = 84
  188. integer taborder = 30
  189. boolean bringtotop = true
  190. integer textsize = -9
  191. integer weight = 400
  192. fontcharset fontcharset = gb2312charset!
  193. fontpitch fontpitch = variable!
  194. string facename = "宋体"
  195. long textcolor = 33554432
  196. borderstyle borderstyle = stylelowered!
  197. end type
  198. type cb_1 from commandbutton within w_repair_balc_before
  199. integer x = 1495
  200. integer y = 48
  201. integer width = 293
  202. integer height = 108
  203. integer taborder = 20
  204. boolean bringtotop = true
  205. integer textsize = -9
  206. integer weight = 400
  207. fontcharset fontcharset = gb2312charset!
  208. fontpitch fontpitch = variable!
  209. string facename = "宋体"
  210. string text = "重算"
  211. end type
  212. event clicked;IF MessageBox ("询问","是否确认要执行操作?",question!,yesno! ) = 2 THEN RETURN
  213. IF cur_storageid = -1 THEN
  214. MessageBox('提示','请选择仓库',information!,ok!)
  215. RETURN
  216. END IF
  217. IF Trim(sle_balcdateint.Text) = '' OR Trim(sle_balcdateint_before.Text) = '' THEN
  218. MessageBox('提示','请输入正确的结存日期',information!,ok!)
  219. RETURN
  220. END IF
  221. Long ll_balcdateint,ll_balcdateint_before
  222. Long rslt
  223. rslt = 1
  224. String arg_msg
  225. ll_balcdateint = Long(sle_balcdateint.Text)
  226. ll_balcdateint_before = Long(sle_balcdateint_before.Text)
  227. //1.用上次结存的结余金额更新要修改的结存的期初金额
  228. UPDATE u_warebalc
  229. SET u_warebalc.bgamt = a.balcamt
  230. FROM u_warebalc INNER JOIN
  231. (SELECT mtrlid, Storageid, status, pcode, woodcode, balcqty, balcamt
  232. FROM u_warebalc
  233. WHERE (Storageid = :cur_storageid) AND (balcdateint = :ll_balcdateint_before)) a ON
  234. u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.Storageid AND
  235. u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
  236. u_warebalc.woodcode = a.woodcode
  237. Where (u_warebalc.Storageid = :cur_storageid) And (u_warebalc.balcdateint = :ll_balcdateint);
  238. IF sqlca.SQLCode <> 0 THEN
  239. rslt = 0
  240. arg_msg = '更新结存期初金额失败'
  241. GOTO ext
  242. END IF
  243. //2.用当时结存的进仓单金额汇总出结存的期间进金额
  244. UPDATE u_warebalc
  245. SET u_warebalc.incamt = a.amt
  246. FROM u_warebalc INNER JOIN
  247. (SELECT u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
  248. u_inwaremx.pcode, ISNULL(SUM(u_inwaremx.qty), 0) AS qty,
  249. ISNULL(SUM(ROUND(u_inwaremx.cost * u_inwaremx.qty, 2)), 0) AS amt,
  250. u_inware.storageid
  251. FROM u_inware INNER JOIN
  252. u_inwaremx ON u_inware.scid = u_inwaremx.scid AND
  253. u_inware.inwareid = u_inwaremx.inwareid
  254. WHERE (u_inware.balcdateint = :ll_balcdateint) AND (u_inware.flag = 1)
  255. GROUP BY u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
  256. u_inwaremx.pcode, u_inware.storageid) a ON
  257. u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.storageid AND
  258. u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
  259. u_warebalc.woodcode = a.woodcode
  260. WHERE (u_warebalc.balcdateint = :ll_balcdateint)
  261. And (u_warebalc.Storageid = :cur_storageid);
  262. IF sqlca.SQLCode <> 0 THEN
  263. rslt = 0
  264. arg_msg = '更新现结存期间进金额失败'
  265. GOTO ext
  266. END IF
  267. //2.1更新出仓单costamt
  268. UPDATE u_outwaremx
  269. SET u_outwaremx.costamt = CASE (a.bgqty + a.incqty)
  270. WHEN 0 THEN 0 ELSE (a.bgamt + a.incamt) / (a.bgqty + a.incqty)
  271. END * u_outwaremx.qty
  272. FROM u_outwaremx INNER JOIN
  273. u_outware ON u_outwaremx.scid = u_outware.scid AND
  274. u_outwaremx.outwareid = u_outware.outwareid INNER JOIN
  275. (SELECT mtrlid, Storageid, status, pcode, woodcode, bgamt, incamt, bgqty,
  276. incqty
  277. FROM u_warebalc) a ON u_outwaremx.mtrlid = a.mtrlid AND
  278. u_outware.StorageID = a.Storageid AND u_outwaremx.status = a.status AND
  279. u_outwaremx.woodcode = a.woodcode AND u_outwaremx.pcode = a.pcode
  280. WHERE (u_outware.balcdateint = :ll_balcdateint) AND (u_outware.flag = 1)
  281. And (u_outware.Storageid = :cur_storageid);
  282. IF sqlca.SQLCode <> 0 THEN
  283. rslt = 0
  284. arg_msg = '更新出仓单金额失败'
  285. GOTO ext
  286. END IF
  287. //3.用当时结存的出仓单金额汇总出结存的期间出金额
  288. UPDATE u_warebalc
  289. SET u_warebalc.desamt = a.amt
  290. FROM u_warebalc INNER JOIN
  291. (SELECT u_outwaremx.mtrlid, u_outwaremx.status, u_outwaremx.woodcode,
  292. u_outwaremx.pcode, ISNULL(SUM(u_outwaremx.qty), 0) AS qty,
  293. ISNULL(SUM(ROUND(u_outwaremx.costamt, 2)), 0) AS amt,
  294. u_outware.StorageID
  295. FROM u_outware INNER JOIN
  296. u_outwaremx ON u_outware.scid = u_outwaremx.scid AND
  297. u_outware.outwareid = u_outwaremx.outwareid
  298. WHERE (u_outware.balcdateint = :ll_balcdateint) AND (u_outware.flag = 1)
  299. GROUP BY u_outwaremx.mtrlid, u_outwaremx.status, u_outwaremx.woodcode,
  300. u_outwaremx.pcode, u_outware.StorageID) a ON
  301. u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.StorageID AND
  302. u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
  303. u_warebalc.woodcode = a.woodcode
  304. WHERE (u_warebalc.balcdateint = :ll_balcdateint)
  305. And (u_warebalc.Storageid = :cur_storageid);
  306. IF sqlca.SQLCode <> 0 THEN
  307. rslt = 0
  308. arg_msg = '更新结存期间出金额失败'
  309. GOTO ext
  310. END IF
  311. //4.更新结余金额
  312. UPDATE u_warebalc
  313. SET balcamt = bgamt + incamt - desamt
  314. WHERE balcdateint = :ll_balcdateint
  315. AND Storageid = :cur_storageid;
  316. IF sqlca.SQLCode <> 0 THEN
  317. rslt = 0
  318. arg_msg = '更新结余金额失败'
  319. GOTO ext
  320. END IF
  321. ext:
  322. IF rslt = 1 THEN
  323. COMMIT;
  324. MessageBox('提示','操作完成!',information!,ok!)
  325. ELSE
  326. ROLLBACK;
  327. MessageBox('错误',arg_msg,stopsign!,ok!)
  328. END IF
  329. end event
  330. type ddlb_1 from uo_ddlb_storageid within w_repair_balc_before
  331. integer x = 512
  332. integer y = 52
  333. integer width = 635
  334. integer height = 504
  335. integer taborder = 20
  336. boolean bringtotop = true
  337. end type
  338. event selectionchanged;call super::selectionchanged;cur_storageid = this.uo_storageid
  339. end event
  340. event constructor;call super::constructor;cur_storageid = this.uo_storageid
  341. end event