1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762 |
- $PBExportHeader$w_warebalc_view.srw
- forward
- global type w_warebalc_view from w_publ_easyq
- end type
- type tv_1 from uo_tv_mtrltype within w_warebalc_view
- end type
- type st_2 from statictext within w_warebalc_view
- end type
- type ddlb_storageid from uo_ddlb_storageid within w_warebalc_view
- end type
- type cb_other from uo_imflatbutton within w_warebalc_view
- end type
- type st_1 from statictext within w_warebalc_view
- end type
- type em_month from editmask within w_warebalc_view
- end type
- type st_lastbalcdate from statictext within w_warebalc_view
- end type
- type ddlb_1 from dropdownlistbox within w_warebalc_view
- end type
- type cb_balc from uo_imflatbutton within w_warebalc_view
- end type
- end forward
- global type w_warebalc_view from w_publ_easyq
- string title = "仓库结存表"
- event ue_retrieve_info ( )
- event retrieve_pageretr ( )
- event ue_mtrl_info ( )
- event ue_retrieve_inoutmx ( )
- event ue_usual_query_filt ( )
- event ue_usual_query_retr ( )
- event ue_cmp_mtrlware ( )
- event ue_cmp_amt2 ( )
- event ue_cmp ( )
- event ue_update_inware_mtrlwareid ( )
- tv_1 tv_1
- st_2 st_2
- ddlb_storageid ddlb_storageid
- cb_other cb_other
- st_1 st_1
- em_month em_month
- st_lastbalcdate st_lastbalcdate
- ddlb_1 ddlb_1
- cb_balc cb_balc
- end type
- global w_warebalc_view w_warebalc_view
- type variables
- Long cur_storageid = -1
- Long cur_storageid_arr[]
- DateTime balcdate //结存日期
- Int cur_mtrlorigin = -1 //当前显示物料来源
- String ls_handtype = ''
- string ls_mtrltype = ''
- long ins_if_info = 0
- integer cur_billtype_in = -1
- integer cur_billtype_out = -1
- end variables
- forward prototypes
- public subroutine wf_hidecol ()
- public function window getparentwindow ()
- end prototypes
- event ue_retrieve_info();if ddlb_1.text = '分类统计表' then return
- Long ll_row
- Long ll_mtrlid
- ll_row = dw_1.GetRow()
- IF ll_row <= 0 THEN
- ll_mtrlid = 0
- ELSE
- ll_mtrlid = dw_1.Object.u_mtrldef_mtrlid[ll_row]
- END IF
- IF IsValid(w_mtrl_info) THEN
- w_mtrl_info.WindowState = Normal!
- w_mtrl_info.ins_mtrlid = ll_mtrlid
- w_mtrl_info.wf_retrieve(ll_mtrlid)
- END IF
- end event
- event retrieve_pageretr();
- //Int rtr_zeronoallocqty
- //
- //IF cbx_1.Checked THEN
- // rtr_zeronoallocqty = -1
- //ELSE
- // rtr_zeronoallocqty = 0
- //END IF
- dw_1.Retrieve(cur_storageid_arr,ls_handtype,ls_mtrltype,cur_mtrlorigin,publ_operator)
- IF dw_1.RowCount() > 0 AND dw_1.GetRow() = 0 THEN dw_1.SetRow(1)
- //查询最后结存日期
- DateTime ldt_lastbalcdate
- SELECT max( balcdate)
- INTO :ldt_lastbalcdate
- FROM u_warebalc
- WHERE (storageid = :cur_storageid OR :cur_storageid = -1)
- And balcdateint <> 0;
- IF sqlca.SQLCode <> 0 THEN
- SetNull(ldt_lastbalcdate)
- END IF
- IF IsNull(ldt_lastbalcdate) THEN
- st_lastbalcdate.Text = '没有结存记录'
- ELSE
- st_lastbalcdate.Text = '最后结存日期:'+String(ldt_lastbalcdate, 'yyyy-mm-dd')
- END IF
- SetPointer(Arrow!)
- end event
- event ue_mtrl_info();if ddlb_1.text = '分类统计表' then return
- Long ll_row
- ll_row = dw_1.GetRow()
- IF ll_row <= 0 THEN
- MessageBox('提示','请选择物料',information!,OK!)
- RETURN
- END IF
- Long ll_mtrlid
- ll_mtrlid = dw_1.Object.u_mtrldef_mtrlid[ll_row]
- IF IsValid(w_mtrl_info) THEN
- w_mtrl_info.WindowState = Normal!
- w_mtrl_info.ins_mtrlid = ll_mtrlid
- w_mtrl_info.wf_retrieve(ll_mtrlid)
- ELSE
- OpenWithParm(w_mtrl_info,ll_mtrlid)
- END IF
- end event
- event ue_retrieve_inoutmx();//Long ll_row
- //Long ll_storageid,ll_mtrlid, ll_mtrlwareid
- //String ls_status,ls_woodcode,ls_pcode
- //String ls_plancode,ls_mtrlcuscode,ls_location
- //Long ll_sptid
- //DateTime ld_fdate,ld_edate,ld_showsale_data
- //Int li_storagetype
- //
- //ll_row = dw_1.GetRow()
- //
- //
- //tab_1.tabpage_1.dw_inout.setredraw(false)
- //tab_1.tabpage_1.dw_inout.setfilter('')
- //tab_1.tabpage_1.dw_inout.filter()
- //
- //tab_1.tabpage_2.dw_out_noaudit.setredraw(false)
- //tab_1.tabpage_2.dw_out_noaudit.setfilter('')
- //tab_1.tabpage_2.dw_out_noaudit.filter()
- //
- //IF ll_row <= 0 THEN
- // tab_1.tabpage_1.dw_inout.Reset()
- // tab_1.tabpage_2.dw_out_noaudit.Reset()
- //ELSE
- // ld_fdate = DateTime(Date(tab_1.tabpage_1.em_3.Text),Time(0))
- // ld_edate = DateTime(Date(tab_1.tabpage_1.em_4.Text),Time('23:59:59'))
- //
- // IF ld_fdate < sys_showsaledata_mindt THEN
- // ld_showsale_data = sys_showsaledata_mindt
- // ELSE
- // ld_showsale_data = ld_fdate
- // END IF
- //
- // ll_mtrlwareid = dw_1.Object.u_mtrlware_mtrlwareid[ll_row]
- // ll_storageid = dw_1.Object.u_mtrlware_storageid[ll_row]
- // ll_mtrlid = dw_1.Object.u_mtrldef_mtrlid[ll_row]
- // ls_status = dw_1.Object.u_mtrlware_status[ll_row]
- // ls_woodcode = dw_1.Object.u_mtrlware_woodcode[ll_row]
- // ls_pcode = dw_1.Object.u_mtrlware_pcode[ll_row]
- // ls_plancode = dw_1.Object.u_mtrlware_plancode[ll_row]
- // ll_sptid = dw_1.Object.u_mtrlware_sptid[ll_row]
- //
- // tab_1.tabpage_1.dw_inout.Retrieve(ll_storageid,ll_mtrlid,ld_fdate,ld_edate,ls_status,ls_woodcode,ls_pcode,ld_showsale_data,ls_plancode,ll_sptid, cur_billtype_in, cur_billtype_out)
- // tab_1.tabpage_2.dw_out_noaudit.Retrieve(ll_mtrlwareid)
- //END IF
- //tab_1.tabpage_1.dw_inout.setredraw(true)
- //tab_1.tabpage_2.dw_out_noaudit.setredraw(true)
- end event
- event ue_usual_query_filt();//String obj_expr = ''
- //IF ddlb_1.Text = '明细统计表' or ddlb_1.text='汇总统计表' THEN
- //
- // IF Trim(sle_usual_query.Text) <> '' THEN
- // IF Pos(Trim(sle_usual_query.Text),'%') = 0 THEN
- // obj_expr = obj_expr+' ( u_mtrldef_mtrlcode LIKE "%'+Trim(sle_usual_query.Text)+'%") '
- // obj_expr = obj_expr+' or ( u_mtrldef_mtrlname LIKE "%'+Trim(sle_usual_query.Text)+'%") '
- // ELSE
- // obj_expr = obj_expr+' ( u_mtrldef_mtrlcode LIKE "'+Trim(sle_usual_query.Text)+'") '
- // obj_expr = obj_expr+' or ( u_mtrldef_mtrlname LIKE "'+Trim(sle_usual_query.Text)+'") '
- // END IF
- // END IF
- //ELSE
- // IF Trim(sle_usual_query.Text) <> '' THEN
- // IF Pos(Trim(sle_usual_query.Text),'%') = 0 THEN
- // obj_expr = obj_expr+' ( u_mtrltype_mtrltype LIKE "%'+Trim(sle_usual_query.Text)+'%") '
- // ELSE
- // obj_expr = obj_expr+' ( u_mtrltype_mtrltype LIKE "'+Trim(sle_usual_query.Text)+'") '
- // END IF
- // END IF
- //END IF
- //
- //dw_1.SetFilter(obj_expr)
- //
- //dw_1.SetRedraw(FALSE)
- //dw_1.Filter()
- //IF dw_1.RowCount() >= 1 THEN
- // dw_1.SelectRow(0,FALSE)
- // dw_1.SelectRow(1,TRUE)
- //END IF
- //dw_1.SetRedraw(TRUE)
- //
- //
- end event
- event ue_usual_query_retr();//String ls_querystrpart = ''
- //ls_newselect = Lower(ori_oldselect)
- //IF Trim(sle_usual_query.Text) <> '' THEN
- // IF Pos(Trim(sle_usual_query.Text),'%') = 0 THEN
- // ls_querystrpart = ls_querystrpart + "u_mtrldef.mtrlcode like '%"+Trim(sle_usual_query.Text)+"%'"
- // ls_querystrpart = ls_querystrpart + " or u_mtrldef.mtrlname like '%"+Trim(sle_usual_query.Text)+"%')"
- // ELSE
- // ls_querystrpart = ls_querystrpart + " (u_mtrldef.mtrlcode like '"+Trim(sle_usual_query.Text)+"'"
- // ls_querystrpart = ls_querystrpart + " or u_mtrldef.mtrlname like '"+Trim(sle_usual_query.Text)+"')"
- // END IF
- //
- // IF Pos(ls_newselect," where ") <> 0 THEN
- // ls_newselect = ls_newselect+" AND ("+ls_querystrpart+')'
- // ELSE
- // ls_newselect = ls_newselect+" where ("+ls_querystrpart+')'
- // END IF
- //END IF
- //wf_retrieveuc(dw_pageretr,ls_newselect,1)
- //THIS.TriggerEvent('retrieve_pageretr')
- //
- end event
- event ue_cmp_mtrlware();//按库存数重算本期期初
- IF Not f_power_ind(1507) THEN
- MessageBox(publ_operator,'你没有使用权限!')
- RETURN
- END IF
- //IF Not dw_pageretr.DataObject = 'dw_warebalc_view' THEN
- // MessageBox('系统提示','必须在客户产品统计表中才能执行本功能')
- // RETURN
- //END IF
- IF MessageBox (publ_operator,"是否确定要执行按库存数重算结存功能?",Question!,YesNo! ) = 2 THEN RETURN
- IF cur_storageid = -1 THEN
- MessageBox('系统提示','请先选择仓库')
- RETURN
- END IF
- Long li_if_fifo = 0
- SELECT if_fifo
- INTO :li_if_fifo
- FROM u_storage
- Where storageid = :cur_storageid Using sqlca;
- IF sqlca.SQLCode <> 0 THEN
- MessageBox('提示', "查询仓库存货核算方法错误!")
- RETURN
- END IF
- IF li_if_fifo = 1 THEN
- MessageBox('提示', "此功能不适合使用先进先出方法的仓库!")
- RETURN
- END IF
- Long rslt = 1
- String arg_msg
- datastore ds_warebalc
- ds_warebalc = Create datastore
- ds_warebalc.DataObject = 'dw_warebalc_view'
- ds_warebalc.SetTransObject(sqlca)
- ds_warebalc.Retrieve(cur_storageid_arr,'','',-1,publ_operator)
- // //清空筛选内容
- //ds_warebalc.SetFilter('')
- //ds_warebalc.Filter()
- //ds_warebalc.Retrieve(cur_storageid_arr,'','',-1,publ_operator)
- Long ll_i
- Decimal ld_newcost // 最新成本价
- Decimal ld_bgqty,ld_bgamt,ld_incqty,ld_incamt,ld_desqty,ld_desamt
- Decimal ld_balcqty,ld_balcamt
- Long ll_mtrlid
- String ls_status,ls_pcode,ls_woodcode
- String ls_mtrlcode
- Decimal ld_noallocqty,ld_wareamt,ld_noallocaddqty
- Decimal ld_noallocqty_sum,ld_wareamt_sum,ld_noallocaddqty_sum,ld_incaddqty,ld_desaddqty
- Long ll_sptid_cusid,ll_sptid
- Open(w_sys_wait_jdt) //初始化进度条
- w_sys_wait_jdt.Show()
- //结存查库存
- w_sys_wait_jdt.wf_accepttol(ds_warebalc.RowCount())
- FOR ll_i = 1 To ds_warebalc.RowCount()
-
- ll_mtrlid = ds_warebalc.Object.u_mtrldef_mtrlid[ll_i]
- ls_mtrlcode = ds_warebalc.Object.u_mtrldef_mtrlcode[ll_i]
- ls_status = ds_warebalc.Object.u_warebalc_status[ll_i]
- ls_woodcode = ds_warebalc.Object.u_warebalc_woodcode[ll_i]
- ls_pcode = ds_warebalc.Object.u_warebalc_pcode[ll_i]
- ll_sptid_cusid = ds_warebalc.Object.u_warebalc_sptid_cusid[ll_i]
- w_sys_wait_jdt.st_msg.Text = " 正在结存重算:"+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+"..." //进度信息
- w_sys_wait_jdt.wf_inc(ll_i)
-
- SELECT isnull(sum(noallocqty),0),
- isnull(sum(wareamt),0),
- isnull(sum(noallocaddqty),0)
- INTO :ld_noallocqty,
- :ld_wareamt,
- :ld_noallocaddqty
- FROM u_mtrlware
- WHERE mtrlid = :ll_mtrlid
- AND storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- And sptid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- IF sqlca.SQLCode = 100 THEN
- ld_noallocqty = 0
- ld_wareamt = 0
- ELSE
- rslt = 0
- arg_msg = '查询库存资料失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
- END IF
-
- UPDATE u_warebalc
- SET balcqty = :ld_noallocqty,
- balcaddqty = :ld_noallocaddqty,
- balcamt = :ld_wareamt,
- bgqty = :ld_noallocqty + desqty - incqty,
- bgamt = :ld_wareamt + desamt - incamt,
- bgaddqty = :ld_noallocaddqty + desaddqty - incaddqty
- WHERE mtrlid = :ll_mtrlid
- AND balcdateint = 0
- AND Storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- And sptid_cusid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
-
- END IF
-
- ld_noallocqty_sum += ld_noallocqty
- ld_wareamt_sum += ld_wareamt
- ld_noallocaddqty_sum += ld_noallocaddqty
- NEXT
- //库存计结存
- Long cnt,ll_scid
- datastore ds_mtrlware
- ds_mtrlware = Create datastore
- ds_mtrlware.DataObject = 'ds_warebalc_view_cmpl_mtrlware_to_balc'
- ds_mtrlware.SetTransObject(sqlca)
- ds_mtrlware.Retrieve(cur_storageid)
- ds_mtrlware.AcceptText()
- IF ld_noallocqty_sum <> ds_mtrlware.Object.sumqty[1] Or &
- ld_wareamt_sum <> ds_mtrlware.Object.sumamt[1] Or &
- ld_noallocaddqty_sum <> ds_mtrlware.Object.sumaddqty[1] THEN
-
- SELECT scid INTO :ll_scid
- FROM u_storage
- Where storageid = :cur_storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库所属分部失败,操作取消'
- GOTO ext
- END IF
-
- w_sys_wait_jdt.wf_accepttol(ds_mtrlware.RowCount())
-
- FOR ll_i = 1 To ds_mtrlware.RowCount()
- ll_mtrlid = 0
- ls_mtrlcode = ''
- ls_status = ''
- ls_woodcode = ''
- ls_pcode = ''
- ld_noallocqty = 0
- ld_wareamt = 0
- ll_sptid = 0
- cnt = 0
-
- ls_mtrlcode = ds_mtrlware.Object.u_mtrldef_mtrlcode[ll_i]
- ll_mtrlid = ds_mtrlware.Object.mtrlid[ll_i]
-
- ls_status = ds_mtrlware.Object.status[ll_i]
- ls_woodcode = ds_mtrlware.Object.woodcode[ll_i]
- ls_pcode = ds_mtrlware.Object.pcode[ll_i]
- ld_noallocqty = ds_mtrlware.Object.qty[ll_i]
- ld_noallocaddqty = ds_mtrlware.Object.addqty[ll_i]
- ld_wareamt = ds_mtrlware.Object.amt[ll_i]
- ll_sptid = ds_mtrlware.Object.u_mtrlware_sptid[ll_i]
-
- w_sys_wait_jdt.st_msg.Text = " 正在库存重算:"+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+"..." //进度信息
- w_sys_wait_jdt.wf_inc(ll_i)
-
-
- SELECT count(*) INTO :cnt
- FROM u_warebalc
- WHERE mtrlid = :ll_mtrlid
- AND balcdateint = 0
- AND Storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- And sptid_cusid = :ll_sptid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
-
- IF cnt > 0 THEN CONTINUE
-
- SELECT CASE when sum(Round(u_inwaremx.qty * u_inwaremx.cost,2)) Is Null THEN 0 ELSE sum(Round(u_inwaremx.qty * u_inwaremx.cost,2)) END ,
- CASE when sum(u_inwaremx.qty) Is Null THEN 0 ELSE sum(u_inwaremx.qty) END,
- CASE when sum(u_inwaremx.addqty) Is Null THEN 0 ELSE sum(u_inwaremx.addqty) END
- Into :ld_incamt,:ld_incqty,:ld_incaddqty
- From u_inwaremx,u_inware
- Where u_inwaremx.scid = u_inware.scid
- And u_inwaremx.inwareid = u_inware.inwareid
- And u_inware.storageid = :cur_storageid
- And u_inware.balcdateint = 0
- And u_inwaremx.mtrlid = :ll_mtrlid
- And u_inwaremx.status = :ls_status
- And u_inwaremx.woodcode = :ls_woodcode
- And u_inwaremx.pcode = :ls_pcode
- And u_inwaremx.sptid_cusid = :ll_sptid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询进仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
-
- SELECT CASE when sum(u_outwaremx.costamt) Is Null THEN 0 ELSE sum(u_outwaremx.costamt) END ,
- CASE when sum(u_outwaremx.qty) Is Null THEN 0 ELSE sum(u_outwaremx.qty) END ,
- CASE when sum(u_outwaremx.addqty) Is Null THEN 0 ELSE sum(u_outwaremx.addqty) END
- Into :ld_desamt,:ld_desqty,:ld_desaddqty
- From u_outwaremx,u_outware
- Where u_outwaremx.scid = u_outware.scid
- And u_outwaremx.outwareid = u_outware.outwareid
- And u_outware.storageid = :cur_storageid
- And u_outware.balcdateint = 0
- And u_outwaremx.mtrlid = :ll_mtrlid
- And u_outwaremx.status = :ls_status
- And u_outwaremx.woodcode = :ls_woodcode
- And u_outwaremx.pcode = :ls_pcode
- And u_outwaremx.sptid = :ll_sptid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询出仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
-
- INSERT INTO u_warebalc
- (scid,
- balcdateint,
- storageid,
- mtrlid,
- status,
- woodcode,
- pcode,
- bgqty,
- bgamt,
- incqty,
- incamt,
- desqty,
- desamt,
- balcqty,
- balcamt,
- sptid_cusid,
- bgaddqty,
- balcaddqty,
- incaddqty,
- desaddqty
- )
- VALUES
- (:ll_scid,0,
- :cur_storageid,
- :ll_mtrlid,
- :ls_status,
- :ls_woodcode,
- :ls_pcode,
- :ld_noallocqty + :ld_desqty - :ld_incqty,
- :ld_wareamt + :ld_desamt - :ld_incamt,
- :ld_incqty,
- :ld_incamt,
- :ld_desqty,
- :ld_desamt,
- :ld_noallocqty,
- :ld_wareamt,
- :ll_sptid,
- :ld_noallocaddqty + :ld_desaddqty - :ld_incaddqty,
- :ld_noallocaddqty,
- :ld_incqty,
- :ld_desaddqty);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '新加结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
- NEXT
- END IF
- //CLOSE(w_sys_wait_jdt)
- //COMMIT;
- //MessageBox('系统提示','重算成功!')
- //THIS.TriggerEvent('retrieve_pageretr')
- ext:
- Destroy ds_warebalc
- Destroy ds_mtrlware
- Close(w_sys_wait_jdt)
- IF rslt = 0 THEN
- ROLLBACK;
- MessageBox('Error',arg_msg)
- RETURN
- ELSE
- COMMIT;
- MessageBox('系统提示','重算成功!')
- This.TriggerEvent('retrieve_pageretr')
- END IF
- end event
- event ue_cmp_amt2();//按上期结存重算本期结余
- IF Not f_power_ind(1507) THEN
- MessageBox(publ_operator,'你没有使用权限!')
- RETURN
- END IF
- //IF Not dw_pageretr.DataObject = 'dw_warebalc_view' THEN
- // MessageBox('系统提示','必须在客户产品统计表中才能执行本功能')
- // RETURN
- //END IF
- IF cur_storageid = -1 THEN
- MessageBox('系统提示','请先选择仓库')
- RETURN
- END IF
- Long li_if_fifo = 0
- SELECT if_fifo
- INTO :li_if_fifo
- FROM u_storage
- Where storageid = :cur_storageid Using sqlca;
- IF sqlca.SQLCode <> 0 THEN
- MessageBox('提示', "查询仓库存货核算方法错误!")
- RETURN
- END IF
- IF li_if_fifo = 1 THEN
- MessageBox('提示', "此功能不适合使用先进先出方法的仓库!")
- RETURN
- END IF
- Long rslt = 1
- String arg_msg
- Long cnt
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_mtrlware
- WHERE u_mtrlware.storageid = :cur_storageid
- AND ( u_mtrlware.plancode <> '' OR sptid <> 0 )
- AND u_mtrlware.noallocqty <> 0
- And u_mtrlware.mtrlid In (SELECT mtrlid From u_warebalc Where storageid = :cur_storageid And balcdateint = 0);
- IF sqlca.SQLCode <> 0 THEN
- MessageBox('系统提示','查询仓库物料使用了批号库存失败,'+sqlca.SQLErrText)
- RETURN
- END IF
- IF cnt > 0 THEN
- MessageBox('系统提示','仓库物料使用了批号库存,不能重算')
- RETURN
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_outware,u_outwaremx
- WHERE u_outware.storageid = :cur_storageid
- AND u_outware.scid = u_outwaremx.scid
- AND u_outware.outwareid = u_outwaremx.outwareid
- AND u_outware.flag = 1
- AND u_outware.balcdateint = 0
- AND u_outwaremx.plancode <> ''
- And u_outwaremx.mtrlid In (SELECT mtrlid From u_warebalc Where storageid = :cur_storageid And balcdateint = 0);
- IF sqlca.SQLCode <> 0 THEN
- MessageBox('系统提示','查询仓库物料出仓使用了批号库存失败,'+sqlca.SQLErrText)
- RETURN
- END IF
- IF cnt > 0 THEN
- MessageBox('系统提示','仓库物料出仓使用了批号库存,不能重算')
- RETURN
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_inware,u_inwaremx
- WHERE u_inware.storageid = :cur_storageid
- AND u_inware.scid = u_inwaremx.scid
- AND u_inware.inwareid = u_inwaremx.inwareid
- AND u_inware.flag = 1
- AND u_inware.balcdateint = 0
- AND u_inwaremx.plancode <> ''
- And u_inwaremx.mtrlid In (SELECT mtrlid From u_warebalc Where storageid = :cur_storageid And balcdateint = 0);
- IF sqlca.SQLCode <> 0 THEN
- MessageBox('系统提示','查询仓库物料进仓使用了批号库存失败,'+sqlca.SQLErrText)
- RETURN
- END IF
- IF cnt > 0 THEN
- MessageBox('系统提示','仓库物料进仓使用了批号库存,不能重算')
- RETURN
- END IF
- IF MessageBox (publ_operator,"是否确定要执行按上期结存重算本期结余功能?",Question!,YesNo! ) = 2 THEN RETURN
- //IF cur_storageid = -1 THEN
- // MessageBox('系统提示','请先选择仓库')
- // RETURN
- //END IF
- datastore ds_warebalc
- ds_warebalc = Create datastore
- ds_warebalc.DataObject = 'dw_warebalc_view_ds'
- ds_warebalc.SetTransObject(sqlca)
- ds_warebalc.Retrieve(cur_storageid_arr,0)
- // //清空筛选内容
- //ds_warebalc.SetFilter('')
- //ds_warebalc.Filter()
- //ds_warebalc.Retrieve(cur_storageid_arr,'','',cur_mtrlorigin,publ_operator)
- Long ll_lastbalcdateint
- Long ll_i
- Decimal ld_newcost,ld_newcost_out // 最新成本价
- Decimal ld_balcqty_last,ld_balcamt_last,ld_inamt,ld_inqty,ld_outamt,ld_outqty
- Decimal ld_ubalcqty_last,ld_uinqty,ld_uoutqty
- Decimal ld_bgqty,ld_bgamt,ld_incqty,ld_incamt,ld_desqty,ld_desamt
- Decimal ld_balcqty,ld_balcamt
- Long ll_mtrlid
- String ls_status,ls_pcode,ls_woodcode
- String ls_mtrlcode,ls_msg
- Long ll_sptid_cusid
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_warebalc
- Where storageid = :cur_storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询历史结存失败,操作取消'
- GOTO ext
- END IF
- IF cnt > 0 THEN
- SELECT max(balcdateint) INTO :ll_lastbalcdateint
- FROM u_warebalc
- Where storageid = :cur_storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询上次结存失败,操作取消'
- GOTO ext
- END IF
- ELSE
- ll_lastbalcdateint = -1
- END IF
- UPDATE u_mtrlware
- SET noallocqty = 0,wareamt = 0
- Where storageid = : cur_storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '清除库存数量,金额失败,操作取消'
- GOTO ext
- END IF
- Open(w_sys_wait_jdt) //初始化进度条
- w_sys_wait_jdt.Show()
- w_sys_wait_jdt.wf_accepttol(ds_warebalc.RowCount())
- FOR ll_i = 1 To ds_warebalc.RowCount()
-
- ld_bgqty = ds_warebalc.Object.bgqty[ll_i]
- ld_bgamt = ds_warebalc.Object.bgamt[ll_i]
- ld_incqty = ds_warebalc.Object.incqty[ll_i]
- ld_incamt = ds_warebalc.Object.incamt[ll_i]
- ld_desqty = ds_warebalc.Object.desqty[ll_i]
- ld_desamt = ds_warebalc.Object.desamt[ll_i]
- ls_status = ds_warebalc.Object.u_warebalc_status[ll_i]
- ls_woodcode = ds_warebalc.Object.u_warebalc_woodcode[ll_i]
- ls_pcode = ds_warebalc.Object.u_warebalc_pcode[ll_i]
- ls_mtrlcode = ds_warebalc.Object.u_mtrldef_mtrlcode[ll_i]
- ll_mtrlid = ds_warebalc.Object.mtrlid[ll_i]
- ll_sptid_cusid = ds_warebalc.Object.u_warebalc_sptid_cusid[ll_i]
-
- w_sys_wait_jdt.st_msg.Text = " 正在重算:"+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+"..." //进度信息
- w_sys_wait_jdt.wf_inc(ll_i)
-
- IF IsNull(ld_bgqty) THEN ld_bgqty = 0
- IF IsNull(ld_incqty) THEN ld_incqty = 0
- IF IsNull(ld_bgamt) THEN ld_bgamt = 0
- IF IsNull(ld_incamt) THEN ld_incamt = 0
- IF IsNull(ld_desqty) THEN ld_desqty = 0
- IF IsNull(ld_desamt) THEN ld_desamt = 0
-
-
- //查期初
- If ll_lastbalcdateint > 0 THEN
- SELECT balcqty,balcamt
- INTO :ld_balcqty_last,:ld_balcamt_last
- FROM u_warebalc
- WHERE storageid = :cur_storageid
- AND mtrlid = :ll_mtrlid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- AND balcdateint = :ll_lastbalcdateint
- And sptid_cusid = :ll_sptid_cusid;
- IF sqlca.SQLCode = -1 THEN
- rslt = 0
- arg_msg = '查询上月结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- elseif sqlca.sqlcode = 100 then
- ld_balcqty_last = 0
- ld_balcamt_last = 0
- END IF
-
- IF ld_balcqty_last <> ld_bgqty THEN ld_bgqty = ld_balcqty_last
- IF ld_balcamt_last <> ld_bgamt THEN ld_bgamt = ld_balcamt_last
- ELSE
- ld_bgqty = 0
- ld_bgamt = 0
- END IF
-
- //查进仓
- SELECT isnull(sum(u_inwaremx.qty),0),isnull(sum(u_inwaremx.uqty),0),isnull(sum(round(u_inwaremx.cost * u_inwaremx.qty,2)),0)
- INTO :ld_inqty,:ld_uinqty,:ld_inamt
- FROM u_inware,u_inwaremx
- WHERE u_inware.scid = u_inwaremx.scid
- AND u_inware.inwareid = u_inwaremx.inwareid
- AND u_inwaremx.mtrlid = :ll_mtrlid
- AND u_inwaremx.status = :ls_status
- AND u_inwaremx.woodcode = :ls_woodcode
- AND u_inwaremx.pcode = :ls_pcode
- AND u_inware.storageid = :cur_storageid
- AND u_inware.balcdateint = 0
- AND u_inware.flag = 1
- And u_inwaremx.sptid_cusid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询本月进仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ld_incqty <> ld_inqty THEN ld_incqty = ld_inqty
- IF ld_incamt <> ld_inamt THEN ld_incamt = ld_inamt
-
- //查出仓
- SELECT isnull(sum(u_outwaremx.qty),0),
- isnull(sum(u_outwaremx.uqty),0),
- isnull(sum(round(u_outwaremx.costamt,2)),0)
- INTO :ld_outqty,:ld_uoutqty,:ld_outamt
- FROM u_outware,u_outwaremx
- WHERE u_outware.scid = u_outwaremx.scid
- AND u_outware.outwareid = u_outwaremx.outwareid
- AND u_outwaremx.mtrlid = :ll_mtrlid
- AND u_outwaremx.status = :ls_status
- AND u_outwaremx.woodcode = :ls_woodcode
- AND u_outwaremx.pcode = :ls_pcode
- AND u_outware.storageid = :cur_storageid
- AND u_outware.balcdateint = 0
- AND u_outware.flag = 1
- And u_outwaremx.sptid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询本月出仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ld_desqty <> ld_outqty THEN ld_desqty = ld_outqty
- IF ld_desamt <> ld_outamt THEN ld_desamt = ld_outamt
-
- IF IsNull(ld_bgqty) THEN ld_bgqty = 0
- IF IsNull(ld_bgamt) THEN ld_bgamt = 0
- IF IsNull(ld_incqty) THEN ld_incqty = 0
- IF IsNull(ld_incamt) THEN ld_incamt = 0
- IF IsNull(ld_desqty) THEN ld_desqty = 0
- IF IsNull(ld_desamt) THEN ld_desamt = 0
-
-
- //出仓成本价
- IF ld_bgqty + ld_incqty <> 0 THEN
- ld_newcost_out = Round((ld_bgamt + ld_incamt) / (ld_bgqty + ld_incqty),10)
- ELSE
- IF ld_desqty <> 0 THEN
- ld_newcost_out = Round(ld_desamt / ld_desqty, 10)
- ELSE
- ld_newcost_out = 0
- END IF
- END IF
-
- IF ld_newcost_out < 0 THEN ld_newcost_out = 0
-
- //更新期间出金额
- UPDATE u_outwaremx
- SET u_outwaremx.cost = :ld_newcost_out,
- u_outwaremx.costamt = round(u_outwaremx.qty * :ld_newcost_out,2)
- FROM u_outwaremx INNER JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid AND
- u_outwaremx.outwareid = u_outware.outwareid
- WHERE u_outwaremx.mtrlid = :ll_mtrlid
- AND u_outware.storageid = :cur_storageid
- AND u_outwaremx.status = :ls_status
- AND u_outwaremx.woodcode = :ls_woodcode
- AND u_outwaremx.pcode = :ls_pcode
- AND u_outware.balcflag = 0
- And u_outwaremx.sptid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新未结存的出仓单金额失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- //重新查出仓
- SELECT isnull(sum(u_outwaremx.qty),0),
- isnull(sum(u_outwaremx.uqty),0),
- isnull(sum(round(u_outwaremx.costamt,2)),0)
- INTO :ld_outqty,:ld_uoutqty,:ld_outamt
- FROM u_outware,u_outwaremx
- WHERE u_outware.scid = u_outwaremx.scid
- AND u_outware.outwareid = u_outwaremx.outwareid
- AND u_outwaremx.mtrlid = :ll_mtrlid
- AND u_outwaremx.status = :ls_status
- AND u_outwaremx.woodcode = :ls_woodcode
- AND u_outwaremx.pcode = :ls_pcode
- AND u_outware.storageid = :cur_storageid
- AND u_outware.balcdateint = 0
- AND u_outware.flag = 1
- And u_outwaremx.sptid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询本月出仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ld_desqty <> ld_outqty THEN ld_desqty = ld_outqty
- IF ld_desamt <> ld_outamt THEN ld_desamt = ld_outamt
-
- IF IsNull(ld_bgqty) THEN ld_bgqty = 0
- IF IsNull(ld_bgamt) THEN ld_bgamt = 0
- IF IsNull(ld_incqty) THEN ld_incqty = 0
- IF IsNull(ld_incamt) THEN ld_incamt = 0
- IF IsNull(ld_desqty) THEN ld_desqty = 0
- IF IsNull(ld_desamt) THEN ld_desamt = 0
-
-
- //更新期间出金额,结存金额
- UPDATE u_warebalc
- SET bgqty = :ld_bgqty,
- bgamt = :ld_bgamt,
- incqty = :ld_incqty,
- incamt = :ld_incamt,
- desqty = :ld_desqty,
- desamt = :ld_desamt,
- balcqty = :ld_bgqty + :ld_incqty - :ld_desqty,
- balcamt = :ld_bgamt + :ld_incamt - :ld_desamt
- WHERE mtrlid = :ll_mtrlid
- AND balcdateint = 0
- AND Storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- And sptid_cusid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ld_bgqty + ld_incqty - ld_desqty <> 0 THEN
- ld_newcost = Round((ld_bgamt + ld_incamt - ld_desamt) / (ld_bgqty + ld_incqty - ld_desqty),10)
- ELSE
- ld_newcost = 0
- END IF
- IF ld_newcost < 0 THEN ld_newcost = 0
-
- UPDATE u_mtrlware
- SET cost = :ld_newcost,
- noallocqty = :ld_bgqty + :ld_incqty - :ld_desqty ,
- wareamt = :ld_bgamt + :ld_incamt - :ld_desamt
- WHERE mtrlid = :ll_mtrlid
- AND Storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- AND plancode = ''
- And sptid = :ll_sptid_cusid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新库存金额失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+','+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
- ext:
- Destroy ds_warebalc
- Close(w_sys_wait_jdt)
- IF rslt = 0 THEN
- ROLLBACK;
- MessageBox('Error',arg_msg)
- RETURN
- ELSE
- COMMIT;
- MessageBox('系统提示','重算成功!')
- This.TriggerEvent('retrieve_pageretr')
- END IF
- end event
- event ue_cmp();//超级重算
- IF Not f_power_ind(1507) THEN
- MessageBox(publ_operator,'你没有使用权限!')
- RETURN
- END IF
- //IF NOT dw_pageretr.DataObject = 'dw_warebalc_view' THEN
- // MessageBox('系统提示','必须在客户产品统计表中才能执行本功能')
- // RETURN
- //END IF
- IF MessageBox (publ_operator,"是否确定要执行超级重算结存功能?",Question!,YesNo! ) = 2 THEN RETURN
- IF cur_storageid = -1 THEN
- MessageBox('系统提示','请先选择仓库')
- RETURN
- END IF
- //// //清空筛选内容
- //dw_pageretr.SetFilter('')
- //dw_pageretr.Filter()
- //dw_pageretr.Retrieve(cur_storageid_arr,'','',-1,publ_operator)
- Long rslt = 1
- String arg_msg
- Long ll_i
- Decimal ld_newcost // 最新成本价
- Decimal ld_bgqty,ld_bgamt,ld_incqty,ld_incamt,ld_desqty,ld_desamt
- Decimal ld_balcqty,ld_balcamt
- Long ll_mtrlid
- String ls_status,ls_pcode,ls_woodcode
- String ls_mtrlcode
- Decimal ld_noallocqty,ld_wareamt
- Decimal ld_noallocqty_sum,ld_wareamt_sum
- Long ll_sptid
- Open(w_sys_wait_jdt) //初始化进度条
- w_sys_wait_jdt.Show()
- //
- ////结存查库存
- //库存计结存
- Long cnt,ll_scid
- datastore ds_mtrlware
- ds_mtrlware = Create datastore
- ds_mtrlware.DataObject = 'ds_warebalc_view_cmpl_mtrlware_to_balc2'
- ds_mtrlware.SetTransObject(sqlca)
- ds_mtrlware.Retrieve(cur_storageid)
- ds_mtrlware.AcceptText()
- //IF ld_noallocqty_sum <> ds_mtrlware.Object.sumqty[1] OR &
- // ld_wareamt_sum <> ds_mtrlware.Object.sumamt[1] THEN
- SELECT scid INTO :ll_scid
- FROM u_storage
- Where storageid = :cur_storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库所属分部失败'
- GOTO ext
- END IF
- w_sys_wait_jdt.wf_accepttol(ds_mtrlware.RowCount())
- FOR ll_i = 1 To ds_mtrlware.RowCount()
- ll_mtrlid = 0
- ls_mtrlcode = ''
- ls_status = ''
- ls_woodcode = ''
- ls_pcode = ''
- ld_noallocqty = 0
- ld_wareamt = 0
- ll_sptid = 0
- cnt = 0
-
- ls_mtrlcode = ds_mtrlware.Object.u_mtrldef_mtrlcode[ll_i]
- ll_mtrlid = ds_mtrlware.Object.mtrlid[ll_i]
-
- ls_status = ds_mtrlware.Object.status[ll_i]
- ls_woodcode = ds_mtrlware.Object.woodcode[ll_i]
- ls_pcode = ds_mtrlware.Object.pcode[ll_i]
- ld_noallocqty = ds_mtrlware.Object.qty[ll_i]
- ld_wareamt = ds_mtrlware.Object.amt[ll_i]
- ll_sptid = ds_mtrlware.Object.u_mtrlware_sptid[ll_i]
- w_sys_wait_jdt.st_msg.Text = " 正在库存重算:"+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode+"..." //进度信息
- w_sys_wait_jdt.wf_inc(ll_i)
-
-
- SELECT sum(Round(u_inwaremx.qty * u_inwaremx.cost,2)) ,
- sum(u_inwaremx.qty)
- INTO :ld_incamt,:ld_incqty
- FROM u_inwaremx,u_inware
- WHERE u_inwaremx.scid = u_inware.scid
- AND u_inwaremx.inwareid = u_inware.inwareid
- AND u_inware.storageid = :cur_storageid
- AND u_inware.balcdateint = 0
- AND u_inwaremx.mtrlid = :ll_mtrlid
- AND u_inwaremx.status = :ls_status
- AND u_inwaremx.woodcode = :ls_woodcode
- AND u_inwaremx.pcode = :ls_pcode
- AND u_inwaremx.sptid_cusid = :ll_sptid
- And u_inware.flag = 1;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询进仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
-
- SELECT sum(u_outwaremx.costamt) ,
- sum(u_outwaremx.qty)
- INTO :ld_desamt,:ld_desqty
- FROM u_outwaremx,u_outware
- WHERE u_outwaremx.scid = u_outware.scid
- AND u_outwaremx.outwareid = u_outware.outwareid
- AND u_outware.storageid = :cur_storageid
- AND u_outware.balcdateint = 0
- AND u_outwaremx.mtrlid = :ll_mtrlid
- AND u_outwaremx.status = :ls_status
- AND u_outwaremx.woodcode = :ls_woodcode
- AND u_outwaremx.pcode = :ls_pcode
- AND u_outwaremx.sptid = :ll_sptid
- And u_outware.flag = 1;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询出仓失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
-
- IF IsNull(ld_desqty) THEN ld_desqty = 0
- IF IsNull(ld_incqty) THEN ld_incqty = 0
- IF IsNull(ld_desamt) THEN ld_desamt = 0
- IF IsNull(ld_incamt) THEN ld_incamt = 0
- UPDATE u_warebalc
- SET balcqty = :ld_noallocqty,
- balcamt = :ld_wareamt,
- bgqty = :ld_noallocqty + :ld_desqty - :ld_incqty,
- bgamt = :ld_wareamt + :ld_desamt - :ld_incamt,
- incqty = :ld_incqty,
- incamt = :ld_incamt,
- desqty = :ld_desqty,
- desamt = :ld_desamt
- WHERE mtrlid = :ll_mtrlid
- AND balcdateint = 0
- AND Storageid = :cur_storageid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- And sptid_cusid = :ll_sptid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- INSERT INTO u_warebalc
- (scid,
- balcdateint,
- storageid,
- mtrlid,
- status,
- woodcode,
- pcode,
- bgqty,
- bgamt,
- incqty,
- incamt,
- desqty,
- desamt,
- balcqty,
- balcamt,
- sptid_cusid)
- VALUES
- (:sys_scid,0,
- :cur_storageid,
- :ll_mtrlid,
- :ls_status,
- :ls_woodcode,
- :ls_pcode,
- :ld_noallocqty + :ld_desqty - :ld_incqty,
- :ld_wareamt + :ld_desamt - :ld_incamt,
- :ld_incqty,
- :ld_incamt,
- :ld_desqty,
- :ld_desamt,
- :ld_noallocqty,
- :ld_wareamt,
- :ll_sptid);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '新加结存失败,物料:'+ls_mtrlcode+','+sys_option_change_status+':'+ls_status+','+sys_option_change_woodcode+':'+ls_woodcode+','+sys_option_change_pcode+':'+ls_pcode
- GOTO ext
- END IF
- END IF
-
- NEXT
- //END IF
- ext:
- Destroy ds_mtrlware
- Close(w_sys_wait_jdt)
- IF rslt = 0 THEN
- ROLLBACK;
- MessageBox('Error',arg_msg)
- RETURN
- ELSE
- COMMIT;
- MessageBox('系统提示','重算成功!')
- This.TriggerEvent('retrieve_pageretr')
- END IF
- end event
- event ue_update_inware_mtrlwareid();UPDATE u_inwaremx
- SET mtrlwareid = u_mtrlware.mtrlwareid
- FROM u_inware INNER JOIN
- u_inwaremx ON u_inware.scid = u_inwaremx.scid AND
- u_inware.inwareid = u_inwaremx.inwareid INNER JOIN
- u_mtrlware ON u_inwaremx.scid = u_mtrlware.scid AND
- u_inwaremx.mtrlid = u_mtrlware.mtrlid AND
- u_inwaremx.plancode = u_mtrlware.plancode AND
- u_inwaremx.status = u_mtrlware.Status AND
- u_inwaremx.woodcode = u_mtrlware.woodcode AND
- u_inwaremx.pcode = u_mtrlware.pcode AND
- u_inwaremx.sptid_cusid = u_mtrlware.Sptid AND
- u_inware.storageid = u_mtrlware.storageid AND
- u_inware.Dxflag = u_mtrlware.Dxflag
- Where (u_inware.flag = 1) And (u_inwaremx.mtrlwareid = 0);
- IF sqlca.SQLCode <> 0 THEN
- ROLLBACK;
- MessageBox('','失败')
- ELSE
- COMMIT;
- MessageBox('','成功')
- END IF
- end event
- public subroutine wf_hidecol ();s_hide_col s_col
- s_col.col_1 = 'u_mtrldef_bgamt'
- s_col.col_2 = 'u_mtrldef_incamt'
- s_col.col_3 = 'u_mtrldef_desamt'
- s_col.col_4 = 'u_mtrldef_balcamt'
- f_hide_col(123,dw_1,s_col)
- end subroutine
- public function window getparentwindow ();return this
- end function
- on w_warebalc_view.create
- int iCurrent
- call super::create
- this.tv_1=create tv_1
- this.st_2=create st_2
- this.ddlb_storageid=create ddlb_storageid
- this.cb_other=create cb_other
- this.st_1=create st_1
- this.em_month=create em_month
- this.st_lastbalcdate=create st_lastbalcdate
- this.ddlb_1=create ddlb_1
- this.cb_balc=create cb_balc
- iCurrent=UpperBound(this.Control)
- this.Control[iCurrent+1]=this.tv_1
- this.Control[iCurrent+2]=this.st_2
- this.Control[iCurrent+3]=this.ddlb_storageid
- this.Control[iCurrent+4]=this.cb_other
- this.Control[iCurrent+5]=this.st_1
- this.Control[iCurrent+6]=this.em_month
- this.Control[iCurrent+7]=this.st_lastbalcdate
- this.Control[iCurrent+8]=this.ddlb_1
- this.Control[iCurrent+9]=this.cb_balc
- end on
- on w_warebalc_view.destroy
- call super::destroy
- destroy(this.tv_1)
- destroy(this.st_2)
- destroy(this.ddlb_storageid)
- destroy(this.cb_other)
- destroy(this.st_1)
- destroy(this.em_month)
- destroy(this.st_lastbalcdate)
- destroy(this.ddlb_1)
- destroy(this.cb_balc)
- end on
- event resize;call super::resize;//IF cbx_inout.Checked THEN
- // tab_1.Visible = TRUE
- //
- // dw_1.Width = THIS.Width - dw_1.X - 40
- // dw_1.Height = THIS.Height - dw_1.Y - tab_1.Height - 150
- //
- // tv_1.Height = THIS.Height - tv_1.Y - 150
- //
- //
- //
- // tab_1.Width = THIS.Width - tab_1.X - 40
- //
- // tab_1.Y = dw_1.Y + dw_1.Height + 10
- // tab_1.X = dw_1.X
- // tab_1.tabpage_1.dw_inout.Height = tab_1.tabpage_1.Height - tab_1.tabpage_1.dw_inout.Y - 40
- // tab_1.tabpage_1.dw_inout.Width = tab_1.tabpage_1.Width - tab_1.tabpage_1.dw_inout.X - 40
- // tab_1.tabpage_2.dw_out_noaudit.Height = tab_1.tabpage_2.Height - tab_1.tabpage_2.dw_out_noaudit.Y - 40
- // tab_1.tabpage_2.dw_out_noaudit.Width = tab_1.tabpage_2.Width - tab_1.tabpage_2.dw_out_noaudit.X - 40
- //ELSE
- dw_1.Width = THIS.Width - dw_1.X - 40
- dw_1.Height = THIS.Height - dw_1.Y - 150
-
- tv_1.Height = THIS.Height - tv_1.Y - 150
-
- // tab_1.Visible = FALSE
- //
- //END IF
- end event
- event ue_before_open;call super::ue_before_open;//cbx_1.visible = false
- //cbx_inout.visible = false
- ins_if_info = Long(f_ProfileString (sys_empid,This.ClassName(), "ins_if_info",'0'))
- IF ins_if_info = 1 THEN
- This.PostEvent('ue_mtrl_info')
- END IF
- end event
- event ue_before_openretrieve;call super::ue_before_openretrieve;//tab_1.tabpage_1.dw_inout.settransobject(sqlca)
- //tab_1.tabpage_2.dw_out_noaudit.settransobject(sqlca)
- end event
- event close;call super::close;IF IsValid(w_mtrl_info) THEN
- ins_if_info = 1
- ELSE
- ins_if_info = 0
- END IF
- f_SetProfileString (sys_empid,This.ClassName(),"ins_if_info",String(ins_if_info))
- end event
- type cb_func from w_publ_easyq`cb_func within w_warebalc_view
- end type
- type cb_exit from w_publ_easyq`cb_exit within w_warebalc_view
- integer x = 1536
- end type
- type cb_2 from w_publ_easyq`cb_2 within w_warebalc_view
- integer x = 1234
- boolean bringtotop = true
- end type
- type cb_psetup from w_publ_easyq`cb_psetup within w_warebalc_view
- integer x = 978
- boolean bringtotop = true
- end type
- type cb_1 from w_publ_easyq`cb_1 within w_warebalc_view
- boolean bringtotop = true
- end type
- event cb_1::clicked;parent.triggerevent("retrieve_pageretr")
- end event
- type st_3 from w_publ_easyq`st_3 within w_warebalc_view
- boolean visible = false
- integer x = 690
- integer y = 204
- end type
- type st_4 from w_publ_easyq`st_4 within w_warebalc_view
- boolean visible = false
- integer x = 1381
- integer y = 204
- end type
- type em_1 from w_publ_easyq`em_1 within w_warebalc_view
- boolean visible = false
- integer x = 882
- integer y = 188
- integer taborder = 120
- end type
- type em_2 from w_publ_easyq`em_2 within w_warebalc_view
- boolean visible = false
- integer x = 1486
- integer y = 188
- integer taborder = 130
- end type
- type ddlb_yl from w_publ_easyq`ddlb_yl within w_warebalc_view
- integer x = 2071
- integer y = 8
- end type
- type cbx_yl from w_publ_easyq`cbx_yl within w_warebalc_view
- integer x = 1861
- integer y = 12
- end type
- type dw_1 from w_publ_easyq`dw_1 within w_warebalc_view
- integer x = 805
- integer y = 300
- integer width = 2400
- integer height = 988
- string dataobject = "dw_warebalc_view_sum"
- end type
- event dw_1::doubleclicked;call super::doubleclicked;IF dwo.Name = 'u_mtrlware_waredscrp' THEN
- Parent.TriggerEvent('ue_waredscrp_view')
- END IF
- end event
- event dw_1::rowfocuschanged;call super::rowfocuschanged;Parent.TriggerEvent('ue_retrieve_info')
- //IF cbx_inout.Checked THEN
- // Parent.TriggerEvent('ue_retrieve_inoutmx')
- //END IF
- end event
- type sle_mtrl from w_publ_easyq`sle_mtrl within w_warebalc_view
- end type
- type sle_cust from w_publ_easyq`sle_cust within w_warebalc_view
- end type
- type st_mtrl from w_publ_easyq`st_mtrl within w_warebalc_view
- end type
- type st_cust from w_publ_easyq`st_cust within w_warebalc_view
- end type
- type cbx_loginretr from w_publ_easyq`cbx_loginretr within w_warebalc_view
- boolean visible = true
- integer x = 1861
- integer y = 100
- end type
- type pb_em1 from w_publ_easyq`pb_em1 within w_warebalc_view
- boolean visible = false
- integer x = 1298
- integer y = 188
- end type
- type pb_em2 from w_publ_easyq`pb_em2 within w_warebalc_view
- boolean visible = false
- integer x = 1897
- integer y = 188
- end type
- type pb_2 from w_publ_easyq`pb_2 within w_warebalc_view
- boolean visible = false
- integer x = 2007
- integer y = 188
- end type
- type cb_help from w_publ_easyq`cb_help within w_warebalc_view
- integer x = 1385
- end type
- type cb_copyself from w_publ_easyq`cb_copyself within w_warebalc_view
- integer x = 722
- end type
- type gb_1 from w_publ_easyq`gb_1 within w_warebalc_view
- end type
- type ln_bar from w_publ_easyq`ln_bar within w_warebalc_view
- end type
- type ln_bar2 from w_publ_easyq`ln_bar2 within w_warebalc_view
- end type
- type r_bar from w_publ_easyq`r_bar within w_warebalc_view
- integer x = 2272
- end type
- type ln_1 from w_publ_easyq`ln_1 within w_warebalc_view
- end type
- type ln_2 from w_publ_easyq`ln_2 within w_warebalc_view
- end type
- type ln_3 from w_publ_easyq`ln_3 within w_warebalc_view
- boolean visible = false
- end type
- type ln_4 from w_publ_easyq`ln_4 within w_warebalc_view
- boolean visible = false
- end type
- type tv_1 from uo_tv_mtrltype within w_warebalc_view
- integer y = 300
- integer width = 800
- integer height = 1808
- integer taborder = 130
- boolean bringtotop = true
- integer textsize = -9
- fontcharset fontcharset = gb2312charset!
- fontfamily fontfamily = anyfont!
- string facename = "宋体"
- end type
- event selectionchanged;call super::selectionchanged;ls_handtype = THIS.uo_cur_info.handtype
- ls_mtrltype = THIS.uo_cur_info.mtrltype
- IF ls_handtype <> '' THEN
- ls_mtrltype = '%'+ls_handtype+'%'
- ls_handtype = ls_handtype+'%'
- ELSE
- ls_mtrltype = ""
- END IF
- PARENT.TriggerEvent('retrieve_pageretr')
- end event
- type st_2 from statictext within w_warebalc_view
- integer x = 5
- integer y = 204
- integer width = 192
- 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 = "仓库:"
- alignment alignment = right!
- boolean focusrectangle = false
- end type
- type ddlb_storageid from uo_ddlb_storageid within w_warebalc_view
- integer x = 206
- integer y = 188
- integer width = 1088
- integer height = 1232
- integer taborder = 130
- boolean bringtotop = true
- end type
- event constructor;call super::constructor;cur_storageid = this.uo_storageid
- cur_storageid_arr = this.uo_storageid_arr
- end event
- event selectionchanged;call super::selectionchanged;cur_storageid = this.uo_storageid
- cur_storageid_arr = this.uo_storageid_arr
- cb_1.triggerevent(clicked!)
- end event
- type cb_other from uo_imflatbutton within w_warebalc_view
- integer x = 466
- integer width = 256
- integer height = 164
- integer taborder = 30
- boolean bringtotop = true
- string text = "辅助功能"
- string normalpicname = "other.BMP"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;m_Dfc_Control_PopupMenu dmPopupMenu
- String menustr
- menustr = "Text=按上期结存数量金额重算本期结存表~tEvent=ue_cmp_amt2"
- menustr = menustr + "|" + "Text=按现库存表数量金额倒推重算本期本期结存表~tEvent=ue_cmp_mtrlware"
- menustr = menustr + "|" + "Text=超级重算~tEvent=ue_cmp"
- menustr = menustr + "|" + "Text=-"
- menustr = menustr + "|" + "Text=更新进仓单明细库存ID~tEvent=ue_update_inware_mtrlwareid"
- menustr = menustr + "|" + "Text=物料相关查询~tEvent=ue_mtrl_info"
- IF Len(Trim(menustr)) <> 0 THEN
- dmPopupMenu = CREATE m_Dfc_Control_PopupMenu
- dmPopupMenu.mf_BuildMenu(THIS, menustr)
- dmPopupMenu.mf_PopMenu()
- DESTROY dmPopupMenu
- END IF
- end event
- type st_1 from statictext within w_warebalc_view
- integer x = 1381
- integer y = 204
- integer width = 242
- 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 = "结存日期"
- alignment alignment = right!
- boolean focusrectangle = false
- end type
- type em_month from editmask within w_warebalc_view
- integer x = 1632
- integer y = 188
- integer width = 434
- integer height = 88
- integer taborder = 130
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- string text = "none"
- alignment alignment = center!
- borderstyle borderstyle = stylelowered!
- maskdatatype maskdatatype = datemask!
- string mask = "yyyy-mm-dd"
- boolean spin = true
- end type
- event constructor;this.text = string(today(),'yyyy-mm-dd')
- end event
- event rbuttondown;s_calender_arg s_calender
- s_calender.PointerX = THIS.PointerX()
- s_calender.PointerY = THIS.PointerY()
- s_calender.X = THIS.X
- s_calender.Y = THIS.Y
- OpenWithParm(w_calendar,s_calender)
- THIS.Text = String(id_date_selected)
- end event
- type st_lastbalcdate from statictext within w_warebalc_view
- integer x = 2158
- integer y = 204
- integer width = 823
- 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 = "最后结存日期"
- boolean focusrectangle = false
- end type
- type ddlb_1 from dropdownlistbox within w_warebalc_view
- integer x = 2427
- integer y = 32
- integer width = 745
- integer height = 1100
- integer taborder = 100
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- string text = "汇总统计表"
- boolean sorted = false
- boolean vscrollbar = true
- string item[] = {"汇总统计表","产品明细统计表","客户产品统计表","分类统计表","汇总统计表(设定售价)"}
- borderstyle borderstyle = stylelowered!
- end type
- event selectionchanged;dw_1.SetRedraw(False)
- dw_1.uf_save_profile_layout()
- IF this.Text = '客户产品统计表' THEN
- dw_1.DataObject = 'dw_warebalc_view'
- ELSEIF this.Text = '产品明细统计表' THEN
- dw_1.DataObject = 'dw_warebalc_view_sum_1'
- ELSEIF this.Text = '汇总统计表' THEN
- dw_1.DataObject = 'dw_warebalc_view_sum'
- ELSEIF this.Text = '分类统计表' THEN
- dw_1.DataObject = 'dw_warebalc_view_2'
- ELSEIF this.Text = '汇总统计表(设定售价)' THEN
- dw_1.DataObject = 'dw_warebalc_view_sum_saleprice'
- END IF
- dw_1.SetTransObject(sqlca)
- dw_1.ins_INIfile_name = sys_inifilename
- dw_1.ins_opemp = publ_operator
- dw_1.cardw_empid = sys_empid
- dw_1.cur_DataObject = dw_1.DataObject
- dw_1.uf_read_profile_layout()
- wf_hidecol()
- f_title_change(dw_1)
- dw_1.SetRedraw(True)
- cb_1.TriggerEvent(Clicked!)
- end event
- type cb_balc from uo_imflatbutton within w_warebalc_view
- integer x = 302
- integer width = 165
- integer height = 164
- integer taborder = 30
- boolean bringtotop = true
- string text = "结存"
- string normalpicname = "update2.BMP"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;IF NOT f_power_ind(75) THEN
- MessageBox('提示','你没有使用权限!',information!,ok!)
- RETURN
- END IF
- IF cur_storageid = -1 THEN
- MessageBox("提示","请选择仓库结存",information!,ok!)
- RETURN
- END IF
- balcdate = DateTime(Date(em_month.Text),Time('23:59:59'))
- IF MessageBox ('询问',"是否确定要把当前日仓库进行结存操作吗?"+'~n'+&
- '结存时间: '+String(balcdate,'YYYY-MM-DD HH:MM:SS')+',结存过程中不能进行其它操作!',Question!,YesNo! ) = 2 THEN RETURN
- w_sys_wait.Show()
- String arg_msg = '',err_msg = ''
- uf_warebalc(1,0,cur_storageid,balcdate,arg_msg)
- w_sys_wait.Hide()
- MessageBox('提示',arg_msg,information!,ok!)
- cb_1.TriggerEvent(Clicked!)
- end event
|