$PBExportHeader$w_outware_sale_mx4_noallocqty.srw forward global type w_outware_sale_mx4_noallocqty from w_publ_base end type type dw_1 from datawindow within w_outware_sale_mx4_noallocqty end type type cbx_1 from checkbox within w_outware_sale_mx4_noallocqty end type end forward global type w_outware_sale_mx4_noallocqty from w_publ_base integer y = 388 integer width = 4096 integer height = 1610 string title = "发货明细产品清单组成汇总" boolean minbox = false windowtype windowtype = response! dw_1 dw_1 cbx_1 cbx_1 end type global w_outware_sale_mx4_noallocqty w_outware_sale_mx4_noallocqty type variables s_saletask_mtrl s_mx long in_mtrlid,in_uqty end variables on w_outware_sale_mx4_noallocqty.create int iCurrent call super::create this.dw_1=create dw_1 this.cbx_1=create cbx_1 iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.dw_1 this.Control[iCurrent+2]=this.cbx_1 end on on w_outware_sale_mx4_noallocqty.destroy call super::destroy destroy(this.dw_1) destroy(this.cbx_1) end on event open;call super::open;dw_1.settransobject(sqlca) dw_1.Retrieve() s_mx=Message.PowerObjectParm long index,i,j long it_mxt = 1 long count = 1 long ll_SonMtrlid[] Decimal ld_Sonscale[] Decimal ls_noallocqty string ls_mtrlcode,ls_mtrlname,ls_mtrlmode,ls_unit,ls_mtrlsectype,ls_zxmtrlmode,ls_dscrp FOR index = 1 TO upperbound(s_mx.mtrlid) in_mtrlid = s_mx.mtrlid[index] in_uqty = s_mx.qty[index] it_mxt = 1//遍历每条明细重新重置it_mxt(明细下级物料清单数) DECLARE cur_pf CURSOR FOR SELECT u_PrdPF.SonMtrlid, u_PrdPF.Sonscale FROM u_PrdPF Where u_PrdPF.mtrlid = :in_mtrlid; OPEN cur_pf; FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt]; DO WHILE sqlca.SQLCode = 0 it_mxt++ FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt]; LOOP it_mxt = it_mxt - 1 CLOSE cur_pf; IF it_mxt = 0 THEN if dw_1.RowCount() <>0 then for i = 1 to count - 1 if dw_1.Object.mtrlid[i] = in_mtrlid then dw_1.Object.uqty[i] =dw_1.Object.uqty[i] + in_uqty dw_1.Object.cqty[i] = dw_1.Object.cqty[i] +in_uqty GOTO nextmx//跳出这次插入 end if next end if select mtrlcode,mtrlname,mtrlmode,unit,mtrlsectype,zxmtrlmode,dscrp,noallocqty into :ls_mtrlcode,:ls_mtrlname,:ls_mtrlmode,:ls_unit,:ls_mtrlsectype,:ls_zxmtrlmode,:ls_dscrp,:ls_noallocqty from u_mtrldef left join u_mtrlware on u_mtrldef.mtrlid = u_mtrlware.mtrlid where u_mtrldef.mtrlid = :in_mtrlid; IF sqlca.SQLCode <> 0 THEN CONTINUE END IF dw_1.Object.mtrlid[count] = in_mtrlid dw_1.Object.mtrlcode[count] = ls_mtrlcode dw_1.Object.mtrlname[count] = ls_mtrlname dw_1.Object.mtrlmode[count] = ls_mtrlmode dw_1.Object.unit[count] = ls_unit dw_1.Object.mtrlsectype[count] = ls_mtrlsectype dw_1.Object.zxmtrlmode[count] = ls_zxmtrlmode dw_1.Object.dscrp[count] = ls_dscrp dw_1.Object.noallocqty[count] = ls_noallocqty dw_1.Object.uqty[count] = in_uqty dw_1.Object.cqty[count] = in_uqty - ls_noallocqty count++ ELSE FOR j =1 TO it_mxt if dw_1.RowCount() <>0 then for i = 1 to count - 1//count 有一个提前量,比实际的dw行数多1 if dw_1.Object.mtrlid[i] = ll_SonMtrlid[j] then//当遇到重复的物料ID时直接在已有的row上面增加需求数量 dw_1.Object.uqty[i] =dw_1.Object.uqty[i] + in_uqty * ld_Sonscale[j] dw_1.Object.cqty[i] = dw_1.Object.cqty[i] + in_uqty * ld_Sonscale[j] GOTO nextson//跳出这次插入 end if next end if select mtrlcode,mtrlname,mtrlmode,unit,mtrlsectype,zxmtrlmode,dscrp,noallocqty into :ls_mtrlcode,:ls_mtrlname,:ls_mtrlmode,:ls_unit,:ls_mtrlsectype,:ls_zxmtrlmode,:ls_dscrp,:ls_noallocqty from u_mtrldef left join u_mtrlware on u_mtrldef.mtrlid = u_mtrlware.mtrlid where u_mtrldef.mtrlid = :ll_SonMtrlid[j]; IF sqlca.SQLCode <> 0 THEN CONTINUE END IF dw_1.Object.mtrlid[count] = ll_SonMtrlid[j] dw_1.Object.mtrlcode[count] = ls_mtrlcode dw_1.Object.mtrlname[count] = ls_mtrlname dw_1.Object.mtrlmode[count] = ls_mtrlmode dw_1.Object.unit[count] = ls_unit dw_1.Object.mtrlsectype[count] = ls_mtrlsectype dw_1.Object.zxmtrlmode[count] = ls_zxmtrlmode dw_1.Object.dscrp[count] = ls_dscrp dw_1.Object.noallocqty[count] = ls_noallocqty dw_1.Object.uqty[count] = in_uqty * ld_Sonscale[j] dw_1.Object.cqty[count] = in_uqty * ld_Sonscale[j] - ls_noallocqty count++ nextson: NEXT END IF nextmx: NEXT dw_1.setfocus() end event type cb_func from w_publ_base`cb_func within w_outware_sale_mx4_noallocqty boolean visible = false end type type cb_exit from w_publ_base`cb_exit within w_outware_sale_mx4_noallocqty integer x = 1851 integer y = 1405 integer picsize = 16 end type type dw_1 from datawindow within w_outware_sale_mx4_noallocqty integer width = 4034 integer height = 1363 integer taborder = 30 boolean bringtotop = true string title = "none" string dataobject = "dw_outware_sale_mx4_noallocqty" boolean livescroll = true borderstyle borderstyle = stylelowered! end type event constructor;f_title_change(this) end event type cbx_1 from checkbox within w_outware_sale_mx4_noallocqty boolean visible = false integer x = 388 integer y = 1424 integer width = 402 integer height = 61 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 134217739 string text = "全选" end type event clicked;Long i dw_1.setredraw(false) IF This.Checked THEN FOR i = 1 To dw_1.RowCount() dw_1.Object.ch[i] = 1 NEXT ELSE FOR i = 1 To dw_1.RowCount() dw_1.Object.ch[i] = 0 NEXT END IF dw_1.setredraw(true) end event