📄 counter.prg
字号:
func counter
para root_id && 所要求的根,所谓总分类
create table counter (type_ID N(8),parent_id n(8),count_yj n(10,2),count_ljzj n(10,2),count_jz n(10,2))
a=1
sele counter
*brow title"创建数据存放文件"
*appe blank
*repl type_id with root_id
sele type_id,parent_id from type where parent_id=root_id into cursor temp
max2=_tally
sele temp
go top
do while !eof()
sele counter
appe blank
repl type_id with temp.type_id
repl parent_id with temp.parent_id
sele temp
skip
enddo
MAX=max2
sele counter
*brow title"第一次求得根下类型"
do while .t.
*activate screen
*clea
*?"do while ...enddo"
FOR N=a TO MAX
*?"for...endfor"
*?"a=",a
*?"n=",n
*?"max=",max
*wait
sele counter
go n
sub_counter(counter.type_id)
ENDFOR
a=max+1
max=recc('counter')
if a>=max+1
exit
endif
enddo
sele counter
pz=0
go top
do while !eof()
*activa screen
*clea
*?"counttype_id=",counter.type_id
*inkey(1)
nYj=0
nLjzj=0
nJz=0
sele * from property where type_id=counter.type_id into cursor temp_property
sele temp_property
* brow title"当前类别下所有的品名"
go top
do while !eof()
sele old_sum,sum_deprecition,left_value from detail where id=temp_property.id order by left_value into cursor temp_detail
sele temp_detail
* brow title"该品名下的明晰"
nYj=nYj+old_sum
nLjzj=nLjzj+sum_deprecition
nJz=nJz+left_value
pz=pz+1
sele temp_property
skip
enddo
sele counter
repl count_yj with nYj
repl count_ljzj with nLjzj
repl count_jz with nJz
* brow title"此时的统计"
skip
enddo
n0Yj=0
n0Ljzj=0
n0Jz=0
max1=0
sele counter
sele * from property where type_id=root_id into cursor temp_property
sele temp_property
* brow title"当前类别下所有的品名"
go top
do while !eof()
sele old_sum,sum_deprecition,left_value from detail where id=temp_property.id order by left_value into cursor temp_detail
sele temp_detail
* brow title"该品名下的明晰"
n0Yj=n0Yj+old_sum
n0Ljzj=n0Ljzj+sum_deprecition
n0Jz=n0Jz+left_value
max1=max1+1
sele temp_property
skip
enddo
sele counter
count to nGs
sum count_yj to nYj
sum count_ljzj to nLj
sum count_jz to nJz
if nyj=nlj+njz
wait window "正确!" nowait
else
wait window "不正确!" nowait
endif
messagebox("该类别下有 "+allt(str(ngs))+" 个子类别,"+allt(str(max1))+" 个直接下属品名,共 "+allt(str(pz+max1))+" 个品种"+chr(13)+"统计如下:"+chr(13)+;
"---------------------------------------"+chr(13)+;
"原价:"+allt(str(nYj+n0yj,12,2))+" 元"+chr(13)+;
"折旧:"+allt(str(nLj+n0ljzj,12,2))+" 元"+chr(13)+;
"净值:"+allt(str(nJz+n0jz,12,2))+" 元",64,"统计数据")
use
******************************* 函数 ***********************************************************************
func sub_counter
para sub_type_id
sele type_id,parent_id from type where parent_id=sub_type_id into cursor temp
if _tally>0
sele temp
go top
do while !eof()
sele counter
appe blank
repl type_id with temp.type_id
repl parent_id with temp.parent_id
sele temp
skip
enddo
endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -