Java学生选课系统实验报告 下载本文

Field klh mm qx

Type Char(12) Char(10) Char(50)

Null Key Comment 口令号 密码 权限

—— PRI YES —— YES ——

根据系统需求,应该基于用户表定义一个视图,其定义用SQL语句描述如下: CREATE VIEW dbo.VIEW1 AS

SELECT TOP 100 PERCENT dbo.XSXX.xh AS 学号, dbo.XSXX.xm AS 姓名, dbo.KCB.kxh AS 课弃号, dbo.KCB.sksjt, dbo.KCB.sksjj, 单位

dbo.KCB.skdd, dbo.BJXX.bjmc, dbo.KCXX.kcmc, dbo.CJB.cj, dbo.KCXX.kcbh,

dbo.BJXX.bjbh FROM dbo.XSXX INNER JOIN

dbo.XKB ON dbo.XSXX.xh = dbo.XKB.xh INNER JOIN dbo.KCB ON dbo.XKB.kxh = dbo.KCB.kxh INNER JOIN dbo.BJXX ON dbo.XSXX.bjbh = dbo.BJXX.bjbh INNER JOIN dbo.CJB ON dbo.XSXX.xh = dbo.CJB.xh AND dbo.XSXX.xh =

dbo.CJB.xh INNER JOIN dbo.KCXX ON dbo.CJB.kcbh = dbo.KCXX.kcbh AND dbo.CJB.kcbh = dbo.KCXX.kcbh

ORDER BY dbo.XSXX.xh DESC, dbo.KCXX.kcbh DESC, dbo.BJXX.bjbh DESC 根据系统需求,可以定义两个存储过程,其定义语句用SQL语句描述如下: 成绩提交存储过程:

CREATE proc sf_CJTJ @courseid int as

21

begin tran

update CJB set sfyqdcj='Y'where kcbh=@courseid and cj>0 commit GO

终止选课存储过程: CREATE proc sf_ZZXK as begin tran

insert into CJB(xh,kcbh,cj,kscs,sfbx,sfck,sfyqdcj)

select distinct a.xh ,b.kcbh,0,1,'N','N','N'from XKB as a,KCB as b where a.kxh=b.kxh and rtrim(a.xh)+rtrim(b.kcbh) not in (

select rtrim(a.xh)+rtrim(b.kcbh)from CJB ) commit GO

4详细设计及功能实现

4.1用户登录模块设计与实现

设计思路:为了检验登录用户是否是一个合法用户,当用户输入用户名和密码后,需要查询数据库以便验证该用户是否为非法用户。同时通过用户输入的口令号就可知道用户是学生,还是教师,学生和教师的权限不同。

22

实现功能:用户可以从登陆界面进入到教务管理系统界面,然后进行一些操作。

图4.1为系统运行时的截图:

该模块的核心代码如下:

图4.1 用户登录模块的系统截图

判断用户是否合法和用户权限。

procedure Tmain.Button1Click(Sender: TObject); begin

if(edit1.Text='')or(edit2.Text='')then

showmessage('用户名密码不能为空!') else begin

DM_Login.ADOQuery1.Close; DM_Login.ADOQuery1.SQL.Clear; DM_Login.ADOQuery1.SQL.Add('select klh='''+edit1.Text+'''and mm='''+edit2.Text+''''); DM_Login.ADOQuery1.Open;

User_Number:=DM_Login.ADOQuery1.FieldByName('klh').AsString; User_Password:=DM_Login.ADOQuery1.FieldByName('mm').AsString; User_Rright:=DM_Login.ADOQuery1.FieldByName('qx').AsString; if(DM_Login.ADOQuery1.RecordCount=0)then begin

23

* from DLB where

showmessage('用户名或密码错误,请重新输入!'); edit1.Text:=''; edit2.Text:=''; end else begin

Main.Caption:='教务管理系统'; Main.Width:=820; Main.Height:=660; label1.Visible:=false; label2.Visible:=false; button1.Visible:=false; button2.Visible:=false; edit1.Visible:=false; edit2.Visible:=false;

if(trim(User_Rright)='学生')then Main.N8.Visible:=false;

end; end; end;

图4.2 班级信息维护模块的系统截图

24