w_outware_sale_mx4_noallocqty.srw 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. $PBExportHeader$w_outware_sale_mx4_noallocqty.srw
  2. forward
  3. global type w_outware_sale_mx4_noallocqty from w_publ_base
  4. end type
  5. type dw_1 from datawindow within w_outware_sale_mx4_noallocqty
  6. end type
  7. type cbx_1 from checkbox within w_outware_sale_mx4_noallocqty
  8. end type
  9. end forward
  10. global type w_outware_sale_mx4_noallocqty from w_publ_base
  11. integer y = 388
  12. integer width = 4096
  13. integer height = 1610
  14. string title = "发货明细产品清单组成汇总"
  15. boolean minbox = false
  16. windowtype windowtype = response!
  17. dw_1 dw_1
  18. cbx_1 cbx_1
  19. end type
  20. global w_outware_sale_mx4_noallocqty w_outware_sale_mx4_noallocqty
  21. type variables
  22. s_saletask_mtrl s_mx
  23. long in_mtrlid,in_uqty
  24. end variables
  25. on w_outware_sale_mx4_noallocqty.create
  26. int iCurrent
  27. call super::create
  28. this.dw_1=create dw_1
  29. this.cbx_1=create cbx_1
  30. iCurrent=UpperBound(this.Control)
  31. this.Control[iCurrent+1]=this.dw_1
  32. this.Control[iCurrent+2]=this.cbx_1
  33. end on
  34. on w_outware_sale_mx4_noallocqty.destroy
  35. call super::destroy
  36. destroy(this.dw_1)
  37. destroy(this.cbx_1)
  38. end on
  39. event open;call super::open;dw_1.settransobject(sqlca)
  40. dw_1.Retrieve()
  41. s_mx=Message.PowerObjectParm
  42. long index,i,j
  43. long it_mxt = 1
  44. long count = 1
  45. long ll_SonMtrlid[]
  46. Decimal ld_Sonscale[]
  47. Decimal ls_noallocqty
  48. string ls_mtrlcode,ls_mtrlname,ls_mtrlmode,ls_unit,ls_mtrlsectype,ls_zxmtrlmode,ls_dscrp
  49. FOR index = 1 TO upperbound(s_mx.mtrlid)
  50. in_mtrlid = s_mx.mtrlid[index]
  51. in_uqty = s_mx.qty[index]
  52. it_mxt = 1//遍历每条明细重新重置it_mxt(明细下级物料清单数)
  53. DECLARE cur_pf CURSOR FOR
  54. SELECT u_PrdPF.SonMtrlid,
  55. u_PrdPF.Sonscale
  56. FROM u_PrdPF
  57. Where u_PrdPF.mtrlid = :in_mtrlid;
  58. OPEN cur_pf;
  59. FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt];
  60. DO WHILE sqlca.SQLCode = 0
  61. it_mxt++
  62. FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt];
  63. LOOP
  64. it_mxt = it_mxt - 1
  65. CLOSE cur_pf;
  66. IF it_mxt = 0 THEN
  67. if dw_1.RowCount() <>0 then
  68. for i = 1 to count - 1
  69. if dw_1.Object.mtrlid[i] = in_mtrlid then
  70. dw_1.Object.uqty[i] =dw_1.Object.uqty[i] + in_uqty
  71. dw_1.Object.cqty[i] = dw_1.Object.cqty[i] +in_uqty
  72. GOTO nextmx//跳出这次插入
  73. end if
  74. next
  75. end if
  76. select mtrlcode,mtrlname,mtrlmode,unit,mtrlsectype,zxmtrlmode,dscrp,noallocqty
  77. into :ls_mtrlcode,:ls_mtrlname,:ls_mtrlmode,:ls_unit,:ls_mtrlsectype,:ls_zxmtrlmode,:ls_dscrp,:ls_noallocqty
  78. from u_mtrldef
  79. left join u_mtrlware
  80. on u_mtrldef.mtrlid = u_mtrlware.mtrlid
  81. where u_mtrldef.mtrlid = :in_mtrlid;
  82. IF sqlca.SQLCode <> 0 THEN
  83. CONTINUE
  84. END IF
  85. dw_1.Object.mtrlid[count] = in_mtrlid
  86. dw_1.Object.mtrlcode[count] = ls_mtrlcode
  87. dw_1.Object.mtrlname[count] = ls_mtrlname
  88. dw_1.Object.mtrlmode[count] = ls_mtrlmode
  89. dw_1.Object.unit[count] = ls_unit
  90. dw_1.Object.mtrlsectype[count] = ls_mtrlsectype
  91. dw_1.Object.zxmtrlmode[count] = ls_zxmtrlmode
  92. dw_1.Object.dscrp[count] = ls_dscrp
  93. dw_1.Object.noallocqty[count] = ls_noallocqty
  94. dw_1.Object.uqty[count] = in_uqty
  95. dw_1.Object.cqty[count] = in_uqty - ls_noallocqty
  96. count++
  97. ELSE
  98. FOR j =1 TO it_mxt
  99. if dw_1.RowCount() <>0 then
  100. for i = 1 to count - 1//count 有一个提前量,比实际的dw行数多1
  101. if dw_1.Object.mtrlid[i] = ll_SonMtrlid[j] then//当遇到重复的物料ID时直接在已有的row上面增加需求数量
  102. dw_1.Object.uqty[i] =dw_1.Object.uqty[i] + in_uqty * ld_Sonscale[j]
  103. dw_1.Object.cqty[i] = dw_1.Object.cqty[i] + in_uqty * ld_Sonscale[j]
  104. GOTO nextson//跳出这次插入
  105. end if
  106. next
  107. end if
  108. select mtrlcode,mtrlname,mtrlmode,unit,mtrlsectype,zxmtrlmode,dscrp,noallocqty
  109. into :ls_mtrlcode,:ls_mtrlname,:ls_mtrlmode,:ls_unit,:ls_mtrlsectype,:ls_zxmtrlmode,:ls_dscrp,:ls_noallocqty
  110. from u_mtrldef
  111. left join u_mtrlware
  112. on u_mtrldef.mtrlid = u_mtrlware.mtrlid
  113. where u_mtrldef.mtrlid = :ll_SonMtrlid[j];
  114. IF sqlca.SQLCode <> 0 THEN
  115. CONTINUE
  116. END IF
  117. dw_1.Object.mtrlid[count] = ll_SonMtrlid[j]
  118. dw_1.Object.mtrlcode[count] = ls_mtrlcode
  119. dw_1.Object.mtrlname[count] = ls_mtrlname
  120. dw_1.Object.mtrlmode[count] = ls_mtrlmode
  121. dw_1.Object.unit[count] = ls_unit
  122. dw_1.Object.mtrlsectype[count] = ls_mtrlsectype
  123. dw_1.Object.zxmtrlmode[count] = ls_zxmtrlmode
  124. dw_1.Object.dscrp[count] = ls_dscrp
  125. dw_1.Object.noallocqty[count] = ls_noallocqty
  126. dw_1.Object.uqty[count] = in_uqty * ld_Sonscale[j]
  127. dw_1.Object.cqty[count] = in_uqty * ld_Sonscale[j] - ls_noallocqty
  128. count++
  129. nextson:
  130. NEXT
  131. END IF
  132. nextmx:
  133. NEXT
  134. dw_1.setfocus()
  135. end event
  136. type cb_func from w_publ_base`cb_func within w_outware_sale_mx4_noallocqty
  137. boolean visible = false
  138. end type
  139. type cb_exit from w_publ_base`cb_exit within w_outware_sale_mx4_noallocqty
  140. integer x = 1851
  141. integer y = 1405
  142. integer picsize = 16
  143. end type
  144. type dw_1 from datawindow within w_outware_sale_mx4_noallocqty
  145. integer width = 4034
  146. integer height = 1363
  147. integer taborder = 30
  148. boolean bringtotop = true
  149. string title = "none"
  150. string dataobject = "dw_outware_sale_mx4_noallocqty"
  151. boolean livescroll = true
  152. borderstyle borderstyle = stylelowered!
  153. end type
  154. event constructor;f_title_change(this)
  155. end event
  156. type cbx_1 from checkbox within w_outware_sale_mx4_noallocqty
  157. boolean visible = false
  158. integer x = 388
  159. integer y = 1424
  160. integer width = 402
  161. integer height = 61
  162. boolean bringtotop = true
  163. integer textsize = -9
  164. integer weight = 400
  165. fontcharset fontcharset = gb2312charset!
  166. fontpitch fontpitch = variable!
  167. string facename = "宋体"
  168. long textcolor = 33554432
  169. long backcolor = 134217739
  170. string text = "全选"
  171. end type
  172. event clicked;Long i
  173. dw_1.setredraw(false)
  174. IF This.Checked THEN
  175. FOR i = 1 To dw_1.RowCount()
  176. dw_1.Object.ch[i] = 1
  177. NEXT
  178. ELSE
  179. FOR i = 1 To dw_1.RowCount()
  180. dw_1.Object.ch[i] = 0
  181. NEXT
  182. END IF
  183. dw_1.setredraw(true)
  184. end event