zoukankan      html  css  js  c++  java
  • Java课程设计——学生成绩管理系统(201521123003 董美凤)

    Java课程设计——学生成绩管理系统(201521123003 董美凤)

    1.团队课程设计博客链接

    学生成绩管理系统博客链接

    2.个人负责模块或任务说明

    • 信息修改
    • 密码修改
    • 部分界面设计

    3.自己的代码提交记录截图

    码云项目地址

    4.自己负责模块或任务详细说明

    • 学生信息修改
    @Override
    public int update(String stuno, String name, String sex, String birthday) {
    			// TODO Auto-generated method stub
    			int result=-1;
    	    	Connection conn = null;
    	    	Statement st= null;
    	    	ResultSet resultset=null;
    String sqlname = "update students set name='"+name+"'where stuno="+stuno;
    String sqlsex="update students set sex='"+sex+"' where stuno="+stuno;
    String sqlbirthday="update students set birthday='"+birthday+"' where stuno="+stuno;
    			try {
    				conn = JDBCUtil.getConnection();
    				st = conn.createStatement();
    				if(!name.isEmpty()){
    					int i=st.executeUpdate(sqlname);
    					result=1;
    				}
    				if(!sex.isEmpty()){
    					int i=st.executeUpdate(sqlsex);
    					result=1;
    				}
    				if(!birthday.isEmpty()){
    					int i=st.executeUpdate(sqlbirthday);
    					result=1;
    				}
    				
    			}catch (SQLException sqle) {
    				sqle.printStackTrace();
    			}catch(Exception e){
    				e.printStackTrace();
    			}finally{
    				JDBCUtil.realeaseAll(null,st, conn);
    			}
    			return result;
    }
    
    

    从界面文本框中请求相关数据,调用update()方法,方法内判断获取的字符串是否为空,不为空则将相关MySqL修改信息语句写入数据库进行更改学生信息。

    • 密码修改
    @Override
    public int changepassword(String stuno, String oldpassword,String newpassword1, String newpassword2) {
    			// TODO Auto-generated method stub
    			int result=-1;
    			String password=null;
    	    	Connection conn = null;
    	    	Statement st= null;
    	    	ResultSet rs=null;
    String sqlchange = "update students set password='"+newpassword1+"'where stuno="+stuno;
    String sqlgetpassword="select * from students where stuno="+stuno;
    			try {
    				conn = JDBCUtil.getConnection();
    				st = conn.createStatement();
    				rs = st.executeQuery(sqlgetpassword);
    				while(rs.next())
    				password=rs.getString("password");
    if(!newpassword1.isEmpty()&&!newpassword2.isEmpty()&&oldpassword.equals(password)){
    					result=st.executeUpdate(sqlchange);					
    				}	
    			}catch (SQLException sqle) {
    				sqle.printStackTrace();
    			}catch(Exception e){
    				e.printStackTrace();
    			}finally{
    				JDBCUtil.realeaseAll(null,st, conn);
    			}
    			return result;
    }
    
    

    用户将所知原密码输入,并输入新密码和确认密码,调用changepassword()方法,该方法将数据库中的相关用户密码读出并与用户所输密码进行比较,同时新密码和确认密码不为空并且相等,同时满足这些条件,才对数据库中的用户的密码进行修改。

    5.课程设计感想

    巩固了所学的知识,对Java的认知有了新的认知,对整个项目的框架构建设计有了更清晰的认识。同时,在遇到问题,不断修改代码,不断尝试不同的思维方式去解决问题的过程中,收获颇多。最重要的是,与队友一起熬夜解决问题,一同谈论、学习、分享的感觉非常好,由于时间紧凑,功能和界面较为简洁,未能够对其进行更好地完善。

  • 相关阅读:
    对面向对象设计原则的总结
    sql server连接字符串
    js页面加载进度条
    Yui.Compressor高性能ASP.NET开发:自动压缩CSS、JS
    asp.net利用多线程执行长时间的任务,客户端显示出任务的执行进度的示例(一)_转
    asp.net删除目录,Session丢失
    extjs ComboBox使用注意
    转:使Eclipse的智能感知可以像 Visual Studio 一样快速提示
    Android ContentProvider 填删改查 实例
    Windows Phone StackPanel 布局示例
  • 原文地址:https://www.cnblogs.com/dongmf/p/7063199.html
Copyright © 2011-2022 走看看