求教一个VFP的编程问题
版主:您好,俺又有一个VFP的编程问题求教,请赐教,谢谢。b01 是一张饭店入住登记的表格,有客人名字、性别、国籍、身份证号码、入住日期、离店日期等资料,那么,通过编程形成了b201008表,统计出8月份每天的在住和已订房间的住客数量(表中的“1”表示占用房间)。俺编写了以下的程序,可以在VFP6.0环境运行,b02是过渡表,为了方便了解,把b01表编程自动形成的,其实现实中b01表的全部资料都是动态的,是通过人工输入的。俺编的这个程序只能解决单月发生的问题,也就是说入住和离店都是在同一个月发生的。
现在俺求教的问题是:入住日期和离店日期是跨月份怎样处理,譬如,某客人2010-08-17入住,2010-10-06离店,那么08-17至08-31的放进b201008表,09-01至09-31的放进b201009表,10-01至10-05的放进b201010表,类推。还有最后怎样对每个表ms1至ms31的每个字段进行批量求和?谢谢。
close all
clear
set safe off
Create Table b01 (ss n(4),xm c(10),sex c (4),nation c (10),address c (15),idno c(15),rz d(8),ld d(8))
Create Table b02 (ss n(4),xm c(10),rz d(8),ld d(8))
FOR i=1 TO 31
cComstr="ALTER TABLE b02 ADD COLUMN ms"+CHRTRAN(STR(i,2),' ','0')+" n(1)"
&cComstr
ENDFOR
Create Table b201008 (ss n(4),xm c(10),roomno c (4),rz d(8),ld d(8))
FOR i=1 TO 31
cComstr="ALTER TABLE b201008 ADD COLUMN ms"+CHRTRAN(STR(i,2),' ','0')+" n(1)"
&cComstr
ENDFOR
close all
clear
use b03
dele all
pack
use b02
dele all
pack
use b01
dele all
pack
close all
use b01
Insert Into b01 (xm,rz,ld) Values ("李明",{^2010/8/1},{^2010/8/8})
Insert Into b01 (xm,rz,ld) Values ("张三",{^2010/8/8},{^2010/8/15})
Insert Into b01 (xm,rz,ld) Values ("thomas",{^2010/8/16},{^2010/8/22})
Insert Into b01 (xm,rz,ld) Values ("mimi",{^2010/8/19},{^2010/8/30})
repl ss with recno() all
brow
close all
clear
use b01
FOR K=1TO 30
use b02
dele all
pack
append from b01 for ss=K
use b02
FOR i=day(rz)to (day(ld)-1)
repl ms01 with 1 for i=1
repl ms02 with 1 for i=2
repl ms03 with 1 for i=3
repl ms04 with 1 for i=4
repl ms05 with 1 for i=5
repl ms06 with 1 for i=6
repl ms07 with 1 for i=7
repl ms08 with 1 for i=8
repl ms09 with 1 for i=9
repl ms10 with 1 for i=10
repl ms11 with 1 for i=11
repl ms12 with 1 for i=12
repl ms13 with 1 for i=13
repl ms14 with 1 for i=14
repl ms15 with 1 for i=15
repl ms16 with 1 for i=16
repl ms17 with 1 for i=17
repl ms18 with 1 for i=18
repl ms19 with 1 for i=19
repl ms20 with 1 for i=20
repl ms21 with 1 for i=21
repl ms22 with 1 for i=22
repl ms23 with 1 for i=23
repl ms24 with 1 for i=24
repl ms25 with 1 for i=25
repl ms26 with 1 for i=26
repl ms27 with 1 for i=27
repl ms28 with 1 for i=28
repl ms29 with 1 for i=29
repl ms30 with 1 for i=30
repl ms31 with 1 for i=31
endfor
use b201008
append from b02
endfor
use b201008
append blank
repl xm with "合计" && 对本月每一天进行合计,就知道每一天的住房数量了。
brow