123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- $PBExportHeader$w_repair_balc.srw
- forward
- global type w_repair_balc from w_publ_base
- end type
- type cb_17 from commandbutton within w_repair_balc
- end type
- type cb_1 from commandbutton within w_repair_balc
- end type
- type st_1 from statictext within w_repair_balc
- end type
- end forward
- global type w_repair_balc from w_publ_base
- integer width = 1371
- integer height = 636
- string title = "修复结存金额,库存金额"
- boolean minbox = false
- windowtype windowtype = response!
- cb_17 cb_17
- cb_1 cb_1
- st_1 st_1
- end type
- global w_repair_balc w_repair_balc
- on w_repair_balc.create
- int iCurrent
- call super::create
- this.cb_17=create cb_17
- this.cb_1=create cb_1
- this.st_1=create st_1
- iCurrent=UpperBound(this.Control)
- this.Control[iCurrent+1]=this.cb_17
- this.Control[iCurrent+2]=this.cb_1
- this.Control[iCurrent+3]=this.st_1
- end on
- on w_repair_balc.destroy
- call super::destroy
- destroy(this.cb_17)
- destroy(this.cb_1)
- destroy(this.st_1)
- end on
- type cb_func from w_publ_base`cb_func within w_repair_balc
- boolean visible = false
- integer x = 1431
- integer y = 816
- end type
- type cb_exit from w_publ_base`cb_exit within w_repair_balc
- integer x = 1006
- integer y = 444
- end type
- type cb_17 from commandbutton within w_repair_balc
- integer x = 32
- integer y = 180
- integer width = 480
- integer height = 84
- integer taborder = 10
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "2.修复现结存金额"
- end type
- event clicked;IF MessageBox ("询问","是否确认要执行操作?",question!,yesno! ) = 2 THEN RETURN
- //1.用最近一次结存的结余金额更新现结存的期初金额
- Long rslt
- rslt = 1
- Long ll_storageid[]
- Long i
- Long ll_i
- Long ll_balcdateint
- String arg_msg
- Decimal ld_balcamt
- i = 1
- DECLARE cur_storage CURSOR FOR
- SELECT DISTINCT Storageid
- FROM u_warebalc
- Order By Storageid;
-
- OPEN cur_storage;
- FETCH cur_storage INTO :ll_storageid[i];
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH cur_storage INTO :ll_storageid[i];
- LOOP
- CLOSE cur_storage;
- FOR ll_i = 1 TO i - 1
- SELECT max(balcdateint) INTO :ll_balcdateint
- FROM u_warebalc
- Where Storageid = :ll_storageid[ll_i];
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库'+String(ll_storageid[ll_i])+'最近一次结存日期失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ll_balcdateint = 0 THEN CONTINUE //如果该仓库没有结存过,则跳过
-
- //用物料最近结存的结余金额更新现结存的期初金额
- UPDATE u_warebalc
- SET u_warebalc.bgamt = a.balcamt
- FROM u_warebalc INNER JOIN
- (SELECT mtrlid, Storageid, status, pcode, woodcode, balcqty, balcamt
- FROM u_warebalc
- WHERE (Storageid = :ll_storageid[ll_i]) AND (balcdateint = :ll_balcdateint)) a ON
- u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.Storageid AND
- u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
- u_warebalc.woodcode = a.woodcode
- Where (u_warebalc.Storageid = :ll_storageid[ll_i]) And (u_warebalc.balcdateint = 0);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新现结存期初金额失败,仓库:'+String(ll_storageid[ll_i])
- GOTO ext
- END IF
-
- NEXT
- //2.用未结存的进仓单金额汇总出现结存的期间进金额
- UPDATE u_warebalc
- SET u_warebalc.incamt = a.amt
- FROM u_warebalc INNER JOIN
- (SELECT u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
- u_inwaremx.pcode, ISNULL(SUM(u_inwaremx.qty), 0) AS qty,
- ISNULL(SUM(ROUND(u_inwaremx.cost * u_inwaremx.qty, 2)), 0) AS amt,
- u_inware.storageid
- FROM u_inware INNER JOIN
- u_inwaremx ON u_inware.scid = u_inwaremx.scid AND
- u_inware.inwareid = u_inwaremx.inwareid
- WHERE (u_inware.balcdateint = 0) AND (u_inware.flag = 1)
- GROUP BY u_inwaremx.mtrlid, u_inwaremx.status, u_inwaremx.woodcode,
- u_inwaremx.pcode, u_inware.storageid) a ON
- u_warebalc.mtrlid = a.mtrlid AND u_warebalc.Storageid = a.storageid AND
- u_warebalc.status = a.status AND u_warebalc.pcode = a.pcode AND
- u_warebalc.woodcode = a.woodcode
- Where (u_warebalc.balcdateint = 0);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新现结存期间进金额失败'
- GOTO ext
- END IF
- ext:
- IF rslt = 1 THEN
- COMMIT;
- MessageBox('提示','操作完成!',information!,ok!)
- ELSE
- ROLLBACK;
- MessageBox('错误',arg_msg,stopsign!,ok!)
- END IF
- end event
- type cb_1 from commandbutton within w_repair_balc
- integer x = 27
- integer y = 36
- integer width = 549
- integer height = 84
- integer taborder = 10
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "1.修复历史结存金额"
- end type
- event clicked;open(w_repair_balc_before)
- end event
- type st_1 from statictext within w_repair_balc
- integer x = 41
- integer y = 324
- integer width = 1193
- integer height = 48
- 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 = "3.执行~"结存预览~"中的~"重算~"功能,更新库存金额"
- boolean focusrectangle = false
- end type
|