首页 JAVA程序设计课程设计报告_高考管理系统的开发(1)

JAVA程序设计课程设计报告_高考管理系统的开发(1)

举报
开通vip

JAVA程序设计课程设计报告_高考管理系统的开发(1)JAVA程序设计课程设计报告_高考管理系统的开发(1) JAVA程序设计 课程设计报告 课 题: 高考管理系统的开发 姓 名: 学 号: 同组姓名: 专业班级: 计算机科学与技术 指导教师: 设计时间: 2011.2.28~3.4 评阅意见: 评定成绩: 指导老师签名: 年 月 日 目录 一、课程设计目的和意义 …………………………………………….1 二、高考信息管理系统数据库结构设计 …………………………….2 1、建立文科数据表………………………………………………..2 2、建...

JAVA程序设计课程设计报告_高考管理系统的开发(1)
JAVA程序 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 课程设计报告_高考管理系统的开发(1) JAVA程序设计 课程设计报告 课 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 : 高考管理系统的开发 姓 名: 学 号: 同组姓名: 专业班级: 计算机科学与技术 指导教师: 设计时间: 2011.2.28~3.4 评阅意见: 评定成绩: 指导老师签名: 年 月 日 目录 一、课程设计目的和意义 …………………………………………….1 二、高考信息管理系统数据库结构设计 …………………………….2 1、建立文科数据表………………………………………………..2 2、建立文科从数据表……………………………………………..3 3、理科数据表的设计……………………………………………..4 三、主控界面的设计…………………………………………………….4 四、理科成绩录入系统设计……………………………………………6 五、理科成绩查询模块的设计 ……………………………………….9 六、文科成绩录入与查询窗体的设计 ………………………………..10 1、文科成绩录入窗体设计………………………………………10 2、文科成绩查询窗体的开发…………………………………..11 3、文科成绩查询窗体的开发…………………………………..11 七、运行与调试 ………………………………………………………11 八、实验小结心得体会 ……………………………………………….15 参考文献 ……………………………………………...……………….16 附录:部分源代码 ……………………………………………………..16 2 一、 课程设计目的和意义 高考成绩的统计和查询工作是非常重要的。高考成绩面向的是全国范围内的考生,它涉及的面比较广、数量大,如果在设计上出现什么问题,都会在社会上产生巨大的影响。在这次试验里,并不是要开发出一套系统的完整的高考管理系统。这里只是简单地做一个高考成绩查询与统计的小系统,并没考虑安全性的问题。主要是学习完《Java程序设计》课程后进行的一次全面的综合练习。其目的在于通过课程设计,使学生能够得到较系统的技能训练,从而巩固和加深对Java 编程的基础理论知识的理解,对java开发数据库系统有更深刻的认识,培养学生综合运用所学理论解决实际问题的能力,使学生成为具有扎实的计算机理论基础和较强的独立动手能力的复合型、应用型人才。 高考成绩管理系统包括两大模块: 1、 高考成绩录入。高考成绩录入包括成绩的添加、修改、编辑和自动 统计的功能。目前高考主要包括两各方面:文科和理科。文科成绩录入和理科成绩录入分别是两个不同的模块。 2、 高考成绩查询。成绩的查询也分为理科查询和文科查询两个部分。 成绩查询系统最好是应用准考证号进行查询,这是因为准考证号是全国统一的 每一个考生只有一个准考证号,这样就避免了同名同姓出现查询重复的问题。 见图1:所示,在这个系统中,包含4个模块:理科成绩录入、理科成绩查询、文科成绩录入和文科成绩查询。其中,理科成绩录入和文科成绩录入、理科成绩查询和文科成绩查询两个模块的设计思路基本一致。 3、建立理(文)科成绩录入和查询界面。建立一个理科数据库表,用来 记录 混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载 准考证号(作为这个数据库表的主键,唯一标识)、学生考号和姓名。另外在建立一个理科数据库表,用来记录学生姓名、考号之外的其他信息,并记录各科的成绩。同理文科的界面和理科的界面设计比较相似。 4、本系统查询与成绩统计。系统设计要求在考生查询的同时自动进行统计工作,这是一种人性化的需求,统计和查询只需要一个事件代码和一个执行动作即可完成。 3 高考信息管理系统 高考信息管理系统主界面 理理文文 科科科科 成成成成 绩绩绩绩 录查录查 入 询 入 询 图1 高考系统模块设计 二、高考信息管理系统数据库结构设计 1、建立文科数据表 建立文科数据表,如表1所示。 表1 文科主数据表的结构 字段名 字段类型 字段大小 说明 关于失联党员情况说明岗位说明总经理岗位说明书会计岗位说明书行政主管岗位说明书 cardID Bigint 8 准考证号 studentName Varchar 50 学生姓名 schoolBefore Varchar 50 考前学校 数据库结构设计如图2所示。该结构说明在数据表的结构创建时,设置了准考证号为关键字段,即在cardID的左边有一个钥匙的符号,是关键字的符号。 另外添加了学生姓名,还设计了该考生的考前学校,这样,当查询到该考号时就可以知道该生所在学校。 4 图2 文科数据库表 2、建立文科从数据表 从表的字段主要包括4个字段,科目序号、考试成绩、准考证号和考试科目,如表2、图3所示。 表2 文科从数据表 字段名 字段类型 字段大小 说明 subjectID Bigint 8 cardID Bigint 8 Subject Varchar 50 Achievement Int 4 subjectNameID Bigint 8 与考试科目相对应(数学 1;英 语 2;;语文 3;政治 4;历史 5) 图3 文科从数据表 5 在表中建立一个科目序号,主要显示个学生的科目排列,并将其按照关键字进行设置。另外,要求从表中的准考证号与主表中的准考证号与相互关联,需要在从表中为从表的准考证号建立关系。如图4所示。 图4 建立art和art2表之间的关系 3、理科数据表的设计 理科数据表的设计应该与理科表的设计方式基本上一致,在这里就不详细介绍了。唯一的区别就是在数据库中存储的数据不同,如高考文科为数学、英语、语文、政治、历史,理科考试科目为数学、英语、语文、物理、化学。 三、主控界面的设计 主界面主要用来调用其他界面,这个界面的主要作用是显示理科成绩录入、理科成绩查询、文科成绩录入、文科成绩查询4个界面,可以根据需要对其进行选择。它的基本结构如图5所示。 图5 主控界面图 6 1、放入控件与窗体布局 (1)在控件中放入一个jPanel1,将布局方式改为xyLayout。 (2)在控件中放入一个4个jLabel:jLabel1、jLabel2、jLabel3、jLabel4,主要是用来设计整个界面的布局。 (3)在控件中放入4个jRadioButton:rdbInputSanAcn(理科成绩录入)、rdbQueryScnAch(理科成绩查询)、rdbInputArtAch(文科成绩录入)、 rdbQueryArtAch(文科成绩查询) (4)添加鼠标单击事件rdbInputScnAch_mouseClicked(MouseEvent e)、 rdbQueryScnAch_mouseClicked(MouseEvent e) 、 rdbInputArtAch_mouseClicked(MouseEvent e)、 rdbQueryArtAch_mouseClicked(MouseEvent e)。 2、主控界面设计和事件发生代码 下面是主控界面设计属性以及事件发生代码 //显示理科成绩录入界面 void rdbInputScnAch_mouseClicked(MouseEvent e) { //调用理科成绩录入界面对话框 ScienceAchievement dlg = new ScienceAchievement(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //显示理科成绩查询界面 void rdbQqueryScnAch_mouseClicked(MouseEvent e) { //调用理科成绩查询界面对话框 ScienceQuery dlg = new ScienceQuery(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //显示文科成绩录入界面 7 void rdbInputArtAch_mouseClicked(MouseEvent e) { //调用文科成绩录入界面对话框 ArtsAchievement dlg = new ArtsAchievement(); …… } //显示文科成绩查询界面 void rdbQueryArtAch_mouseClicked(MouseEvent e) { //调用文科成绩查询界面对话框 ArtsQuery dlg = new ArtsQuery(); …… } 四、理科成绩录入系统设计 理科成绩录入窗体是承担整个录入过程的窗体,要将数据录入并保存在数据表中,就需要一系列的数据库相关空间将其连接起来。另外,在进行成绩录入时,增加了一个对话框进行成绩的录入(其准考证号为在界面中输入的值),这样就能够完成对理科成绩的录入。另外,还应该添加的控件进行属性设置。 理科成绩录入窗体设计如下: (1) 加入一个jPanel1,并将其设置为xyLayout1。 (2) 加入4个jLabel,用来布置整个窗体的布局。 (3) 在控件中加入3个jLabel控件:jLabel3、jLabel4、jLabel5,代表 的含义分别是“准考证号”、“学生姓名”、“考前学校”。 (4) 加入3个jTextField:jTextField1、jTextField2、jTextField3. (5) 在jLabel6中加入jButton1,将其文本标签设置为成绩录入。 (6) 加入数据库控件jdbTable1. (7) 加入数据库控件database1. (8) 加入数据库控件queryDataSet1. 如图6所示为理科成绩录入主界面 8 图6 理科成绩录入主界面 理科成绩录入模块的代码如下: database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); database1.setDatabaseName(""); queryDataSet1.setMetaDataUpdate(MetaDataUpdate.TABLENAME); queryDataSet1.setSchemaName("dbo"); queryDataSet1.setSort(new com.borland.dx.dataset.SortDescriptor("", new String[] {"cardID", "studentName", "schoolBefore"}, new boolean[] {true, false, false, }, null, 0)); queryDataSet1.setTableName("science"); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT * FROM science", null, true, Load.ALL)); jdbTable1.setDataSet(queryDataSet1); queryDataSet1.setColumns(new Column[] {column1, column3, column4}); getContentPane().add(panel1); void jButton1_actionPerformed(ActionEvent e) { ScienceAcn dlg = new ScienceAcn(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); queryDataSet1.refresh(); jdbTable1.setDataSet(queryDataSet1);} 9 在上述程序段中,语句ScienceAcn dlg = new ScienceAcn()的作用是调用一个 对话框,主要功能是输入考试的各科成绩。对话框的代码如下(对话框如图7 所示): 图7 理科成绩录入的对话框 database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); void jButton1_actionPerformed(ActionEvent e) { ScienceAchievement scienceAchievement = new ScienceAchievement() ; int cardID = scienceAchievement.cardID() ; String studentName = scienceAchievement.studentName() ; String studentBefore = scienceAchievement.studentBefore() ; int Math = Math() ; int English = English() ; int Chinese = Chinese() ; int Physics = Physics() ; int Chemistry = Chemistry() ; int MathID = 1 ; int EnglishID = 2 ; int ChineseID = 3 ; int PhysicsID = 4 ; int ChemistryID = 5 ; String MathName = "数学" ; String EnglishName = "英语" ; String ChineseName = "语文" ; String PhysicsName = "物理" ; String ChemistryName = "化学" ; Statement sql = database1.createStatement() ; 10 String stmt = "INSERT INTO [science] VALUES('"+cardID+"', '"+studentName+"' , '"+studentBefore+"')" ; String stmt1 = "INSERT INTO [science2] VALUES('"+cardID+"','"+MathID+"','"+MathName+"','"+Math+"')" ; String stmt2 = "INSERT INTO [science2] VALUES('"+cardID+"','"+EnglishID+"','"+EnglishName+"','"+English+"')" ; String stmt3 = "INSERT INTO [science2] VALUES('"+cardID+"','"+ChineseID+"','"+ChineseName+"','"+Chinese+"')" ; String stmt4 = "INSERT INTO [science2] VALUES('"+cardID+"','"+PhysicsID+"','"+PhysicsName+"','"+Physics+"')" ; String stmt5 = "INSERT INTO [science2] VALUES('"+cardID+"','"+ChemistryID+"','"+ChemistryName+"','"+Chemistry+"')" ; try{ sql.executeUpdate(stmt) ; sql.executeUpdate(stmt1) ; sql.executeUpdate(stmt2) ; sql.executeUpdate(stmt3) ; sql.executeUpdate(stmt4) ; sql.executeUpdate(stmt5) ; } catch(SQLException www){} }} 五、理科成绩查询模块的设计 录入成绩只是高考成绩管理的一部分,但是录入部分的内容仅仅是面向管理员,而高考信息系统的主要目的是让广大考生能够及时查询高考结果。录入部分并不是整个系统最重要的部分,重要的是对录入信息的开发利用,查询信息是一个重要的工具,因此,进行查询窗体的开发是很有必要的。。 理科成绩查询模块窗体属性及事件的设计如下: (1) 加入jPanel1,并设布局方式为xyLayout1.。 (2) 加入两个jLabel,对窗体进行整体布局。jLabel1的文本标题设置为 “理科成绩查询”;jLabel2在整体布局时只是起到装饰的作用。 (3) 加入一个jLabel3,文本标题为“准考证号”。 (4) 加入一个jTextField,将其命名为jtfCardID。 (5) 加入一个jButton,将其命名为jbnQuery,文本设置为“执行查询”。 (6) 加入一个jLabel4,将文本标题设置为“总成绩”。 (7) 加入一个jdbTextField1 (8) 加入一个jButton,将其命名为jbvExit。 11 (9) 加入一个数据库控件database1,用于连接数据库。 (10)加入一个数据库控件queryDataSet1,用于执行SQL语句。 (11)加入一个jdbTable1数据库控件。 理科成绩查询模块代码如下: //连接数据库(local) database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); void jbnQuery_actionPerformed(ActionEvent e) { //进行数据查询 try{ //获得准考证号 int cardID1 = Integer.parseInt(jtfCardID.getText().trim()); //查询学习成绩 queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT *FROM science2 where science2.cardID = '"+cardID1+"'", null, true, Load.ALL)); // queryDataSet1.setColumns(new Column[] {column2, column3, column4, column5, column1}); //加入到jdbTable1中 jdbTable1.setDataSet(queryDataSet1); //执行sum语句,获得成绩总分 queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT SUM(achievement) AS SUM_achievement FROM science2\n" + "where science2.cardID ='"+cardID1+"'", null, true, Load.ALL)); //在jdbTextField1中加入一列 jdbTextField1.setColumnName("SUM_achievement"); //把数据集加入到jdbTextField1中 jdbTextField1.setDataSet(queryDataSet2); } catch(Exception sql){ JOptionPane.showMessageDialog(this,"准考证不存在,请重试"); }} 六、文科成绩录入与查询窗体的设计 1、文科成绩录入窗体设计 (1)加入一个jPanel1,并将其设置为xyLayout1。 (2)加入4个jLabel,用来布置整个窗体的布局。 (3)在控件中加入3个jLabel控件:jLabel3、jLabel4、jLabel5,代表的含 义分别是“准考证号”、“学生姓名”、“考前学校”。 12 (4)加入3个jTextField:jTextField1、jTextField2、jTextField3. (5)在jLabel6中加入jButton1,将其文本标签设置为成绩录入。 (6)加入数据库控件jdbTable1. (7)加入数据库控件database1. (8)加入数据库控件queryDataSet1. 文科成绩录入模块的代码设计与理科成绩录入模块基本一致,在这里不再 详细叙述。 2、文科成绩查询窗体的开发 文科查询窗体与理科查询窗体一样,只是标签的标题和数据库控件的数据源不同而已,为保持案例的完整起见,下面进行简单说明。 文科成绩查询模块窗体属性及事件的设计如下: (1) 加入jPanel1,并设布局方式为xyLayout1.。 (2) 加入一个jLabel1,将文本设置为“文科成绩查询”。 (3) 加入两个jLabel,jLabel2、jLabel4用来作为界面布局。 (4) 加入一个jLabel3,文本标题为“准考证号”。 (5) 加入一个jTextField1。 (6) 加入一个jButton,文本设置为“执行查询”。 (7) 加入一个jLabel5,将文本标题设置为“总成绩”。 (8) 加入一个jdbTextField1 (9) 加入一个jButton,将其设置为“退出”。 3、文科成绩查询代码设计 文科成绩查询模块的代码设计与理科成绩查询模块功能基本一致 七、运行与调试 13 14 15 16 八、实验小结与心得体会 本案例通过实现一个高考管理系统;以及对数据库的查询、添加使读者更加深入理解JDBC技术。同时,要设计实现整个数据库的应用程序的类图,培养读者的设计能力。由于管理系统之间有相似性,因此熟悉了这一管理系统,读者在实践中在遇到相关管理系统的开发也相对容易了。 在这次试验中我了解了如何在java中编写程序代码将java程序语言同数据库连接起来,知道了如何利用java程序代码对数据库表中的内容进行增、删、 查、改等操作,也理解了程序中的一些函数代码,了解了有些系统函数在系统中的功能以及不同的数据库坏境当连接数据库时java程序代码也会相应的有所改 变,SQL2000与SQL2005使用时,java程序编码在连接数据库时就有细微差别。。例如:SQL2000 环境下: String driverName=”com.microsaft.jdbc.sqlserver.SQLServerDriver”; String dbURL=”jdbc:Microsoft:sqlServer://localhost:14433;DatabaseName=sample”; 在SQL2005环境下: String driverName=”com.microsaftsqlserver.SQLServerDriver”; String dbURL=”jdbc:sqlServer://localhost:14433;DatabaseName=sample”;而 database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));也是一种连接数据库的 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 。连接数据库前要先建立数据源,选择要处理的数据库。。 mouseClicked(MouseEvent e)是以个鼠标单击事件;queryDataSet1.refresh();为刷新数据集queryDataSet1;jdbTable1.setDataSet(queryDataSet1);表示为在 jdbTable1中显示数据集queryDataSet1;ScienceAchievement dlg=new ScienceAchievement();是调用理科成绩录入界面对话框;dlg.show();作用是将对象显示出来,如将理科成绩录入界面对话框显示出来;dispose();代表销毁窗口;trim()系统函数表示消除格。如:当输入的数据中有空格也能因将空格忽略而显示相应的数据。在源程序中因有些键单击后没反应,故做了些相应的修改。如:文科成绩录入对话框中jButton2(取消)键没反应,故添加了jButton响应事件 jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); 17 }}); void jButton2_actionPerformed(ActionEvent e) { cancel() ; } 因为该实验中用到了数据源(ODBC),故该程序中的一些代码必须做相应的改变。如 将程序中类似[info].[dbo].[science]的代码中的[info].[dbo].去掉,因为环境不能够识别。另外,在查询时不应该只查询特定的一项,应将源代码queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT SUM(achievement) AS SUM_achievement FROM info.dbo.art2\n" + "where art2.cardID = '10000001'", null, true, Load.ALL)); 改为 queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT SUM(achievement) AS SUM_achievement FROM art2\n" + "where art2.cardID = '"+cardID1+"'", null, true, Load.ALL)); 再此实验中遇到了一些问题,如在对文理科进行成绩录入时,出现异常。成绩录入主界 面中的数据无法传从到成绩录入对话框,输入的数据丢失,成绩录入主界面的数据为空值, 从而导致函数调用时,无法对空值转化为整形而出现异常。将一些关键字设为全局变量即可 解决此问题。 通过本案例的学习,是操作者强化了所学的知识,加强了动手能力的同时,了解相关的 业务,为后续工作打下了坚实的基础。 参考文献 1、黄晓东,java课程设计案例精编,中国水利水电出版社,2007。 2、崔晓静、严小舟,java语言程序设计,中国铁道出版社,2007.12 附录:部分源代码 package infomanagement; import java.awt.*; import javax.swing.*; import com.borland.jbcl.layout.*; import com.borland.dx.dataset.*; import com.borland.dbswing.*; import com.borland.dx.sql.dataset.*; import java.awt.event.*; public class ArtsAchievement extends JDialog { 18 private JPanel panel1 = new JPanel(); private BorderLayout borderLayout1 = new BorderLayout(); private JPanel jPanel1 = new JPanel(); private XYLayout xYLayout1 = new XYLayout(); private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JLabel jLabel4 = new JLabel(); private JLabel jLabel5 = new JLabel(); private JTextField jTextField1 = new JTextField(); private JTextField jTextField2 = new JTextField(); private JTextField jTextField3 = new JTextField(); private JLabel jLabel6 = new JLabel(); private JButton jButton1 = new JButton(); private JdbTable jdbTable1 = new JdbTable(); private Database database1 = new Database(); private QueryDataSet queryDataSet1 = new QueryDataSet(); public ArtsAchievement(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public ArtsAchievement() { this(null, "", false); } private void jbInit() throws Exception { panel1.setLayout(borderLayout1); jPanel1.setLayout(xYLayout1); jLabel1.setFont(new java.awt.Font("Dialog", 0, 23)); jLabel1.setForeground(Color.red); jLabel1.setBorder(BorderFactory.createEtchedBorder()); jLabel1.setText(" 文科成绩录入"); jLabel2.setBorder(BorderFactory.createEtchedBorder()); jLabel3.setText(" 准考证号"); jLabel4.setText(" 学生姓名"); jLabel5.setText(" 考前学校"); jLabel6.setBorder(BorderFactory.createEtchedBorder()); 19 jButton1.setText("成绩录入"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jdbTable1.setBorder(BorderFactory.createEtchedBorder()); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); jTextField1.setText("0"); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT * FROM art", null, true, Load.ALL)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel1, new XYConstraints(0, 0, 399, 48)); jPanel1.add(jLabel3, new XYConstraints(30, 50, 114, 21)); jPanel1.add(jLabel4, new XYConstraints(150, 50, 108, 23)); jPanel1.add(jLabel5, new XYConstraints(270, 50, 104, 23)); jPanel1.add(jLabel2, new XYConstraints(0, 46, 399, 76)); jPanel1.add(jTextField1, new XYConstraints(40, 81, 90, 20)); jPanel1.add(jTextField2, new XYConstraints(160, 81, 90, 20)); jPanel1.add(jTextField3, new XYConstraints(280, 81, 90, 20)); jPanel1.add(jLabel6, new XYConstraints(1, 119, 397, 50)); jPanel1.add(jButton1, new XYConstraints(280, 134, 90, 20)); jPanel1.add(jdbTable1, new XYConstraints(2, 172, 396, 215)); } public int cardID(){ int card = Integer.parseInt(jTextField1.getText().trim()) ; return card ; } public String studentName(){ return jTextField2.getText().trim().toString() ; } public String studentBefore(){ return jTextField3.getText().trim().toString(); } void jButton1_actionPerformed(ActionEvent e) { ArtAcn dlg = new ArtAcn(); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); 20 dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); queryDataSet1.refresh(); jdbTable1.setDataSet(queryDataSet1); } } package infomanagement; import java.awt.*; import javax.swing.*; import com.borland.jbcl.layout.*; import java.awt.event.*; import com.borland.dx.sql.dataset.*; import java.sql.* ; public class ArtAcn extends JDialog { private JPanel jPanel1 = new JPanel(); private XYLayout xYLayout1 = new XYLayout(); private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JTextField jTextField1 = new JTextField(); private JLabel jLabel4 = new JLabel(); private JTextField jTextField2 = new JTextField(); private JLabel jLabel5 = new JLabel(); private JTextField jTextField3 = new JTextField(); private JLabel jLabel6 = new JLabel(); private JTextField jTextField4 = new JTextField(); private JLabel jLabel7 = new JLabel(); private JTextField jTextField5 = new JTextField(); private JLabel jLabel8 = new JLabel(); private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private Database database1 = new Database(); public ArtAcn(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { 21 ex.printStackTrace(); } } public ArtAcn() { this(null, "", false); } private void jbInit() throws Exception { jPanel1.setLayout(xYLayout1); jLabel1.setForeground(Color.red); jLabel1.setBorder(BorderFactory.createEtchedBorder()); jLabel1.setText(" 文科科成绩录入"); jLabel2.setBorder(BorderFactory.createEtchedBorder()); jLabel3.setForeground(Color.red); jLabel3.setText(" 数学"); jLabel4.setForeground(Color.red); jLabel4.setText(" 英语"); jLabel5.setForeground(Color.red); jLabel5.setText(" 语文"); jLabel6.setForeground(Color.red); jLabel6.setText(" 政治"); jLabel7.setForeground(Color.red); jLabel7.setText(" 历史"); jLabel8.setBorder(BorderFactory.createEtchedBorder()); jButton1.setText("确定"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setText("取消"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton2.setText("取消"); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel1, new XYConstraints(0, 1, 400, 26)); jPanel1.add(jLabel3, new XYConstraints(20, 45, 90, 20)); jPanel1.add(jTextField1, new XYConstraints(140, 45, 120, 20)); 22 jPanel1.add(jLabel4, new XYConstraints(20, 90, 90, 20)); jPanel1.add(jTextField2, new XYConstraints(140, 90, 120, 20)); jPanel1.add(jLabel5, new XYConstraints(20, 135, 90, 20)); jPanel1.add(jTextField3, new XYConstraints(140, 135, 120, 20)); jPanel1.add(jLabel6, new XYConstraints(20, 180, 90, 20)); jPanel1.add(jTextField4, new XYConstraints(140, 180, 120, 20)); jPanel1.add(jLabel7, new XYConstraints(20, 225, 90, 20)); jPanel1.add(jTextField5, new XYConstraints(140, 225, 120, 20)); jPanel1.add(jLabel2, new XYConstraints(1, 26, 399, 275)); jPanel1.add(jLabel8, new XYConstraints(1, 255, 397, 44)); jPanel1.add(jButton1, new XYConstraints(200, 265, 90, 30)); jPanel1.add(jButton2, new XYConstraints(300, 265, 90, 30)); } public int Math(){ return Integer.parseInt(jTextField1.getText().trim()) ; } public int English(){ return Integer.parseInt(jTextField2.getText().trim()) ; } public int Chinese(){ return Integer.parseInt(jTextField3.getText().trim()) ; } public int Polity(){ return Integer.parseInt(jTextField4.getText().trim()) ; } public int History(){ return Integer.parseInt(jTextField5.getText().trim()) ; } void cancel(){ dispose() ; } void jButton2_actionPerformed(ActionEvent e) { cancel() ; } void jButton1_actionPerformed(ActionEvent e) { ScienceAchievement scienceAchievement = new ScienceAchievement() ; int cardID = scienceAchievement.cardID() ; String studentName = scienceAchievement.studentName() ; String studentBefore = scienceAchievement.studentBefore() ; int Math = Math() ; int English = English() ; int Chinese = Chinese() ; int Polity = Polity() ; 23 int History = History() ; int MathID = 1 ; int EnglishID = 2 ; int ChineseID = 3 ; int PolityID = 4 ; int HistoryID = 5 ; String MathName = "数学" ; String EnglishName = "英语" ; String ChineseName = "语文" ; String PolityName = "政治" ; String HistoryName = "化学" ; Statement sql = database1.createStatement() ; String stmt = "INSERT INTO [art] VALUES('"+cardID+"', '"+studentName+"' , '"+studentBefore+"')" ; String stmt1 = "INSERT INTO [art2] VALUES('"+cardID+"','"+MathID+"','"+MathName+"','"+Math+"')" ; String stmt2 = "INSERT INTO [art2] VALUES('"+cardID+"','"+EnglishID+"','"+EnglishName+"','"+English+"')" ; String stmt3 = "INSERT INTO [art2] VALUES('"+cardID+"','"+ChineseID+"','"+ChineseName+"','"+Chinese+"')" ; String stmt4 = "INSERT INTO [art2] VALUES('"+cardID+"','"+PolityID+"','"+PolityName+"','"+Polity+"')" ; String stmt5 = "INSERT INTO [art2] VALUES('"+cardID+"','"+HistoryID+"','"+HistoryName+"','"+History+"')" ; try{ sql.executeUpdate(stmt) ; sql.executeUpdate(stmt1) ; sql.executeUpdate(stmt2) ; sql.executeUpdate(stmt3) ; sql.executeUpdate(stmt4) ; sql.executeUpdate(stmt5) ; } catch(Exception www){} }} package infomanagement; import java.awt.*; import javax.swing.*; import com.borland.jbcl.layout.*; import com.borland.dbswing.*; import com.borland.dx.sql.dataset.*; import com.borland.dx.dataset.*; import java.awt.event.*; 24 public class ArtsQuery extends JDialog { private JPanel jPanel1 = new JPanel(); private XYLayout xYLayout1 = new XYLayout(); private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JTextField jTextField1 = new JTextField(); private JButton jButton1 = new JButton(); private JLabel jLabel4 = new JLabel(); private JdbTable jdbTable1 = new JdbTable(); private JLabel jLabel5 = new JLabel(); private JButton jButton2 = new JButton(); private JdbTextField jdbTextField1 = new JdbTextField(); private QueryDataSet queryDataSet1 = new QueryDataSet(); private Database database1 = new Database(); private QueryDataSet queryDataSet2 = new QueryDataSet(); private Column column1 = new Column(); public ArtsQuery(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public ArtsQuery() { this(null, "", false); } private void jbInit() throws Exception { jPanel1.setLayout(xYLayout1); jLabel1.setFont(new java.awt.Font("Dialog", 0, 23)); jLabel1.setForeground(Color.magenta); jLabel1.setBorder(BorderFactory.createEtchedBorder()); jLabel1.setText(" 文科科成绩查询"); jLabel2.setBorder(BorderFactory.createEtchedBorder()); jLabel3.setText("准考证号"); jButton1.setText("执行查询"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } 25 }); jLabel4.setBorder(BorderFactory.createEtchedBorder()); jdbTable1.setBorder(BorderFactory.createEtchedBorder()); jLabel5.setText("总成绩"); jButton2.setText("退出"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:local", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver")); column1.setColumnName("NewColumn1"); column1.setDataType(com.borland.dx.dataset.Variant.STRING); column1.setPreferredOrdinal(0); column1.setServerColumnName("NewColumn1"); column1.setSqlType(0); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(jLabel1, new XYConstraints(0, 1, 399, 53)); jPanel1.add(jLabel3, new XYConstraints(10, 68, 90, 20)); jPanel1.add(jTextField1, new XYConstraints(110, 68, 90, 20)); jPanel1.add(jLabel2, new XYConstraints(0, 53, 398, 49)); jPanel1.add(jButton1, new XYConstraints(290, 68, 90, 20)); jPanel1.add(jdbTable1, new XYConstraints(1, 104, 394, 153)); jPanel1.add(jLabel5, new XYConstraints(20, 270, 90, 20)); jPanel1.add(jButton2, new XYConstraints(290, 270, 90, 20)); jPanel1.add(jdbTextField1, new XYConstraints(110, 270, 90, 20)); jPanel1.add(jLabel4, new XYConstraints(-2, 105, 397, 202)); } void cancel(){ dispose() ; } void jButton2_actionPerformed(ActionEvent e) { cancel() ; } void jButton1_actionPerformed(ActionEvent e) { //进行数据查询 try{ //获得准考证号 int cardID1 = Integer.parseInt(jTextField1.getText().trim()); //查询学习成绩 26 queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT * FROM art2 where art2.cardID='"+cardID1+"'", null, true, Load.ALL)); //加入到jdbTable1中 jdbTable1.setDataSet(queryDataSet1); //执行sum语句,获得成绩总分 queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT SUM(achievement) AS SUM_achievement FROM art2\n" + "where art2.cardID = '"+cardID1+"'", null, true, Load.ALL)); //在jdbTextField1中加入一列 jdbTextField1.setColumnName("SUM_achievement"); //把数据集加入到jdbTextField1中 jdbTextField1.setDataSet(queryDataSet2); } catch(Exception www){ JOptionPane.showMessageDialog(this,"请重新输入准考证号"); } } } package infomanagement; import com.borland.dx.dataset.*; public class QueryDataSet1RowIterator { private RowIterator rowIterator = new RowIterator(); public QueryDataSet1RowIterator() { } void bind(DataSet dataset) throws DataSetException { rowIterator.bind(dataset);} void bind(ReadRow readRow) throws DataSetException { rowIterator.bind(readRow);} void bind(ReadWriteRow readWriteRow) throws DataSetException { rowIterator.bind(readWriteRow); } void bind(RowIterator ri) throws DataSetException { rowIterator.bind(ri);} public void first() throws DataSetException { rowIterator.first(); } public void last() throws DataSetException { rowIterator.last();} public boolean next() throws DataSetException { return rowIterator.next(); } public boolean prior() throws DataSetException { return rowIterator.prior();} public int getCardID() throws DataSetException { return rowIterator.getInt("cardID");} public void setCardID(int value) throws DataSetException { rowIterator.setInt("cardID", value);} 27 public String getStudentName() throws DataSetException { return rowIterator.getString("studentName"); } public void setStudentName(String value) throws DataSetException { rowIterator.setString("studentName", value);} public String getSchoolBefore() throws DataSetException { return rowIterator.getString("schoolBefore"); } public void setSchoolBefore(String value) throws DataSetException { rowIterator.setString("schoolBefore", value);} } package infomanagement; import javax.swing.UIManager; import java.awt.*; public class info { private boolean packFrame = false; //Construct the application public info() { Frame1 frame = new Frame1(); //Validate frames that have preset sizes //Pack frames that have useful preferred size info, e.g. from their layout if (packFrame) { frame.pack();} else { frame.validate();} //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true);} //Main method public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { e.printStackTrace();} new info(); } } 28
本文档为【JAVA程序设计课程设计报告_高考管理系统的开发(1)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_654168
暂无简介~
格式:doc
大小:376KB
软件:Word
页数:44
分类:
上传时间:2018-06-03
浏览量:12