基于JAVA和MYSQL数据库的CS架构学生成绩管理系统的设计与实现.doc_第1页
基于JAVA和MYSQL数据库的CS架构学生成绩管理系统的设计与实现.doc_第2页
基于JAVA和MYSQL数据库的CS架构学生成绩管理系统的设计与实现.doc_第3页
基于JAVA和MYSQL数据库的CS架构学生成绩管理系统的设计与实现.doc_第4页
基于JAVA和MYSQL数据库的CS架构学生成绩管理系统的设计与实现.doc_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

上海理工大学计算机学院可视化程序设计报告(2010 2011 年度第2学期)2011 年 03月 09日 目 录一、课程设计的目的与要求2二、 设计的正文 21.系统分析21.1系统开发背景等 21.2业务流程分析 21.3数据流程图 32.系统设计 3 2.1功能设计 3 2.2系统运行环境与数据库设计 4 2.3输入/输出设计43.系统实施4 3.1登录与退出界面 4 3.2 修改密码10 3.3成绩查询153.4 相关数据库表24三、课程设计总结25四、参考文献26 学生成绩查询系统一、课程设计的目的与要求通过面向对象程序设计课程设计,进一步掌握面向对象程序设计的理论和方法。培养和锻炼开发小型学生成绩查询系统的能力。为今后相关系统开发打下良好的基础。要求了学生成绩查询系统开发的全过程,理解面向对象程序设计课程相关的概念,掌握面向对象程序设计的开发方法,巩固对java相关方法和概论的理解。主要包括:系统调研方法;业务分析、数据分析、系统逻辑模型设计方法;数据库设计、功能设计、物理模型设计方法;系统的实现等方法。完成一个小型系统的设计与开发。二、设计正文1 系统分析1.1系统开发背景、开发范围、建设目标与必要性随着国家对于教育的重视逐渐加大,学校正向着大型化、规模化发展,而对于大中型学校,跟学生信息管理有关的信息随之急剧增加。在这种情况下单靠人工来处理员工的工资不但显得力不从心,而且极容易出错。该系统就是设计一个学生信息数据库管理系统,由计算机代替人工执行一系列诸如增加新学生,删除旧学生,学生信息修改,查询,维护及打印等操作。这样就使学生部门管理人员可以轻松快捷地完成学生信息管理的任务。1本课题的研究意义当今时代是飞速发展的信息时代。在各行各业中离不开信息处理,这正是计算机被广泛应用于信息管理系统的环境。计算机的最大好处在于利用它能够进行信息管理。使用计算机进行信息控制,不仅提高了工作效率,而且大大的提高了其安全性。尤其对于复杂的信息管理,计算机能够充分发挥它的优越性。2本课题的研究现状管理查询信息系统是进行信息的采集、存储、查询、加工、维护和使用的系统。它是随着管理科学和技术科学的发展而形成的。学生成绩管理查询系统是一个教育单位不可缺少的部分,它的内容对于学校的决策者和管理者和学生来说都至关重要,所以学生成绩管理查询系统应该能够为用户提供充足的信息和快捷的查询手段,但一直以来人们使用传统人工的方式管理文件档案,这种管理方式存在着许多缺点,如:效率低、保密性差;另外时间一长,将产生大量的文件和数据,这对于查找、更新和维护都带来了不少的困难。1.2业务流程分析主要业务流程图,如下图所示 1.3数据流程图 2 系统设计2.1功能设计学生信息管理系统主要提供方便高效的查询功能,学生可以通过该系统查询相关信息。对于本系统,我们需要实现以下一些基本功能:1)密码管理功能该模块实现对用户密码进行管理的功能,主要是进行密码的修改。为了防止个人的名片信息被泄露,不知道用户密码的人员不能进入本系统。出于安全的考虑,用户可以定期修改自己的密码,以防止密码被盗用。2)成绩管理功能该模块实现成绩查询功能。用户在查询学生成绩时,有时需要了解学生的基本信息,因此希望在查询出的内容中包括学生基本情况和成绩信息。有时用户需要查询学生的某些课程成绩,因此应该具有查询课程成绩的功能。有时需要查询学生的学期总成绩,因此也应该具有该功能。3)退出系统完成了对学生成绩的查询的操作后,应该可以安全地离开该系统。通过该模块实现安全退出大学生成绩查询系统。2.2系统运行环境与数据库设计鉴于本系统的业务性质,必须选择具有较高的可靠性、稳定性和必要的容错能力的计算机硬件和软件系统,以保证任何情况下都不至于丢失、损坏数据;必须具有较高的响应速度,以保证各项具体业务的顺利进行;应考虑具有良好的可维护性,可操作性和可扩充性,以保证将来系统规模的扩展和升级的需要。开发与运行环境的使用开发前台工具:java开发后台工具:mysql本系统采用microsoft windows 2000server作为操作系统。本系统准备采用客户机/服务器(c/s)结构模式。2.3输入/输出设计格式说明:学生成绩输入界面格式为对话框格式,可是选项为:学生学号、姓名、班级、各科目成绩。输出单个学生成绩也是对话框形式,全部学生成绩输出为表格形式。安全性设计:设置了用户名和密码验证方式,防止用户非法登录。3 系统实施3.1登录与退出界面登录界面:退出界面关键代码如下,public class login extends jframe implements actionlistener, focuslistener,keylistener, itemlistener /* * */private static final long serialversionuid = 1l;jlabel top, bott;jpanel panelmain, panelinfo;jtextfield username;jpasswordfield password;jbutton login, cancel;string culestring = 提 示 : ;public login() super(重庆大学城市科技学院2008级电子商务-学生成绩管理系统);top = new jlabel(new imageicon(picture/login_top.gif);bott = new jlabel();panelmain = new jpanel(new borderlayout(10, 10);bott.setborder(new lineborder(new color(184, 173, 151);buildcenter();panelmain.add(north, top);panelmain.add(south, bott);panelmain.add(panelinfo);/ 加监听事件login.addactionlistener(this);cancel.addactionlistener(this);login.addfocuslistener(this);cancel.addfocuslistener(this);login.addkeylistener(this);cancel.addkeylistener(this);username.addfocuslistener(this);username.addkeylistener(this);password.addfocuslistener(this);password.addkeylistener(this);/ 加窗口监听,new windowadapter适配器this.addwindowlistener(new windowadapter() public void windowclosing(windowevent we) quit();/ end windowclosing);this.setcontentpane(panelmain); / 设置窗口面板this.setlocation(400, 335);this.setsize(350, 250);this.setresizable(false); / 设置窗口大小不可变this.setdefaultcloseoperation(jframe.do_nothing_on_close);/ /*/this.setvisible(true);password.requestfocus(true); / 设置焦点给密码框private void buildcenter() / todo auto-generated method stubjlabel lb1, lb2;lb1 = new jlabel(用户名:);lb2 = new jlabel(密 码:);username = new jtextfield(15);password = new jpasswordfield(15);login = new tjbutton(picture/key.gif, 登 录, 登录系统);cancel = new tjbutton(picture/exit.gif, 退 出, 关闭系统);/ */ 定义面板为无布局panelinfo = new jpanel(null);/ 加入组建panelinfo.add(lb1);panelinfo.add(lb2);panelinfo.add(username);panelinfo.add(password);panelinfo.add(login);panelinfo.add(cancel);lb1.setbounds(70, 14, 60, 25);lb2.setbounds(70, 48, 60, 25);username.setbounds(150, 14, 150, 25);password.setbounds(150, 48, 150, 25);login.setbounds(80, 100, 80, 23);cancel.setbounds(195, 100, 80, 23);/ 设置边框线panelinfo.setborder(borderfactory.createtitledborder();private void quit() int flag = 0;string msg = 您 现 在 要 关 闭 系 统 吗?;flag = joptionpane.showconfirmdialog(null, msg, 提示,joptionpane.yes_no_option);if (flag = joptionpane.yes_option) this.setvisible(false);system.exit(0);return;private void denglu() string username = username.gettext().trim();/ system.out.println(user);string pwd = string.valueof(password.getpassword();string sql = select password from userinfo where username=+ username + ;resultset rs = connectiondb.verification(sql); / 从数据库获取匹配user的密码结果集int flag = 0; / 用户登录错误次数的标记try while (rs.next() / 用户名存在if (pwd.equals(rs.getstring(1) bott.settext(culestring + 登录成功,正在进入系统.);saveuserinfo user = new saveuserinfo();/ 保存用户名user.setusername(username);user.setpassword(pwd);new registerui();this.setvisible(false); else bott.settext(culestring + 用户名/密码不正确,请重新输入.);int m = joptionpane.showconfirmdialog(null,用户名/密码错误,请重新输入!, 错误信息, joptionpane.yes_option);if (m = joptionpane.no_option) system.exit(1); else flag+;if (flag = 3) joptionpane.showmessagedialog(null,您不是本系统的用户,系统关闭 ., 警告,joptionpane.error_message);system.exit(0);/在login.java这个页面里面点击鼠标右键,run as -java application就ok了明白了/还有一种方法,上面哟uge绿的圆形图标,那个下拉菜单有需要运行的类名称,需要运行哪个就点一下哦/程序要改一下 =return; catch (headlessexception e) / todo auto-generated catch blocke.printstacktrace(); catch (sqlexception e) / todo auto-generated catch blocke.printstacktrace();public void actionperformed(actionevent ae) / 动作按键if (ae.getsource() = login) denglu(); / 登录 else quit(); / 退出public void itemstatechanged(itemevent ie) password.requestfocus(true);public void keylistener(keyevent ke) / 键盘按下监听int key = ke.getkeycode();if (key = ke.vk_enter) if (ke.getsource() = username) password.requestfocus(true); / 按下enter键后,焦点从用户名框转到密码框 else if (password.getpassword().length 0) denglu(); / 按enter键登录系统 else if (key = ke.vk_escape) quit(); / 按esc键退出系统public void keyreleased(keyevent ke) / 键盘释放监听public void keytyped(keyevent ke) / 按键类型监听public void focusgained(focusevent fe) if (fe.getsource() = username) / 窗口下面的功能提示bott.settext(culestring + 请输入用户名.); else if (fe.getsource() = password) bott.settext(culestring + 请输入登录密码.); else if (fe.getsource() = login) bott.settext(culestring + 登录系统.); else if (fe.getsource() = cancel) bott.settext(culestring + 退出系统.);public void focuslost(focusevent fe) / 失去焦点监听 */public static void main(string args) new fstartwindow(picture/login.gif, new jframe(), 1200);new login();public void keypressed(keyevent e) / todo auto-generated method stub3.2修改密码修改密码:学生输入正确的用户名和密码后可以对自己的密码进行修改。管理员也可以登录系统后,进入用户管理模块,点击修改用户密码,输入原始密码,新密码和确认密码,如果原始密码输入错误系统将提示密码错误,新密码和确认密码必须是一样的这样才能修改成功。private static final long serialversionuid = 1l;string username = saveuserinfo.getusername();string password = saveuserinfo.getpassword();jbutton bt1, bt2;jtextfield tf1, tf2, tf3, tf;jpanel panelmain;public repassword (jframe frame) super(frame, 修改密码, true);panelmain = new jpanel(new borderlayout();buildpanel();addlistener();this.setcontentpane(panelmain);this.setsize(350, 200);this.setmaximumsize(new dimension(500, 500);this.setresizable(false);this.setlocation(450, 350);this.setvisible(true);private void addlistener() / todo auto-generated method stubbt1.addactionlistener(this);bt2.addactionlistener(this);bt1.addmouselistener(this);bt2.addmouselistener(this);tf1.addactionlistener(this);tf2.addactionlistener(this);private void buildpanel() / todo auto-generated method stubjlabel pass1, pass2, pass3;pass1 = new jlabel(原密码:);pass2 = new jlabel(新密码:);pass3 = new jlabel(重复新密码:);/文本框tf1 = new jtextfield(15);tf2 = new jtextfield(15);tf3 = new jtextfield(15);tf = new jtextfield(密码信息);tf.sethorizontalalignment (jtextfield.center);tf.setbackground(new color(199, 183, 143);tf.setborder(new lineborder(new color(87, 87, 47);tf.seteditable(false);/按钮bt1 = new tjbutton(picture/modi3.gif, 确定, 修改密码);bt2 = new tjbutton(picture/cancel.gif, 取消, 取消操作);jpanel ps, pc, pcc, pcc1, pcc11, pcc12;/jlabel line0 = new jlabel(new imageicon(pic/line5.gif);/分隔线/jlabel line1 = new jlabel(new imageicon(pic/line4.gif);/分隔线ps = new jpanel(new flowlayout(flowlayout.center,50,10); /放置确定和取消按钮pc = new jpanel(new borderlayout(0,5); /放置按钮以上的部分pcc = new jpanel(new flowlayout(flowlayout.center,0,0); /添加新用户文本框为不可编辑,放在north,其他放在流布局的面板中pcc1 = new jpanel(new flowlayout(flowlayout.left,0,3); /放置密码信息三行pcc11 = new jpanel(new gridlayout(3,1,0,6);/放置密码信息三行pcc12 = new jpanel(new gridlayout(3,1,0,6);/放置密码信息三行文本框/构造密码信息三行pcc11.add(pass1);pcc11.add(pass2);pcc11.add(pass3);pcc12.add(tf1);pcc12.add(tf2);pcc12.add(tf3);pcc1.add(pcc11);pcc1.add(pcc12);/将用户信息加入面板pcc.add(pcc1);pc.add(north,tf);pc.add(pcc);pc.setborder(borderfactory.createtitledborder();ps.add(bt1);ps.add(bt2);panelmain.add(south,ps);panelmain.add(pc);/*=* *# private boolean isvalidity() : 测试用户输入的数据是否合法 *参数 :无 *返回值 :boolean *修饰符 :private *功能 :测试用户输入的数据是否合法 *=* */private boolean isvalidity() if(tf1.gettext().length() = 0) joptionpane.showmessagedialog(null, 原密码不能为空, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else if(tf2.gettext().length() = 0) joptionpane.showmessagedialog(null, 新密码不能为空, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else if(tf3.gettext().length() = 0) joptionpane.showmessagedialog(null, 重复密码不能为空, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else if(tf2.gettext().length() != tf3.gettext().length() joptionpane.showmessagedialog(null, 新密码和重复密码不一致不能为空, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else if(tf1.gettext().tostring() != password) joptionpane.showmessagedialog(null, 您输入的原密码不正确, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else if(tf2.gettext().length() 16) joptionpane.showmessagedialog(null, 密码长度不能超过16位, 提示, joptionpane.information_message);tf1.requestfocus(true);return false; else password = tf2.gettext();return true;/*=* *# private void savelivein() : *参数 :无 *返回值 :无 *修饰符 :private *功能 :保存用户信息 *=* * throws sqlexception */private boolean repassword() throws sqlexception boolean flag = connectiondb.repassword(username, password);return flag;/*=* *actionlistener 监听 *=* */public void actionperformed (actionevent e) string msg = 密码修改成功!请返回.;if (e.getsource() = bt1) if (isvalidity() try boolean flag = repassword(); catch (sqlexception e1) / todo auto-generated catch blocke1.printstacktrace();joptionpane.showmessagedialog(null, msg, 提示, joptionpane.yes_option);else if(e.getsource() = bt2) this.setvisible(false);public void mouseclicked(mouseevent e) / todo auto-generated method stubpublic void mouseentered(mouseevent e) / todo auto-generated method stubpublic void mouseexited(mouseevent e) / todo auto-generated method stubpublic void mousepressed(mouseevent e) / todo auto-generated method stubpublic void mousereleased(mouseevent e) / todo auto-generated method stub3.3成绩查询public class connectiondb private static connection conn = null;private static statement stmt = null;private static resultset rs = null;static try class.forname(com.mysql.jdbc.driver).newinstance();conn = drivermanager.getconnection(jdbc:mysql:/localhost:3306/stu, root, root); catch (exception e) joptionpane.showmessagedialog(null, 数据库连接失败., 错误,joptionpane.error_message);system.exit(0);private connectiondb() / 防止实例化public static resultset verification(string sql) try stmt = conn.createstatement();rs = stmt.executequery(sql);/ stmt.close();/ conn.close(); catch (sqlexception e) / todo auto-generated catch blocke.printstacktrace();return rs;/根据用户名获取密码信息public string getpassword(string username) string password = null;try stmt = conn.createstatement();rs = stmt.executequery(select password from userinfo where username = + username + );while (rs.next() password = rs.getstring(password);rs.close();stmt.close();conn.close(); catch (sqlexception e) / todo auto-generated catch blocksystem.out.println(connectiondb.insertamount(): false);return password;/更新数据库中的密码信息public static boolean repassword(string username, string password) boolean flag = false; / 作为是否成功插入记录的标记int rsbefore = 0;try stmt = conn.createstatement();rsbefore = stmt.executeupdate(update userinfo set password = + password + where username = + username + );stmt.close();conn.close(); catch (sqlexception e) / todo auto-generated catch blocksystem.out.println(connectiondb.insertamount(): false);if (rsbefore 0)flag = true;return flag;/根据学号获取此学生的各科成绩,返回值为string数组,保存形式为课程名+分数public static string getgrade(string stuid) string sql = select b.coursename, a.grade from gradeinfo a,courseinfo b where a.stuid=+ stuid + and a.courseid=b.courseid;string str = null;int count = 0;try stmt = conn.createstatement();rs = stmt.executequery(sql);while (rs.next() / gradeinfo info = new gradeinfo();/ info.setcoursename(rs.getstring(coursename);/ info.setscore(rs.getstring(grade);/ list.add(info);count+;str = new stringcount;rs.beforefirst();int i = 0;while (rs.next() stri+ = rs.getstring(coursename) + .+ rs.getstring(grade);rs.close();stmt.close(); catch (sqlexception e) / todo auto-generated catch blocke.printstacktrace();if (str != null & str.length 0)return str;return null;/根据学号获取学生姓名(写重复了 。见getname方法)public static string getname(string stuid) string sql = select name from stuinfo where stuid= + stuid + ;string str = null;try stmt = conn.createstatement();rs = stmt.executequery(sql);while (rs.next() str = rs.getstring(name);rs.close();stmt.close(); catch (sqlexception e) / todo auto-generated catch blocke.printstacktrace();if (str != null)return str;return null;/根据学号获取此学号的平均成绩public static string getavg(string stuid) string sql = select avg(grade) as avg from gradeinfo where stuid=+ stuid + ;/cast(avg(colname) as decimal(9,1) endstring str = null;try stmt = conn.createstatement();rs = stmt.executequery(sql);while (rs.next() str = rs.getstring(avg);rs.close();stmt.close(); catch (sqlexception e) / todo auto-generated catch blocke.printstacktrace();if (str != null)return str;return null;/获取所有学生的平均成绩public static string getallavg() string sql = select a.stuid, name

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论