w_cmpl_balc.srw 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. $PBExportHeader$w_cmpl_balc.srw
  2. forward
  3. global type w_cmpl_balc from window
  4. end type
  5. type st_4 from statictext within w_cmpl_balc
  6. end type
  7. type sle_balcdateint_next from singlelineedit within w_cmpl_balc
  8. end type
  9. type st_3 from statictext within w_cmpl_balc
  10. end type
  11. type st_2 from statictext within w_cmpl_balc
  12. end type
  13. type st_1 from statictext within w_cmpl_balc
  14. end type
  15. type sle_balcdateint from singlelineedit within w_cmpl_balc
  16. end type
  17. type sle_storageid from singlelineedit within w_cmpl_balc
  18. end type
  19. type cb_1 from commandbutton within w_cmpl_balc
  20. end type
  21. end forward
  22. global type w_cmpl_balc from window
  23. integer width = 1797
  24. integer height = 964
  25. boolean titlebar = true
  26. string title = "Untitled"
  27. boolean controlmenu = true
  28. boolean minbox = true
  29. boolean maxbox = true
  30. boolean resizable = true
  31. long backcolor = 67108864
  32. string icon = "AppIcon!"
  33. boolean center = true
  34. st_4 st_4
  35. sle_balcdateint_next sle_balcdateint_next
  36. st_3 st_3
  37. st_2 st_2
  38. st_1 st_1
  39. sle_balcdateint sle_balcdateint
  40. sle_storageid sle_storageid
  41. cb_1 cb_1
  42. end type
  43. global w_cmpl_balc w_cmpl_balc
  44. on w_cmpl_balc.create
  45. this.st_4=create st_4
  46. this.sle_balcdateint_next=create sle_balcdateint_next
  47. this.st_3=create st_3
  48. this.st_2=create st_2
  49. this.st_1=create st_1
  50. this.sle_balcdateint=create sle_balcdateint
  51. this.sle_storageid=create sle_storageid
  52. this.cb_1=create cb_1
  53. this.Control[]={this.st_4,&
  54. this.sle_balcdateint_next,&
  55. this.st_3,&
  56. this.st_2,&
  57. this.st_1,&
  58. this.sle_balcdateint,&
  59. this.sle_storageid,&
  60. this.cb_1}
  61. end on
  62. on w_cmpl_balc.destroy
  63. destroy(this.st_4)
  64. destroy(this.sle_balcdateint_next)
  65. destroy(this.st_3)
  66. destroy(this.st_2)
  67. destroy(this.st_1)
  68. destroy(this.sle_balcdateint)
  69. destroy(this.sle_storageid)
  70. destroy(this.cb_1)
  71. end on
  72. type st_4 from statictext within w_cmpl_balc
  73. integer x = 155
  74. integer y = 412
  75. integer width = 457
  76. integer height = 72
  77. integer textsize = -12
  78. integer weight = 400
  79. fontcharset fontcharset = ansi!
  80. fontpitch fontpitch = variable!
  81. fontfamily fontfamily = swiss!
  82. string facename = "Arial"
  83. long textcolor = 33554432
  84. long backcolor = 67108864
  85. string text = "下月结存日"
  86. boolean focusrectangle = false
  87. end type
  88. type sle_balcdateint_next from singlelineedit within w_cmpl_balc
  89. integer x = 640
  90. integer y = 376
  91. integer width = 457
  92. integer height = 128
  93. integer taborder = 30
  94. integer textsize = -12
  95. integer weight = 400
  96. fontcharset fontcharset = ansi!
  97. fontpitch fontpitch = variable!
  98. fontfamily fontfamily = swiss!
  99. string facename = "Arial"
  100. long textcolor = 33554432
  101. borderstyle borderstyle = stylelowered!
  102. end type
  103. type st_3 from statictext within w_cmpl_balc
  104. integer x = 155
  105. integer y = 272
  106. integer width = 457
  107. integer height = 72
  108. integer textsize = -12
  109. integer weight = 400
  110. fontcharset fontcharset = ansi!
  111. fontpitch fontpitch = variable!
  112. fontfamily fontfamily = swiss!
  113. string facename = "Arial"
  114. long textcolor = 33554432
  115. long backcolor = 67108864
  116. string text = "本月结存日"
  117. boolean focusrectangle = false
  118. end type
  119. type st_2 from statictext within w_cmpl_balc
  120. integer x = 155
  121. integer y = 128
  122. integer width = 457
  123. integer height = 72
  124. integer textsize = -12
  125. integer weight = 400
  126. fontcharset fontcharset = ansi!
  127. fontpitch fontpitch = variable!
  128. fontfamily fontfamily = swiss!
  129. string facename = "Arial"
  130. long textcolor = 33554432
  131. long backcolor = 67108864
  132. string text = "仓库ID"
  133. boolean focusrectangle = false
  134. end type
  135. type st_1 from statictext within w_cmpl_balc
  136. integer x = 46
  137. integer y = 544
  138. integer width = 873
  139. integer height = 72
  140. integer textsize = -12
  141. integer weight = 400
  142. fontcharset fontcharset = ansi!
  143. fontpitch fontpitch = variable!
  144. fontfamily fontfamily = swiss!
  145. string facename = "Arial"
  146. long textcolor = 33554432
  147. long backcolor = 67108864
  148. string text = "none"
  149. boolean focusrectangle = false
  150. end type
  151. type sle_balcdateint from singlelineedit within w_cmpl_balc
  152. integer x = 640
  153. integer y = 240
  154. integer width = 457
  155. integer height = 128
  156. integer taborder = 20
  157. integer textsize = -12
  158. integer weight = 400
  159. fontcharset fontcharset = ansi!
  160. fontpitch fontpitch = variable!
  161. fontfamily fontfamily = swiss!
  162. string facename = "Arial"
  163. long textcolor = 33554432
  164. borderstyle borderstyle = stylelowered!
  165. end type
  166. type sle_storageid from singlelineedit within w_cmpl_balc
  167. integer x = 640
  168. integer y = 104
  169. integer width = 457
  170. integer height = 128
  171. integer taborder = 10
  172. integer textsize = -12
  173. integer weight = 400
  174. fontcharset fontcharset = ansi!
  175. fontpitch fontpitch = variable!
  176. fontfamily fontfamily = swiss!
  177. string facename = "Arial"
  178. long textcolor = 33554432
  179. string text = "11"
  180. borderstyle borderstyle = stylelowered!
  181. end type
  182. type cb_1 from commandbutton within w_cmpl_balc
  183. integer x = 1207
  184. integer y = 72
  185. integer width = 494
  186. integer height = 104
  187. integer taborder = 10
  188. integer textsize = -9
  189. integer weight = 400
  190. fontcharset fontcharset = gb2312charset!
  191. fontpitch fontpitch = variable!
  192. string facename = "宋体"
  193. string text = "计算结存"
  194. end type
  195. event clicked;Int rslt = 1
  196. String ls_msg
  197. Long ll_storageid
  198. Long ll_balcdateint,ll_balcdateint_next
  199. datetime ldt_balcdate
  200. ll_storageid = Long(sle_storageid.Text)
  201. ll_balcdateint = Long(sle_balcdateint.Text)
  202. ll_balcdateint_next = Long(sle_balcdateint_next.Text)
  203. ldt_balcdate = datetime(date(mid(sle_balcdateint.Text,1,4)+'-'+mid(sle_balcdateint.Text,5,2)+'-'+right(sle_balcdateint.Text,2)),time('23:59:59'))
  204. messagebox('',string(ldt_balcdate))
  205. DELETE FROM u_warebalc
  206. WHERE balcdateint = :ll_balcdateint
  207. AND storageid = :ll_storageid;
  208. IF sqlca.SQLCode <> 0 THEN
  209. ls_msg = '删除结存失败,'+sqlca.SQLErrText
  210. rslt = 0
  211. GOTO ext
  212. END IF
  213. IF ll_balcdateint = 0 THEN
  214. INSERT INTO u_warebalc
  215. (balcdateint,
  216. mtrlid,
  217. storageid,
  218. status,
  219. woodcode,
  220. pcode,
  221. balcqty,
  222. balcamt,
  223. scid )
  224. SELECT
  225. :ll_balcdateint,
  226. mtrlid,
  227. u_mtrlware.storageid,
  228. status,
  229. woodcode,
  230. pcode,
  231. sum(noallocqty),
  232. sum(wareamt),
  233. u_storage.scid
  234. FROM u_mtrlware inner join u_storage on
  235. u_mtrlware.storageid = u_storage.storageid
  236. WHERE u_mtrlware.storageid = :ll_storageid
  237. GROUP BY
  238. mtrlid,
  239. u_mtrlware.storageid,
  240. status,
  241. woodcode,
  242. pcode,
  243. u_storage.scid ;
  244. IF sqlca.SQLCode <> 0 THEN
  245. ls_msg = '库存->结存失败,'+sqlca.SQLErrText
  246. rslt = 0
  247. GOTO ext
  248. END IF
  249. ELSE
  250. INSERT INTO u_warebalc
  251. (balcdateint,
  252. balcdate,
  253. mtrlid,
  254. storageid,
  255. status,
  256. woodcode,
  257. pcode,
  258. balcqty,
  259. balcamt,
  260. scid )
  261. SELECT
  262. :ll_balcdateint,
  263. :ldt_balcdate,
  264. mtrlid,
  265. u_warebalc.storageid,
  266. status,
  267. woodcode,
  268. pcode,
  269. bgqty,
  270. bgamt,
  271. u_warebalc.scid
  272. FROM u_warebalc
  273. WHERE u_warebalc.storageid = :ll_storageid
  274. and u_warebalc.balcdateint = :ll_balcdateint_next;
  275. IF sqlca.SQLCode <> 0 THEN
  276. ls_msg = '结存->结存失败,'+sqlca.SQLErrText
  277. rslt = 0
  278. GOTO ext
  279. END IF
  280. END IF
  281. COMMIT;
  282. Long ll_i,ll_count
  283. Long ll_mtrlid
  284. String ls_status,ls_woodcode,ls_pcode
  285. Decimal ld_balcqty,ld_balcamt
  286. Decimal ld_inqty,ld_inamt
  287. Decimal ld_decqty,ld_decamt
  288. Decimal ld_bgqty,ld_bgamt
  289. long ll_sptid
  290. datastore ds
  291. ds = CREATE datastore
  292. ds.DataObject = 'ds_balc'
  293. ds.SetTransObject(sqlca)
  294. ll_count = ds.Retrieve(ll_storageid,ll_balcdateint)
  295. MessageBox('',ll_count)
  296. FOR ll_i = 1 TO ll_count
  297. st_1.Text = String(ll_i)+'/'+String(ll_count)
  298. ll_mtrlid = ds.Object.mtrlid[ll_i]
  299. ls_status = ds.Object.status[ll_i]
  300. ls_woodcode = ds.Object.woodcode[ll_i]
  301. ls_pcode = ds.Object.pcode[ll_i]
  302. ld_balcqty = ds.Object.balcqty[ll_i]
  303. ld_balcamt = ds.Object.balcamt[ll_i]
  304. SELECT isnull(sum(qty),0),isnull(sum(round(cost * qty,2)),0)
  305. INTO :ld_inqty,:ld_inamt
  306. FROM u_inware,u_inwaremx
  307. WHERE u_inware.inwareid = u_inwaremx.inwareid
  308. AND u_inwaremx.mtrlid = :ll_mtrlid
  309. AND u_inwaremx.status = :ls_status
  310. AND u_inwaremx.woodcode = :ls_woodcode
  311. AND u_inwaremx.pcode = :ls_pcode
  312. AND u_inware.storageid = :ll_storageid
  313. AND u_inware.balcdateint = :ll_balcdateint
  314. AND u_inware.flag = 1;
  315. IF sqlca.SQLCode <> 0 THEN
  316. ls_msg = '进仓失败,'+sqlca.SQLErrText
  317. rslt = 0
  318. GOTO ext
  319. END IF
  320. SELECT isnull(sum(qty),0),isnull(sum(costamt),0)
  321. INTO :ld_decqty,:ld_decamt
  322. FROM u_outware,u_outwaremx
  323. WHERE u_outware.outwareid = u_outwaremx.outwareid
  324. AND u_outwaremx.mtrlid = :ll_mtrlid
  325. AND u_outwaremx.status = :ls_status
  326. AND u_outwaremx.woodcode = :ls_woodcode
  327. AND u_outwaremx.pcode = :ls_pcode
  328. AND u_outware.storageid = :ll_storageid
  329. AND u_outware.balcdateint = :ll_balcdateint
  330. AND u_outware.flag = 1;
  331. IF sqlca.SQLCode <> 0 THEN
  332. ls_msg = '出仓失败,'+sqlca.SQLErrText
  333. rslt = 0
  334. GOTO ext
  335. END IF
  336. ld_bgqty = ld_balcqty + ld_decqty - ld_inqty
  337. ld_bgamt = ld_balcamt + ld_decamt - ld_inamt
  338. UPDATE u_warebalc
  339. SET bgqty = :ld_bgqty,
  340. bgamt = :ld_bgamt,
  341. incqty = :ld_inqty,
  342. incamt = :ld_inamt,
  343. desqty = :ld_decqty,
  344. desamt = :ld_decamt
  345. WHERE balcdateint = :ll_balcdateint
  346. AND mtrlid = :ll_mtrlid
  347. AND storageid = :ll_storageid
  348. AND status = :ls_status
  349. and woodcode = :ls_woodcode
  350. and pcode = :ls_pcode;
  351. IF sqlca.SQLCode <> 0 THEN
  352. ls_msg = 'u结存失败,'+sqlca.SQLErrText
  353. rslt = 0
  354. GOTO ext
  355. END IF
  356. NEXT
  357. ls_msg = 'ok'
  358. ext:
  359. IF rslt = 0 THEN
  360. ROLLBACK;
  361. ELSE
  362. COMMIT;
  363. END IF
  364. MessageBox('',ls_msg)
  365. end event