已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JAVAJAVA学生管理系统学生管理系统 课程设计课程设计 编译提示 1 有使用其他可视化Java编程工具经验的用户也可以利用这些软件已经携带的JDK 例如从 控 制面板 中通过 系统 高级 环境变量 针对JBuilder8设置环境变量 即把Path路径设置为C J Builder8 jdk1 4 bin 然后将每章 源程序 目录之中的内容保存在例如C temp目录中 然后即可在 命令提示符窗口中切换到C temp 并使用javac classpath java命令进行编译 其中 classpath用来告诉编译器用户Java文件的路径 表示 java文件的路径在当前目录位置 注意点的前后均有一个空格 经过编译产生 class文件 后 在C temp 提示符下使用java classpath 命令即可运行程序 其中 classpath用来告诉编译器用户类文件的路径 表示 class文件的路径在当前目录位置 注意点的前后均有一个空格 为不包括扩展名的类 文件名 2 上述方法对于直接安装的JDK 1 5亦完全适用 3 也可以象书中介绍的那样 在使用javac命令之前使用set classpath c temp设置类路径 等号前后不能有空格 然后即可直接使用javac java编译命令和java 运行命令 4 但是应注意 在使用JDK 1 4时 个别程序可能会无法正常编译运行 因JDK 1 5的编程方式略有变化 所以应首选JDK 1 5 5 与在 环境变量 对话框中设置类路径相比 在命令提示符窗口中设置类路径是比较稳妥的方 法 因为用户存放程序代码的目录位置是根据内容不同而随时确定的 此外您可能会发现 环境 变量 对话框中的ClassPath设置在有些情况下毫无作用 AddCourseInfo java import java awt event import java awt import javax swing 课程信息管理模块 添加新的课程信息 public class AddCourseInfo extends CourseInfo CrsBean getCnum new CrsBean public AddCourseInfo this setTitle 添加课程信息 this setResizable false cNum setEditable false cNum setText getCnum getCrsId cName setEditable true cTeacher setEditable true cType setEditable true cTime setEditable true cPlace setEditable true 设置运行位置 使对话框居中 Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation int screenSize width 400 2 int screenSize height 300 2 45 public void downInit addInfo setText 增加 addInfo setFont new Font Dialog 0 12 downPanel add addInfo clearInfo setText 清空 clearInfo setFont new Font Dialog 0 12 downPanel add clearInfo eixtInfo setText 退出 eixtInfo setFont new Font Dialog 0 12 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj eixtInfo 退出 this dispose else if obj addInfo 增加 cNum setEnabled false cName setEditable false cTeacher setEditable false cType setEditable false cTime setEditable false cPlace setEditable false addInfo setEnabled false clearInfo setEnabled false eixtInfo setEnabled false CrsBean addCrs new CrsBean addCrs crsAdd cName getText cTeacher getText cPlace getText cType getText cTime getText this dispose AddCourseInfo aci new AddCourseInfo aci downInit aci pack aci setVisible true this dispose else if obj clearInfo 清空 setNull cNum setText getCnum getCrsId 543 AddGradeInfo java import java awt event import java awt import javax swing 成绩信息管理模块 添加新的成绩信息 public class AddGradeInfo extends GradeInfo implements ActionListener public AddGradeInfo this setTitle 添加成绩信息 this setResizable false 设置运行位置 使对话框居中 Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation int screenSize width 400 2 int screenSize height 300 2 45 public void downInit addInfo setText 增加 addInfo setFont new Font Dialog 0 12 downPanel add addInfo eixtInfo setText 退出 eixtInfo setFont new Font Dialog 0 12 downPanel add eixtInfo this contentPane add downPanel BorderLayout SOUTH sNum addActionListener this addInfo addActionListener this eixtInfo addActionListener this 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj addInfo 增加 cNum setEnabled false cName setEditable false cTeacher setEditable false Grade setEditable false sNum setEditable false sName setEditable false addInfo setEnabled false clearInfo setEnabled false eixtInfo setEnabled false csBean addGrade new csBean addGrade csModify cNum getText String sNum getSelectedItem Grade getText this dispose AddGradeInfo agi new AddGradeInfo else if obj sNum 选择学号 StuBean sN new StuBean sName setText sN stuSearch String sNum getSelectedItem 0 if cName getItemCount 0 cName removeAllItems csBean cN new csBean cReturn cN cNameSearch String sNum getSelectedItem if cReturn null cName removeActionListener this JOptionPane showMessageDialog null 该学生没有选择课程 addInfo setEnabled false cName setEnabled false else int i 0 for i 0 i cReturn length i cName addItem cReturn i cName setEnabled true sNum setEnabled false cName setSelectedItem null cName addActionListener this else if obj cName 选择课程号 CrsBean cSname new CrsBean cNum setText cSname crsNameSearch String cName getSelectedItem String sNum getSelectedIt em 0 cTeacher setText cSname crsNameSearch String cName getSelectedItem String sNum getSelecte dItem 1 addInfo setEnabled true cName setEnabled false cName removeActionListener this JAVA学生管理系统 import java awt event import java awt import javax swing 学生信息管理模块 添加新的学生信息 public class AddStuInfo extends StuInfo StuBean getSnum new StuBean public AddStuInfo this setTitle 添加学生信息 this setResizable false sNum setEditable false sNum setText getSnum getStuId sName setEditable true sSex setEditable true sSethnic setEditable true sBirth setEditable true sYear setEditable true sMajor setEditable true sCollege setEditable true sHome setEditable true 设置运行时窗口的位置 Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation screenSize width 400 2 screenSize height 300 2 45 public void downInit addInfo setText 增加 addInfo setFont new Font Dialog 0 12 downPanel add addInfo clearInfo setText 清空 clearInfo setFont new Font Dialog 0 12 downPanel add clearInfo eixtInfo setText 退出 eixtInfo setFont new Font Dialog 0 12 downPanel add eixtInfo 添加事件侦听 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj eixtInfo 退出 this dispose else if obj addInfo 增加 sNum setEnabled false sName setEnabled false sSex setEnabled false sSethnic setEnabled false sBirth setEnabled false sYear setEnabled false sMajor setEnabled false sCollege setEnabled false sHome setEnabled false addInfo setEnabled false clearInfo setEnabled false eixtInfo setEnabled false StuBean addStu new StuBean addStu stuAdd sName getText sSex getText sBirth getText sHome getText sSethnic getText sYear getText sMajor getText sCollege getText this dispose AddStuInfo asi new AddStuInfo asi downInit asi pack asi setVisible true else if obj clearInfo 清空 setNull sNum setText getSnum getStuId JAVA学生管理系统 import javax swing import java awt import java awt event import 课程信息综合管理类 提供主界面 供其他类继承 public class CourseInfo extends JFrame implements ActionListener Container contentPane JPanel centerPanel new JPanel JPanel upPanel new JPanel JPanel downPanel new JPanel 框架的大小 Dimension faceSize new Dimension 800 500 JLabel jLabel1 new JLabel JLabel jLabel2 new JLabel JLabel jLabel3 new JLabel JLabel jLabel4 new JLabel JLabel jLabel5 new JLabel JLabel jLabel6 new JLabel JTextField cNum new JTextField 15 JTextField cName new JTextField 15 JTextField cTeacher new JTextField 15 JTextField cType new JTextField 15 JTextField cTime new JTextField 15 JTextField cPlace new JTextField 15 JButton searchInfo new JButton JButton addInfo new JButton JButton modifyInfo new JButton JButton deleteInfo new JButton JButton clearInfo new JButton JButton saveInfo new JButton JButton eixtInfo new JButton GridBagLayout girdBag new GridBagLayout GridBagConstraints girdBagCon public CourseInfo this setSize faceSize 设置标题 this setTitle 课程综合信息管理 this setResizable false 设置程序图标 this setIconImage getImage icon gif try Init catch Exception e e printStackTrace public void Init throws Exception contentPane this getContentPane contentPane setLayout new BorderLayout 中部面板的布局 centerPanel setLayout girdBag jLabel1 setText 课程编码 jLabel1 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 0 girdBagCon gridy 0 girdBagCon insets new Insets 10 10 10 1 girdBag setConstraints jLabel1 girdBagCon centerPanel add jLabel1 girdBagCon new GridBagConstraints girdBagCon gridx 1 girdBagCon gridy 0 girdBagCon insets new Insets 10 1 10 15 girdBag setConstraints cNum girdBagCon centerPanel add cNum jLabel2 setText 课程名称 jLabel2 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 2 girdBagCon gridy 0 girdBagCon insets new Insets 10 15 10 1 girdBag setConstraints jLabel2 girdBagCon centerPanel add jLabel2 girdBagCon new GridBagConstraints girdBagCon gridx 3 girdBagCon gridy 0 girdBagCon insets new Insets 10 1 10 10 girdBag setConstraints cName girdBagCon centerPanel add cName jLabel3 setText 授课老师 jLabel3 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 0 girdBagCon gridy 1 girdBagCon insets new Insets 10 10 10 1 girdBag setConstraints jLabel3 girdBagCon centerPanel add jLabel3 girdBagCon new GridBagConstraints girdBagCon gridx 1 girdBagCon gridy 1 girdBagCon insets new Insets 10 1 10 15 girdBag setConstraints cTeacher girdBagCon centerPanel add cTeacher jLabel4 setText 课程类别 jLabel4 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 2 girdBagCon gridy 1 girdBagCon insets new Insets 10 15 10 1 girdBag setConstraints jLabel4 girdBagCon centerPanel add jLabel4 girdBagCon new GridBagConstraints girdBagCon gridx 3 girdBagCon gridy 1 girdBagCon insets new Insets 10 1 10 10 girdBag setConstraints cType girdBagCon centerPanel add cType jLabel5 setText 上课时间 jLabel5 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 0 girdBagCon gridy 2 girdBagCon insets new Insets 10 10 10 1 girdBag setConstraints jLabel5 girdBagCon centerPanel add jLabel5 girdBagCon new GridBagConstraints girdBagCon gridx 1 girdBagCon gridy 2 girdBagCon insets new Insets 10 1 10 15 girdBag setConstraints cTime girdBagCon centerPanel add cTime jLabel6 setText 上课地点 jLabel6 setFont new Font Dialog 0 12 girdBagCon new GridBagConstraints girdBagCon gridx 2 girdBagCon gridy 2 girdBagCon insets new Insets 10 15 10 1 girdBag setConstraints jLabel6 girdBagCon centerPanel add jLabel6 girdBagCon new GridBagConstraints girdBagCon gridx 3 girdBagCon insets new Insets 10 1 10 10 girdBag setConstraints cPlace girdBagCon centerPanel add cPlace contentPane add centerPanel BorderLayout CENTER 下部面板的布局 public void downInit searchInfo setText 查询 searchInfo setFont new Font Dialog 0 12 downPanel add searchInfo addInfo setText 增加 addInfo setFont new Font Dialog 0 12 downPanel add addInfo modifyInfo setText 修改 modifyInfo setFont new Font Dialog 0 12 downPanel add modifyInfo deleteInfo setText 删除 deleteInfo setFont new Font Dialog 0 12 downPanel add deleteInfo saveInfo setText 保存 saveInfo setFont new Font Dialog 0 12 downPanel add saveInfo clearInfo setText 清空 clearInfo setFont new Font Dialog 0 12 downPanel add clearInfo eixtInfo setText 退出 eixtInfo setFont new Font Dialog 0 12 downPanel add eixtInfo contentPane add downPanel BorderLayout SOUTH 添加事件侦听 searchInfo addActionListener this addInfo addActionListener this modifyInfo addActionListener this deleteInfo addActionListener this saveInfo addActionListener this clearInfo addActionListener this eixtInfo addActionListener this 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj searchInfo 查询 else if obj addInfo 增加 else if obj modifyInfo 修改 else if obj deleteInfo 删除 else if obj saveInfo 保存 cName setText null cTeacher setText null cType setText null cTime setText null cPlace setText null 通过给定的文件名获得图像 Image getImage String filename URLClassLoader urlLoader URLClassLoader this getClass getClassLoader URL url null Image image null url urlLoader findResource filename image Toolkit getDefaultToolkit getImage url MediaTracker mediatracker new MediaTracker this try mediatracker addImage image 0 mediatracker waitForID 0 catch InterruptedException ex image null if mediatracker isErrorID 0 image null return image JAVA学生管理系统 import javax swing import java awt import java awt event 课程信息管理模块 根据课程编号查询课程信息 以供调用者修改或删除 public class CourseInfoSearchCnum extends JDialog implements ActionListener Container contentPane String s 框架的大小 Dimension faceSize new Dimension 300 100 JLabel jLabel1 new JLabel JComboBox selectCnum JButton searchInfo new JButton public CourseInfoSearchCnum JFrame frame super frame true this setResizable false try Init catch Exception e e printStackTrace 设置运行位置 使对话框居中 Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation int screenSize width 400 2 int screenSize height 300 2 45 private void Init throws Exception this setSize faceSize contentPane this getContentPane contentPane setLayout new FlowLayout jLabel1 setText 请输入或者选择课程号 jLabel1 setFont new Font Dialog 0 12 contentPane add jLabel1 CrsBean getId new CrsBean s getId getAllId selectCnum new JComboBox s selectCnum setSelectedItem null selectCnum setEditable true selectCnum setFont new Font Dialog 0 12 contentPane add selectCnum searchInfo setText 查询 searchInfo setFont new Font Dialog 0 12 contentPane add searchInfo selectCnum addActionListener this searchInfo addActionListener this 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj selectCnum 退出 this dispose else if obj searchInfo 修改 this dispose 返回选择的学号 public String getCnum return String this selectCnum getSelectedItem import javax swing import java awt import java awt event import 课程信息查询模块 根据课程名称查询课程的信息 public class CourseSearchCname extends JFrame implements ActionListener Container contentPane 框架的大小 Dimension faceSize new Dimension 300 100 JLabel jLabel1 new JLabel JTextField cName new JTextField 8 JButton searchInfo new JButton public CourseSearchCname 设置标题 this setTitle 按课程名称查询 this setResizable false 设置程序图标 this setIconImage getImage icon gif try Init Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation int screenSize width 400 2 int screenSize height 300 2 45 private void Init throws Exception this setSize faceSize contentPane this getContentPane contentPane setLayout new FlowLayout jLabel1 setText 请输入课程名称 jLabel1 setFont new Font Dialog 0 12 contentPane add jLabel1 cName setText null cName setFont new Font Dialog 0 12 contentPane add cName searchInfo setText 确定 searchInfo setFont new Font Dialog 0 12 contentPane add searchInfo searchInfo addActionListener this 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj searchInfo 查询 ResultCourse rC new ResultCourse cname cName getText this dispose 通过给定的文件名获得图像 Image getImage String filename URLClassLoader urlLoader URLClassLoader this getClass getClassLoader URL url null Image image null url urlLoader findResource filename image Toolkit getDefaultToolkit getImage url MediaTracker mediatracker new MediaTracker this try mediatracker addImage image 0 mediatracker waitForID 0 catch InterruptedException ex image null if mediatracker isErrorID 0 image null return image JAVA学生管理系统 import javax swing import java awt import java awt event import 课程信息查询模块 根据授课教师查询课程的信息 public class CourseSearchCteacher extends JFrame implements ActionListener Container contentPane 框架的大小 Dimension faceSize new Dimension 300 100 JLabel jLabel1 new JLabel JTextField cTeacher new JTextField 8 JButton searchInfo new JButton public CourseSearchCteacher 设置标题 this setTitle 按课程名称查询 this setResizable false 设置程序图标 this setIconImage getImage icon gif try Init catch Exception e e printStackTrace 设置运行位置 使对话框居中 Dimension screenSize Toolkit getDefaultToolkit getScreenSize this setLocation int screenSize width 400 2 int screenSize height 300 2 45 private void Init throws Exception this setSize faceSize contentPane this getContentPane contentPane setLayout new FlowLayout jLabel1 setText 请输入授课教师名称 jLabel1 setFont new Font Dialog 0 12 contentPane add jLabel1 cTeacher setText null cTeacher setFont new Font Dialog 0 12 contentPane add cTeacher searchInfo setText 确定 searchInfo setFont new Font Dialog 0 12 contentPane add searchInfo searchInfo addActionListener this 事件处理 public void actionPerformed ActionEvent e Object obj e getSource if obj searchInfo 查询 ResultCourse rC new ResultCourse cteacher cTeacher getText this dispose 通过给定的文件名获得图像 Image getImage String filename URLClassLoader urlLoader URLClassLoader this getClass getClassLoader URL url null Image image null url urlLoader findResource filename image Toolkit getDefaultToolkit getImage url MediaTracker mediatracker new MediaTracker this try mediatracker addImage image 0 mediatracker waitForID 0 catch InterruptedException ex image null if mediatracker isErrorID 0 image null return image JAVA学生管理系统 import java util import java sql import javax swing 用来保存成绩查询方面的类 public class csBean String sql ResultSet rs Vector tempvector new Vector 1 1 String cNum String sNum float grade int colNum 添加学生的选课信息 public void csAdd String cnum String snum Database DB new Database this cNum cnum this sNum snum sql insert into sc cnum snum values Integer parseInt cNum Integer parseInt sNum try DB OpenConn DB executeUpdate sql JOptionPane showMessageDialog null 成功添加一条新的纪录 catch Exception e JOptionPane showMessageDialog null 保存失败 错误 JOptionPane ERROR MESSAGE finally DB closeStmt DB closeConn 修改学生的选课成绩 public void csModify String cnum String snum String grade Database DB new Database this cNum cnum this sNum snum try this grade Float parseFloat grade catch Exception e JOptionPane showMessageDialog null 成绩输入错误 错误 JOptionPane ERROR MESSAGE return sql update sc set grade grade where snum Integer parseInt sNum and cnum Integer parseInt cNum try DB OpenConn DB executeUpdate sql JOptionPane showMessageDialog null 成功登记成绩 catch Exception e System out println e JOptionPane showMessageDialog null 登记失败 错误 JOptionPane ERROR MESSAGE finally DB closeStmt DB closeConn 根据学号搜索其所选的课程名称 public String cNameSearch String snum Database DB new Database this sNum snum sql select from sc course where sc snum Integer parseInt sNum and um um String cn null int row 0 int i 0 try DB OpenConn rs DB executeQuery sql if rs last row rs getRow if row 0 cn null else cn new String row rs first rs previous while rs next cn i rs getString 5 i catch Exception e finally DB closeStmt DB closeConn return cn 成绩信息综合查询 public String csAllSearch String snum int colnum this sNum snum this colNum colnum Database DB new Database String cn null int row 0 int i 0 sql select from sc course student where sc snum Integer parseInt sNum and um um and sc snum student snum try DB OpenConn rs DB executeQuery sql if rs last row rs getRow if row 0 cn null else cn new String row colNum rs first rs previous while rs next cn i 0 rs getString 1 cn i 1 rs getString 11 cn i 2 rs getString 2 cn i 3 rs getString 5 cn i 4 rs getString 3 i catch Exception e finally DB closeStmt DB closeConn return cn JAVA学生管理系统 import java sql 连接数据库的类 public clas
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 修鞋工安全防护竞赛考核试卷含答案
- 光纤拉制工安全文化强化考核试卷含答案
- 直肠炎的健康宣教
- 溃疡性结肠炎常见症状及护理护理要点讲解
- 太阳照常升起小说分析
- 胰腺癌常见症状及护理守则
- 2025年血压计维护合同协议
- 2026《消防设施操作员(初级)》技能鉴定浓缩高频考点500题及答案
- 脑出血营养科查房
- 高逼格大师介绍
- WSET品酒师二级模拟题
- (完整版)毛石混凝土挡墙专项施工方案
- 生物统计与试验设计(延边大学)知到智慧树网课答案
- 中学生心理健康综合测量问卷MHT00
- 国网安全考试试卷题库及答案解析
- 高速公路建设项目亮点策划方案
- 2025年部编新版道德与法治三年级上册期末复习计划
- 消防应急预案消防应急预案
- 2025河北雄安友信公司招聘10人笔试参考题库附带答案详解
- 建筑施工关键工序技术控制措施
- 山东省日照市2025年中考英语真题附同步解析答案
评论
0/150
提交评论