你不看回帖吗?上一个帖子中早就给你代码了呀、
[quote]
以下是引用xuminxz在2019-4-18 21:54:32的发言:
2010年前写过一些考务管理的代码,其中计算机等级考试考务管理与你的类似。那是一个大系统中的一部分,给你没有用。相关其中部分改了下,看看能不能用。因为没有数据,没法调试。自已看看吧。
** ksxxb 考生信息表
** kmdm 科目代码
** xh 学号
*!*
zkzh 准考证号
*!*
bj 班级(可以用班号代替)
*!*
kch 考场号 整数
*!*
zwh 座位号 整数(1-30)
**
SELECT distinct kmdm,COUNT(*) as kmrs FROM ksxxb INTO CURSOR kmtj
ORDER BY kmdm asc
&& 如果BM大的在前用 desc 代替 ASC
FOR
i=1 TO RECCOUNT('kmtj')
SELECT kmtj
GO i
ckmdm=ALLTRIM(kmdm)
nkcs= INT(kmrs,30)
nfb=MOD(kmrs,30) &&非标考场人数
SELECT bj,COUNT(*) as bjrs FROM ksxxb GROUP by bj ORDER BY bjrs DESC INTO CURSOR bjtmp
FOR ibjs=1 TO RECCOUNT('bjtmp')
SELECT bjtmp
GO ibjs
cbj=ALLTRIM(bj)
cbjrs=PADL(ALLTRIM(STR(bjrs)),3,'0')
SELECT ksxxb
REPLACE zkzh WITH
cbjrs FOR ALLTRIM(bj)==cbj AND kmdm=ckmdm
ENDFOR
SELECT zkzh,xh,kch,zwh FROM ksxxb INTO CURSOR zkztmp WHERE kmdm=ckmdm ORDER BY zkzh desc,bj READWRITE
SELECT zkztmp
GO 1
FOR j=1 TO nfb
FOR k=1 TO nkcs+1
REPLACE kch WITH
k,zwh WITH j
skip
ENDFOR
ENDFOR
FOR j=nfb+1 TO 30
FOR k=1 TO nkcs
REPLACE kch WITH
k,zwh WITH j
skip
ENDFOR
ENDFOR
SELECT zkztmp
REPLACE zkzh WITH ckmdm +PADL(ALLTRIM(STR(kch)),3,'0')+PADL(ALLTRIM(STR(zwh)),2,'0') all
&&生成准考证
*民族代码+3位考场+加两位座号,如需要可在前面加年月等。
irecc=RECCOUNT()
FOR j=1 TO irecc
SELECT zkztmp
GO j
cxh=ALLTRIM(xh)
czkzh=zkzh
ikch=kch
izwh=zwh
SELECT ksxxb
LOCATE FOR ALLTRIM(xh)==cxh
IF FOUND()
REPLACE zkzh WITH czkzh,kch WITH ikch,zwh WITH izwh
ELSE
=MESSAGEBOX('程序出错!')
ENDIF