学生成绩管理系统Java课程设计_第1页
学生成绩管理系统Java课程设计_第2页
学生成绩管理系统Java课程设计_第3页
学生成绩管理系统Java课程设计_第4页
学生成绩管理系统Java课程设计_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

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

文档简介

┊┊┊┊┊┊┊┊┊┊┊┊┊装┊┊┊┊┊订┊┊┊┊┊线┊┊┊┊┊┊┊┊┊┊┊┊┊课程设计纸共39页第页学生成绩t_grade表结构定义,如图6.3所示:图6.3学生成绩表结构定义图(4)班级成绩t_tongji表结构定义,如图6.4所示:图6.4班级成绩表结构定义图7.具体功能实现7.1登录功能的实现(1)登录界面该界面可以对用户名和密码进行验证如不正确则会显示错误信息,如图7.1所示:图7.1登录界面(2)登录功能的实现代码,此段代码通过连接数据库用sql语句查找符合条件的用户,返回值为Logininfo类的对象,在调用此方法的程序中验证此对象是否为空,如为空,则没有该用户显示错误信息;如不为空,则该用户存在,可直接用此对象的getRole()方法进入不同的界面。publicLogininfoquerybyUsernameAndPassword(Logininfouser){ Logininfou=newLogininfo(); Stringname=user.getName(); Stringpwd=user.getPassword(); Stringsql="select*fromt_loginwherename='"+name+"'andpassword='"+pwd+"'"; DBConnectionconn=newDBConnection(); ResultSetrs=conn.doQuery(sql); try{ if(rs.next()){ u.setName(rs.getString("name")); u.setPassword(rs.getString("password")); u.setRole(rs.getInt("role")); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnu; }7.2学生信息查询功能的实现(1)学生信息查询功能界面,可通过此界面按多条件查找如可按学号、姓名或班级等查找,如图7.2所示:图7.2学生信息查询界面(2)学生信息查询功能的实现代码,此代码利用sql语句在数据库中查找所有学生信息,存放在List对象中;如有条件的查找则只需修改sql语句即可,提高了代码的重用性。publicList<Studentinfo>queryAll(){ DBConnectionconn=newDBConnection(); Stringsql="select*fromt_studentinfo"; ResultSetrs=conn.doQuery(sql); List<Studentinfo>list=newArrayList<Studentinfo>(); try{ while(rs.next()){ Studentinfostudent=newStudentinfo(); student.setId(rs.getInt("id")); student.setName(rs.getString("name")); student.setClasses(rs.getInt("classes")); student.setSex(rs.getString("sex")); student.setRace(rs.getString("race")); student.setNativeplace(rs.getString("nativeplace")); student.setDepartment(rs.getString("department")); student.setSchoolyear(rs.getString("schoolyear")); student.setBirth(rs.getString("birth")); list.add(student); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnlist;}7.3学生信息添加功能的实现(1)学生信息添加功能界面,此界面可添加学生信息到数据库中,如图7.3所示:图7.3学生信息添加界面(2)学生信息添加功能的实现代码,此方法以Studentinfo的对象为参数,省去了传多个参数的麻烦,返回值为布尔型,可直接判断添加操作是否成功。publicbooleaninsertStudent(Studentinfostudent){ DBConnectionconn=newDBConnection(); Stringname=student.getName(); intclasses=student.getClasses(); Stringsex=student.getSex(); Stringrace=student.getRace(); Stringnativeplace=student.getNativeplace(); Stringdepartment=student.getName(); Stringschoolyear=student.getSchoolyear(); Stringbirth=student.getBirth(); Stringsql="insertintot_studentinfo(name,classes,sex,race,nativeplace,department,schoolyear,birth)values('"+name+"',"+classes+",'"+sex+"','"+race+"','"+nativeplace+"','"+department+"','"+schoolyear+"','"+birth+"')"; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } }7.4学生信息修改功能的实现(1)学生信息修改功能界面,此界面可以修改学生信息,如图7.4所示: 图7.4学生信息修改界面(2)学生信息修改功能的实现代码,此方法以Studentinfo的对象为参数,省去了传多个参数的麻烦,返回值为布尔型,可直接判断修改操作是否成功。publicbooleanAlteruser(Studentinfos){ Stringname=s.getName(); intclasses=s.getClasses(); Stringsex=s.getSex(); Stringrace=s.getRace(); Stringnativeplace=s.getNativeplace(); Stringdepartment=s.getDepartment(); Stringschoolyear=s.getSchoolyear(); Stringbirth=s.getBirth(); DBConnectionconn=newDBConnection(); Stringsql="updatet_studentinfosetname='"+name+"',classes="+classes+",sex='"+sex+"',race='"+race+"',nativeplace='"+nativeplace+"',"+ "department='"+department+"', schoolyear='"+schoolyear+"',birth='"+birth+"'whereid="+s.getId(); intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; }}7.5学生信息删除功能的实现(1)学生信息删除功能界面,在查询的结果表上直接选中表中的行,点击删除确定就可删除选中行如图7.5所示:图7.5学生信息删除界面(2)学生信息删除功能的实现代码,此方法的参数(此参数是通过在表中添加的鼠标监听器得到的)是所选的表中行的信息的学号,返回布尔型的值,可判断删除是否成功。publicbooleandeletebyID(intid){ DBConnectionconn=newDBConnection(); Stringsql="deletefromt_studentinfowhereid="+id; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } }7.6学生成绩查询功能的实现(1)学生成绩查询功能界面,可多条件查询学生成绩,如图7.6所示:图7.6学生成绩查询功能界面(2)学生成绩查询功能的实现代码,此方法将查到的结果集中的属性放到Grade对象的相应字段中(用Grade类中的get()方法实现),再用while循环将Grade对象放入到List中。publicList<Grade>queryAll(){ DBConnectionconn=newDBConnection(); Stringsql="select*fromt_grade"; ResultSetrs=conn.doQuery(sql); List<Grade>list=newArrayList<Grade>(); try{ while(rs.next()){ Gradegrade=newGrade(); grade.setId(rs.getInt("id")); grade.setName(rs.getString("name")); grade.setDepartment(rs.getString("department")); grade.setClasses(rs.getInt("classes")); grade.setEnglish(rs.getFloat("english")); grade.setSoft(rs.getFloat("soft")); grade.setOs(rs.getFloat("os")); grade.setJava(rs.getFloat("Java")); grade.setSum(rs.getFloat("sum")); grade.setAverage(rs.getFloat("average")); grade.setDates(rs.getString("dates")); list.add(grade); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnlist; }7.7学生成绩添加功能的实现(1)学生成绩添加功能界面,此界面可以添加学生成绩,如图7.7所示:图7.7学生成绩添加界面(2)学生成绩添加功能的实现代码,传Grade对象参数,返回布尔值,方便判断。publicbooleaninsertGrade(Gradegrade){ DBConnectionconn=newDBConnection(); Stringname=grade.getName(); Stringdepartment=grade.getDepartment(); intclasses=grade.getClasses(); floatenglish=grade.getEnglish(); floatsoft=grade.getSoft(); floatos=grade.getOs(); floatjava=grade.getJava(); floatsum=grade.getSum(); floataverage=grade.getAverage(); Stringdates=grade.getDates(); Stringsql="insertintot_grade(name,department,classes,English,soft,os,Java,sum,average,dates)values('" +name+"','"+department+"',"+classes+","+english+","+soft+","+os+","+java+","+sum+","+average+",'"+dates+"')"; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } }7.8学生成绩修改功能的实现(1)学生成绩修改功能界面,此界面只可以更改分数不可以更改其他信息,这样避免了对学生信息更改的混乱,如图7.8所示:图7.8学生成绩修改界面(2)学生成绩修改功能的实现代码,此方法运用的技术同添加方法相同。publicbooleanAlterGrade(Gradeg){ floatenglish=g.getEnglish(); floatsoft=g.getSoft(); floatos=g.getOs(); floatjava=g.getJava(); floatsum=english+soft+os+java; floataverage=sum/4; DBConnectionconn=newDBConnection();Stringsql="updatet_gradesetEnglish="+english+",soft="+soft+",os="+os+",Java="+java+",sum="+sum+",average="+average+"whereid="+g.getId(); intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } }7.9学生成绩导出功能的实现 (1)学生成绩导出功能界面,此界面可以再选位置创建一个新的文本文档,将表中的内容存放到此文本文档中,如图7.9所示:图7.9学生成绩导出功能界面(2)学生成绩导出功能的实现代码,此段代码运用了File类和BufferedWtiter类来实现文件的创建与写出(从内存写到外存)。GradeDaodata=newGradeDao();Listlist=data.queryAll();GradeTabletable=newGradeTable();JTabletable1=newJTable();table1=table.GradeTable(table1,list);intp=fileDialog.showSaveDialog(this);Filefile=fileDialog.getSelectedFile();Strings="学号"+"姓名"+"院系"+"班级"+"英语"+"软件工程"+"操纵系统"+"Java"+"总成绩"+"平均成绩"+"日期"+"\n"; try{ FileWriterwrite=newFileWriter(file); BufferedWriterwrite1=newBufferedWriter(write);//从内存写出到硬盘 write1.write(s); write1.newLine(); for(inti=0;i<list.size();i++){ Gradeg=newGrade(); g=(Grade)list.get(i); Strings1=""+g.getId()+""+g.getName()+""+g.getDepartment()+""+g.getClasses()+""+g.getEnglish()+""+g.getSoft()+""+g.getOs()+""+g.getJava()+""+g.getSum()+""+g.getAverage()+""+g.getDates()+"\n";System.out.println(s1);//从内存写出到硬盘 write1.write(s1);write1.newLine();}write1.close();write.close(); }catch(IOExceptiona){ }7.10班级成绩查询功能的实现 (1)班级成绩查询功能界面,此界面可以多条件查询班级成绩,如图7.10所示:图7.10班级成绩查询界面(2)班级成绩查询功能的实现代码,此方法将查到的结果集中的属性放到Tongji对象的相应字段中(用Tongji类中的get()方法实现),再用while循环将Tongji对象放入到List中,运用list对象更方便操作。publicList<Tongji>queryAll(){ DBConnectionconn=newDBConnection(); Stringsql="select*fromt_tongji"; ResultSetrs=conn.doQuery(sql); List<Tongji>list=newArrayList<Tongji>(); try{ while(rs.next()){ Tongjit=newTongji(); t.setId(rs.getInt("id")); t.setClasses(rs.getInt("classes")); t.setSum(rs.getFloat("sum")); t.setAverage(rs.getFloat("average")); t.setDates(rs.getString("dates")); list.add(t); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnlist; }8.总结经过四个多星期的系统设计与代码编写,基本完成了学生成绩管理系统(主要是权限分配、学生信息管理、学生成绩管理、班级成绩管理)的设计与实现。在这个系统中,可实现由计算机代替人工执行一系列诸如学生信息、学生成绩和班级成绩信息的增、删、查、改和导出等操作以及个人信息的更新等等,这样就使管理人员从繁重的工作中解脱出来,同时实现管理工作的规范化、效率化、国际化。在设计过程中,我首先考虑到了本系统各个大的功能模块,然后进行更加详细的划分,逐步完善各个模块的具体内容。在进行具体代码的编写时,突然会发现有很多边界条件没有考虑到,各种各样的漏洞导致系统容易崩溃不能正常运行,这就需要补充很多的边界控制条件,这时才明白写出能运行的程序和写出健壮的程序是完全不同的两个概念,这些都是需要牢记和掌握的。在信息提示方面,需要给用户一些温馨的提示,而不是诸如“错误编号0x704820”9.附录(1)bean包/*bean包中的Logininfo类*/packagebean;publicclassLogininfo{ intid; Stringname; Stringpassword; introle; publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetName(){ returnname; } publicvoidsetName(Stringname){ =name; } publicStringgetPassword(){ returnpassword; } publicvoidsetPassword(Stringpassword){ this.password=password; } publicintgetRole(){ returnrole; } publicvoidsetRole(introle){ this.role=role; } }/*bean包中的Studentinfo类*/packagebean;publicclassStudentinfo{ privateintid; privateStringname; privateintclasses; privateStringsex; privateStringrace; privateStringnativeplace; privateStringdepartment; privateStringschoolyear; privateStringbirth; publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetName(){ returnname; } publicvoidsetName(Stringname){ =name; } publicintgetClasses(){ returnclasses; } publicvoidsetClasses(intclasses){ this.classes=classes; } publicStringgetSex(){ returnsex; } publicvoidsetSex(Stringsex){ this.sex=sex; } publicStringgetRace(){ returnrace; } publicvoidsetRace(Stringrace){ this.race=race; } publicStringgetNativeplace(){ returnnativeplace; } publicvoidsetNativeplace(Stringnativeplace){ this.nativeplace=nativeplace; } publicStringgetDepartment(){ returndepartment; } publicvoidsetDepartment(Stringdepartment){ this.department=department; } publicStringgetSchoolyear(){ returnschoolyear; } publicvoidsetSchoolyear(Stringschoolyear){ this.schoolyear=schoolyear; } publicStringgetBirth(){ returnbirth; } publicvoidsetBirth(Stringbirth){ this.birth=birth; }}/*bean包中的Grade类*/packagebean;publicclassGrade{ privateintid; privateStringname; privateintclasses; privateStringdepartment; privatefloatEnglish; privatefloatsoft; privatefloatos; privatefloatJava; privatefloatsum; privatefloataverage; privateStringdates; publicStringgetDepartment(){ returndepartment; } publicvoidsetDepartment(Stringdepartment){ this.department=department; } publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetName(){ returnname; } publicvoidsetName(Stringname){ =name; } publicintgetClasses(){ returnclasses; } publicvoidsetClasses(intclasses){ this.classes=classes; } publicfloatgetEnglish(){ returnEnglish; } publicvoidsetEnglish(floatenglish){ English=english; } publicfloatgetSoft(){ returnsoft; } publicvoidsetSoft(floatsoft){ this.soft=soft; } publicfloatgetOs(){ returnos; } publicvoidsetOs(floatos){ this.os=os; } publicfloatgetJava(){ returnJava; } publicvoidsetJava(floatjava){ Java=java; } publicfloatgetSum(){ returnsum; } publicvoidsetSum(floatsum){ this.sum=sum; } publicfloatgetAverage(){ returnaverage; } publicvoidsetAverage(floataverage){ this.average=average; } publicStringgetDates(){ returndates; } publicvoidsetDates(Stringdates){ this.dates=dates; }}/*bean包中的Tongji类*/packagebean;publicclassTongji{ privateintid; privateintclasses; privatefloatsum; privatefloataverage; privateStringdates; publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicintgetClasses(){ returnclasses; } publicvoidsetClasses(intclasses){ this.classes=classes; } publicfloatgetSum(){ returnsum; } publicvoidsetSum(floatsum){ this.sum=sum; } publicfloatgetAverage(){ returnaverage; } publicvoidsetAverage(floataverage){ this.average=average; } publicStringgetDates(){ returndates; } publicvoidsetDates(Stringdatesl){ this.dates=dates; }}(2)jdbc包/*jdbc包中的DBConnection类*/packagejdbc;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassDBConnection{ privateResultSetrs; privateConnectioncon; privateStatementst;static{ try{ Class.forName("com.mysql.jdbc.Driver");//加载驱动 }catch(ClassNotFoundExceptione){ e.printStackTrace(); }}publicvoidgetConnection(){ try{ con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");//连接数据库语句 }catch(SQLExceptione){ e.printStackTrace(); }}/*查询数据库*/publicResultSetdoQuery(Stringsql){ this.getConnection(); try{ st=con.createStatement();//用连接创建sql执行语句 rs=st.executeQuery(sql);//用sql的执行语句调用executeQuery返回结果集对象 }catch(SQLExceptione){ e.printStackTrace(); } returnrs;}/*关闭数据库连接*/publicvoidqueryclose(){ try{ rs.close(); st.close(); con.close(); }catch(SQLExceptione){ e.printStackTrace(); } }/*更新数据库,返回的本次操作影响的数据库的行数*/publicintUpdate(Stringsql){ this.getConnection(); intcount=0; try{ st=con.createStatement(); count=st.executeUpdate(sql); }catch(SQLExceptione){ e.printStackTrace(); } returncount;}/*关闭数据库更新连接*/publicvoidupdateclose(){ try{ st.close(); con.close(); }catch(SQLExceptione){ e.printStackTrace(); }}}(3)dao包/*dao包中的Logindao类*/packagedao;importjava.sql.ResultSet;importjava.sql.SQLException;importjdbc.DBConnection;importbean.Logininfo;/*按用户名和密码查询用户*/publicclassLogindao{ publicstaticLogininfoquerybyUsernameAndPassword(Logininfouser){ Logininfou=newLogininfo(); Stringname=user.getName(); Stringpwd=user.getPassword(); Stringsql="select*fromt_loginwherename='"+name+"'andpassword='"+pwd+"'"; DBConnectionconn=newDBConnection(); ResultSetrs=conn.doQuery(sql); try{ if(rs.next()){ u.setName(rs.getString("name")); u.setPassword(rs.getString("password")); u.setRole(rs.getInt("role")); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnu; }}/*dao包中的Studentinfodao类*/packagedao;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importjavax.swing.JTable;importjavax.swing.table.DefaultTableModel;importjdbc.DBConnection;importbean.Logininfo;importbean.Studentinfo;publicclassStudentinfodao{/*查询所有学生信息的方法*/ publicList<Studentinfo>queryAll(){ DBConnectionconn=newDBConnection(); Stringsql="select*fromt_studentinfo"; ResultSetrs=conn.doQuery(sql); List<Studentinfo>list=newArrayList<Studentinfo>(); try{ while(rs.next()){ Studentinfostudent=newStudentinfo();//将数据库的信息获取并放到student中再将student依次加入到list中 student.setId(rs.getInt("id")); student.setName(rs.getString("name")); student.setClasses(rs.getInt("classes")); student.setSex(rs.getString("sex")); student.setRace(rs.getString("race")); student.setNativeplace(rs.getString("nativeplace")); student.setDepartment(rs.getString("department")); student.setSchoolyear(rs.getString("schoolyear")); student.setBirth(rs.getString("birth")); list.add(student); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnlist; } /*添加学生信息的方法*/ publicbooleaninsertStudent(Studentinfostudent){ DBConnectionconn=newDBConnection(); Stringname=student.getName(); intclasses=student.getClasses(); Stringsex=student.getSex(); Stringrace=student.getRace(); Stringnativeplace=student.getNativeplace(); Stringdepartment=student.getName(); Stringschoolyear=student.getSchoolyear(); Stringbirth=student.getBirth(); Stringsql="insertintot_studentinfo(name,classes,sex,race,nativeplace,department,schoolyear,birth)values('"+name+"',"+classes+",'"+sex+"','"+race+"','"+nativeplace+"','"+department+"','"+schoolyear+"','"+birth+"')"; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } } /*按学号删除学生信息的方法*/ publicbooleandeletebyID(intid){ DBConnectionconn=newDBConnection(); Stringsql="deletefromt_studentinfowhereid="+id; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } } /*修改学生信息的方法*/ publicbooleanAlteruser(Studentinfos){ Stringname=s.getName(); intclasses=s.getClasses(); Stringsex=s.getSex(); Stringrace=s.getRace(); Stringnativeplace=s.getNativeplace(); Stringdepartment=s.getDepartment(); Stringschoolyear=s.getSchoolyear(); Stringbirth=s.getBirth(); DBConnectionconn=newDBConnection(); Stringsql="updatet_studentinfosetname='"+name+"',classes="+classes+",sex='"+sex+"',race='"+race+"',nativeplace='"+nativeplace+"',"+"department='"+department+"',schoolyear='"+schoolyear+"',birth='"+birth+"'whereid="+s.getId(); intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } } /*按学号查询学生信息的方法*/ publicStudentinfoquerybyId(intid){ Studentinfos=newStudentinfo(); Stringsql="select*fromt_studentinfowhereid="+id+""; DBConnectionconn=newDBConnection(); ResultSetrs=conn.doQuery(sql); try{ if(rs.next()){ s.setId(rs.getInt("id")); s.setName(rs.getString("name")); s.setClasses(rs.getInt("classes")); s.setSex(rs.getString("sex")); s.setRace(rs.getString("race")); s.setNativeplace(rs.getString("nativeplace")); s.setDepartment(rs.getString("department")); s.setSchoolyear(rs.getString("schoolyear")); s.setBirth(rs.getString("birth")); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returns; }}/*dao包中的GradeDao类*/packagedao;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importjdbc.DBConnection;importbean.Grade;publicclassGradeDao{/*学生成绩查询方法*/ publicList<Grade>queryAll(){ DBConnectionconn=newDBConnection(); Stringsql="select*fromt_grade"; ResultSetrs=conn.doQuery(sql); List<Grade>list=newArrayList<Grade>(); try{ while(rs.next()){ Gradegrade=newGrade();//将数据库的信息获取并放到grade中再将grade依次加入到list中 grade.setId(rs.getInt("id")); grade.setName(rs.getString("name")); grade.setDepartment(rs.getString("department")); grade.setClasses(rs.getInt("classes")); grade.setEnglish(rs.getFloat("english")); grade.setSoft(rs.getFloat("soft")); grade.setOs(rs.getFloat("os")); grade.setJava(rs.getFloat("Java")); grade.setSum(rs.getFloat("sum")); grade.setAverage(rs.getFloat("average")); grade.setDates(rs.getString("dates")); list.add(grade); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returnlist; } /*学生成绩添加方法*/ publicbooleaninsertGrade(Gradegrade){ DBConnectionconn=newDBConnection(); Stringname=grade.getName(); Stringdepartment=grade.getDepartment(); intclasses=grade.getClasses(); floatenglish=grade.getEnglish(); floatsoft=grade.getSoft(); floatos=grade.getOs(); floatjava=grade.getJava(); floatsum=grade.getSum(); floataverage=grade.getAverage(); Stringdates=grade.getDates(); Stringsql="insertintot_grade(name,department,classes,English,soft,os,Java,sum,average,dates)values('"+name+"','"+department+"',"+classes+","+english+","+soft+","+os+","+java+","+sum+","+average+",'"+dates+"')"; intcount=conn.Update(sql); if(count>0){ conn.updateclose(); returntrue; }else{ conn.updateclose(); returnfalse; } } /*按学号查询学生成绩的方法*/ publicGradequerybyId(intid){ Gradeg=newGrade(); Stringsql="select*fromt_gradewhereid="+id+""; DBConnectionconn=newDBConnection(); ResultSetrs=conn.doQuery(sql); try{ if(rs.next()){ g.setId(rs.getInt("id")); g.setName(rs.getString("name")); g.setDepartment(rs.getString("department")); g.setClasses(rs.getInt("classes")); g.setEnglish(rs.getFloat("English")); g.setSoft(rs.getFloat("soft")); g.setOs(rs.getFloat("os")); g.setJava(rs.getFloat("Java")); g.setSum(rs.getFloat("sum")); g.setAverage(rs.getFloat("average")); } }catch(SQLExceptione){ e.printStackTrace(); } conn.queryclose(); returng; } /*学生成绩修改方法*/ publicbooleanAlterGrade(Gradeg){ floatenglish=g.getEnglish(); floatsoft=g.getSoft(); floatos=g.getOs(); floatjava=g.getJava(); floatsum=english+soft+os+java; floataverage=sum/4;

温馨提示

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

评论

0/150

提交评论