JAVA学生成绩管理系统源码

合集下载

Java学生成绩查询系统

Java学生成绩查询系统

Chap 2实践2-1class Ex2_1{public static void main(String[] args) {float sum=0.0f,count=1.0f;for(int i=1;i<=20;++i){count=1.0f;for(int j=1;j<=i;++j)count*=j;sum+=count;}System.out.println("1+2!+3!+...+20!的值为:"+sum);}}实践2-2public class Ex2_2{public static void main(String[] args) {System.out.println("** 菲波拉挈数列的前20个数为:**");long f1 = 1, f2 = 1;for (int i = 1; i <= 10; i ++) {System.out.print(f1 + " " + f2 + " ");if (i % 2 == 0) {System.out.println();}f1 = f1 + f2;f2 = f2 + f1;}}}Chap 3实践3-1public class Student{ static String name="张三";static int age;public Student(){age=18;}public static void main(String args[]){System.out.println("姓名:"+name+",年龄:"+age);}}实践3-2class People{String name;People(String name){=name ; //对成员变量name 初始化}}class Student extends People{String stuID;Student(String name,String stuID){super(name) ; //对继承自父类的成员变量name初始化this.stuID=stuID ; //对成员变量stuID 初始化}}public class PeopleDemo{public static void main(String arg[]) {Student stu=new Student("张三","20080601") ; //定义对象System.out.println(+" "+stu.stuID) ; //输出对象的姓名和学号}}实践4-1public class Ex4_1 {String str;public Ex4_1(String str) {this.str = str;}int getlength(){return(str.length());}public static void main(String[] args) {Ex4_1 test = new Ex4_1("Hello");System.out.println("字符串是:"+test.str+" 长度为:"+test.getlength());}}实践4-2import java.util.*;import java.io.*;public class Ex4_2{public static void main(String[] args) {String str1 = new String();String str2 = new String();char ch;Scanner reader= new Scanner(System.in);System.out.println("输入字符串:");str1=reader.next(); //输入字符串System.out.println("输入要删除的字符:");str2=reader.next(); //输入穿要删除的字符,以字符串的形式输入ch=str2.charAt(0); //将字符串转换为字符str2=str1.replace(ch,' '); //用空格替代指定字符System.out.println("删除字符后的字符串"+str2);}}实践5-1public class Ex5_1{public static void main(String[] args) {try {int num[] = new int [10];System.out.println("num[10] is " + num[10]);}catch (Exception ex){System.out.println("Exception");}catch (RuntimeException ex){System.out.println("RuntimeException");}catch (ArithmeticException ex){System.out.println("ArithmeticException");}}}实践5-2public class Ex5_2{static double cal(double a, double b)throws IllegalArgumentException{ double value;if ( b == 0 ){ // 抛出IllegalArgumentException异常throw new IllegalArgumentException("除数不能为0");} else {value = a/b;if ( value < 0 ){ // 抛出IllegalArgumentException异常throw new IllegalArgumentException("运算结果小于0");}}return value;}public static void main(String[] args){ double result;try{ double a = Double.parseDouble(args[0]);double b = Double.parseDouble(args[1]);result = cal(a, b);System.out.println("运算结果是: " + result);}catch( IllegalArgumentException e ){ // 处理llegalArgumentException异常System.out.println("异常说明: "+e.getMessage());}}}Chap 6实践6-1import javax.swing.JFrame;import javax.swing.JLabel;import java.awt.Font;public class ex6_1 {public static void main(String[] args){JFrame frame=new JFrame();JLabel label1=new JLabel("JA V A Programming");Font font1=label1.getFont();font1=new Font("Courier", font1.getStyle(), 20); label1.setFont(font1);frame.getContentPane().add(label1);frame.pack();frame.setVisible(true);}}实践6-2import javax.swing.*;public class ex6_2 extends JFrame {public ex6_2(){super("第一个窗体");setDefaultCloseOperation(DISPOSE_ON_CLOSE);setSize(300, 150);setLocationRelativeTo(null);setVisible(true);}public static void main(String [] args){new ex6_2();}}Chap 7实践7-1import javax.swing.*;import java.awt.*;public class ex7_1 extends JFrame{ex7_1(){super("程序调试");setLayout(new FlowLayout());JButton jbtn1=new JButton("确定");JButton jbtn2=new JButton("取消");this.getContentPane().add(jbtn1);this.getContentPane().add(jbtn2);this.setVisible(true);this.setSize(300,150);}public static void main( String args[]) {new ex7_1 ();}}实践7-2import javax.swing.*;import java.awt.*;public class Ex7_2 extends JFrame{Panel pan0,pan1,pan2,pan3,pan4,pan5,pan6,pan7;Panel[] pan;String[] numStr={"1","2 ABC","3 DEF","4 GHI","5 JKL","6 MNO","7 PQRS","8 TUV","9 WXYZ","*","0","#"};Ex7_2(){super("手机键盘界面");pan=new Panel[8];for(int j=0;j<8;j++){pan[j]=new Panel();}ImageIcon icon=new ImageIcon("JM1.jpg");JLabel jlab1=new JLabel(icon,SwingConstants.CENTER);pan[5].add(jlab1);pan[0].setLayout(new GridLayout(4,3));for(int i=0;i<numStr.length;i++){pan[0].add(new JButton(numStr[i]));}pan[1].setLayout(new GridLayout(2,1));pan[1].add(new JButton("确定"));pan[1].add(new JButton("Call"));pan[2].setLayout(new GridLayout(2,1));pan[2].add(new JButton("取消"));pan[2].add(new JButton("ON/OFF"));pan[7].setLayout(new BorderLayout());pan[7].add("North",new JButton("上"));pan[7].add("South",new JButton("下"));pan[7].add("East",new JButton("右"));pan[7].add("West",new JButton("左"));pan[3].setLayout(new BorderLayout());pan[3].add(pan[7]);pan[4].setLayout(new GridLayout(1,3));pan[4].add(pan[1]);pan[4].add(pan[3]);pan[4].add(pan[2]);pan[6].setLayout(new GridLayout(3,1));pan[6].add(pan[5]);pan[6].add(pan[4]);pan[6].add(pan[0]);getContentPane().add(pan[6]);setVisible(true);setResizable(false);setLocation(400,150);pack();}public static void main(String[] args){new Ex7_2();}}Chap 8实践8-1import java.awt.event.*;import javax.swing.*;import java.awt.*;public class Ex8_1 extends JFrame implements WindowListener{ public Ex8_1(){Container con=this.getContentPane();con.setLayout(new FlowLayout());setBounds(0,0,200,200);setVisible(true);addWindowListener(this);}public static void main(String args[]){new Ex8_1();}public void windowClosing(WindowEvent e){System.out.println("The window closing");System.exit(0);}public void windowClosed(WindowEvent e){}public void windowOpened(WindowEvent e){System.out.println("window opened");}public void windowIconified(WindowEvent e){}public void windowDeiconified(WindowEvent e){}public void windowDeactivated(WindowEvent e) {System.out.println("The window deactived");}public void windowActivated(WindowEvent e){System.out.println("The window Activated");}}实践8-2import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Ex8_2 extends JFrame implements ActionListener {static Ex8_2 frm=new Ex8_2();static JButton btn1=new JButton("Yellow");static JButton btn2=new JButton("Green");public static void main(String args[]) {btn1.addActionListener(frm); // 把事件监听者frm向btn1注册btn2.addActionListener(frm); // 把事件聆听者frm向btn2注册frm.setTitle("Action Event");frm.setLayout(new FlowLayout(FlowLayout.CENTER));frm.setSize(200,150);frm.getContentPane().add(btn1);frm.getContentPane().add(btn2);frm.setVisible(true);}public void actionPerformed(ActionEvent e) {JButton btn=(JButton) e.getSource(); // 取得事件源对象if(btn==btn1) // 如果是按下btn1按钮frm.getContentPane().setBackground(Color.yellow);else if(btn==btn2) // 如果是按下btn2按钮frm.getContentPane().setBackground(Color.green);}}Chap 9实践9-1import javax.swing.*;import java.awt.*;import javax.swing.event.*;public class Ex9_1 extends JFrame implements ListSelectionListener{ String pro[] = {"软件专业", "网络专业", "动漫专业"};JPanel p1;JComboBox courseCombo;JList proList;Ex9_1(){proList = new JList(pro);proList.addListSelectionListener(this);courseCombo = new JComboBox();p1 = new JPanel();add(p1);p1.add(proList);p1.add(courseCombo);add(p1);setSize(400,200);setVisible(true);}public void valueChanged(ListSelectionEvent e){Object obj = e.getSource();if(obj==proList){courseCombo.removeAllItems();int nIndex = proList.getSelectedIndex();switch(nIndex ){case 0: courseCombo.addItem ("Java程序设计") ;courseCombo.addItem ("J2ee项目开发") ;break;case 1: courseCombo.addItem ("网络基本原理") ;courseCombo.addItem ("局域网技术与组网工程") ;courseCombo.addItem ("网络操作系统") ;break;case 2: courseCombo.addItem ("动漫造型") ;courseCombo.addItem ("漫画制作") ;break;}}}public static void main(String args[]){new Ex9_1();}}实践9-2import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Ex9_2 extends JFrame implements ItemListener{JRadioButton rad1=new JRadioButton("说法正确",false);JRadioButton rad2=new JRadioButton ("说法错误",false);ButtonGroup btg=new ButtonGroup ();JTextArea ta=new JTextArea(2,10);JTextField tf=new JTextField(4);JLabel lb=new JLabel("你的选择:");JPanel jp=new JPanel();String text="BoxLayout是由Swing 提供的布局管理器,功能上同GridBagLayout 一样强大,而且更加易用。

基于java的学生成绩管理系统的设计与实现

基于java的学生成绩管理系统的设计与实现

文章标题:基于Java的学生成绩管理系统的设计与实现一、引言学生成绩管理系统是学校管理系统中的重要组成部分,它可以帮助学校、老师和学生高效地管理和查询学生成绩信息。

基于Java的学生成绩管理系统的设计与实现是一个重要的课题,本文将从深度与广度两个角度来探讨这个主题。

二、学生成绩管理系统的基本要求学生成绩管理系统需要满足以下基本要求:1)能够实现学生信息的录入、修改和删除;2)能够实现课程信息的录入、修改和删除;3)能够实现成绩信息的录入、修改和删除;4)能够实现成绩的统计和排名功能;5)能够实现成绩的查询和导出功能。

三、基于Java的学生成绩管理系统的设计与实现1. 系统架构设计学生成绩管理系统可以采用三层架构设计,即用户界面层、业务逻辑层和数据访问层。

用户界面层负责与用户的交互,业务逻辑层负责处理业务逻辑,数据访问层负责与数据库进行交互。

2. 数据库设计数据库设计是学生成绩管理系统中的关键环节,需要设计学生信息表、课程信息表和成绩信息表,并建立它们之间的关联关系。

3. 功能模块设计学生成绩管理系统的功能模块包括学生信息管理、课程信息管理、成绩信息管理、成绩统计和排名以及成绩查询和导出功能。

四、基于Java的学生成绩管理系统的个人观点我认为基于Java的学生成绩管理系统的设计与实现不仅可以提高学校管理效率,也可以帮助老师更好地了解学生的学习情况,同时也能够让学生更方便地查询自己的成绩信息。

这个系统可以为学校管理和教学工作提供很大的便利,是非常值得推广和应用的。

五、总结与展望通过本文的探讨,我们深入了解了基于Java的学生成绩管理系统的设计与实现,从系统架构设计、数据库设计,功能模块设计等方面进行了全面的评估。

我们也共享了个人观点和理解。

希望本文能够为读者提供有价值的信息,同时也为学生成绩管理系统的推广应用提供一些借鉴和思路。

六、个人观点通过本次的撰写,我对基于Java的学生成绩管理系统的设计与实现有了更深入的了解,同时也对系统架构设计、数据库设计、功能模块设计等方面有了更全面的认识。

学生信息管理系统java课程设计(含源代码)

学生信息管理系统java课程设计(含源代码)

JAVA 程序设计 课程设计陈述宇文皓月课 题: 学生信息管理系统 姓 名: 学 号: 同组姓名: 专业班级: 指导教师: 设计时间:目 录1、需要实现的功能32、设计目的3 1、功能模块划分32、数据库结构描述43、系统详细设计文档64、各个模块的实现方法描述95、测试数据及期望结果11一、系统描述1、需求实现的功能1.1、录入学生基本信息的功能学生基本信息主要包含:学号、姓名、年龄、出生地、专业、班级总学分,在拔出时,如果数据库已经存在该学号,则不克不及再拔出该学号。

1.2、修改学生基本信息的功能在管理员模式下,只要在表格中选中某个学生,就可以对该学生信息进行修改。

评阅意见:评定成绩:指导老师签名:年 月 日1.3、查询学生基本信息的功能可使用“姓名”对已存有的学生资料进行查询。

1.4、删除学生基本信息的功能在管理员模式下,只要选择表格中的某个学生,就可以删除该学生。

1.5、用户登陆用分歧的登录权限可以进入分歧的后台界面,从而实现权限操纵。

1.6、用户登陆信息设置可以修改用户登陆密码2、设计目的学生信息管理系统是一个教育单位不成缺少的部分。

一个功能齐全、简单易用的信息管理系统不单能有效地减轻学校相关工作人员的工作负担,它的内容对于学校的决策者和管理者来说都至关重要。

所以学生信息管理系统应该能够为用户提供充足的信息和快捷的查询手段。

但一直以来人们使用传统人工的方式管理文件档案、统计和查询数据,这种管理方式存在着许多缺点,如:效率低、保密性差、人工的大量浪费;另外时间一长,将发生大量的文件和数据,这对于查找、更新和维护都带来了很多困难。

随着科学技术的不竭提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。

作为计算机应用的一部分,使用计算机对学校的各类信息进行管理,具有手工管理无法比较的优点。

例如:检索迅速、查询方便、效率高、可靠性好、存储量大、保密性好、寿命长、成本低等。

学生信息管理系统源代码

学生信息管理系统源代码

学生信息管理系统源代码import java.io.*;class StuInfo {public String name;public int number;public String sex;public String age;public String bir;public String email;public String addr;public String tel;public String getName() {return name;}public void setName(String name) { = name;}public int getNumber() {return number;}public void setNumber(int number) {this.number = number;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String getAge() {return age;}public void setAge(String age) {this.age = age;}public String getBir() {return bir;}public void setBir(String bir) {this.bir = bir;}public String getEmail() {return email;}public void setEmail(String email ) { this.email = email;}public String getAddr() {return addr;}public void setAddr(String addr) {this.addr = addr;}public String getTel() {return tel;}public void setTel(String tel) {this.tel = tel;}}public class Student {private static PrintStream out = System.out;private static String filename = "Stu.txt";private static int total = 0;private static int rt = 0;//recyle lengthprivate StuInfo[] stuInfos;private StuInfo[] recycle;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));//创建缓冲流public Student(){stuInfos = new StuInfo[11];}public void 信息录入(){BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));try{System.out.print("\n请输入学生信息(以0结束)\n");System.out.print("学号:\n");StuInfo stu = new StuInfo();stu.setNumber(Integer.parseInt(buf.readLine()));while(stu.getNumber()!=0) {System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());//添加其他输入信息stuInfos[total]=stu;total++;stu = new StuInfo();System.out.print("\n请输入下一个学生信息(以0结束)\n");System.out.print("姓名:\n");stu.setName(buf.readLine());}}catch(Exception e){out.print(e);}}public void 保存数据(){try{FileWriter fwr=new FileWriter(filename);BufferedWriter fw = new BufferedWriter(fwr);fw.write(total+"\r\n");for(int k=0;k<total;k++){//保存学生信息fw.write(stuInfos[k].getNumber()+"\r\n");fw.write(stuInfos[k].getName()+"\r\n");fw.write(stuInfos[k].getSex()+"\r\n");fw.write(stuInfos[k].getAge()+"\r\n");fw.write(stuInfos[k].getBir()+"\r\n");fw.write(stuInfos[k].getEmail()+"\r\n");fw.write(stuInfos[k].getAddr()+"\r\n");fw.write(stuInfos[k].getTel()+"\r\n");}fw.write(rt+"\r\n");for(int k=0;k<rt;k++){//保存回收站信息fw.write(recycle[k].getNumber()+"\r\n");fw.write(recycle[k].getName()+"\r\n");fw.write(recycle[k].getSex()+"\r\n");fw.write(recycle[k].getAge()+"\r\n");fw.write(recycle[k].getBir()+"\r\n");fw.write(recycle[k].getEmail()+"\r\n");fw.write(recycle[k].getAddr()+"\r\n");fw.write(recycle[k].getTel()+"\r\n");}fw.flush();fw.close();fwr.close();System.out.println("\n已保存数据!");}catch(Exception e){out.print(e);}}public void 读取数据(){try{FileReader fr = new FileReader(filename);BufferedReader bfr = new BufferedReader(fr); String buff = bfr.readLine();if(buff != null) {total = Integer.parseInt(buff);}else{total = 0;}StuInfo stu;for(int i=0; i<total;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine())); stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());stuInfos[i]=stu;}buff = bfr.readLine();if(buff!= null) {rt = Integer.parseInt(buff);}else{rt = 0;}for(int i=0; i<rt;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine()));stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());//补全recycle[i]=stu;}// bfr.flush();bfr.close();fr.close();System.out.println("读取成功");}catch(Exception e){out.print(e);}}public void 显示学生(StuInfo[] stus,int length){ try{out.println("----------");for(int i=0;i<length;i++){out.println("学号:"+stus[i].getNumber());out.println("姓名:"+stus[i].getName());out.println("性别:"+stus[i].getSex());out.println("年龄:"+stus[i].getAge());out.println("生日:"+stus[i].getBir());out.println("邮箱:"+stus[i].getEmail());out.println("地址:"+stus[i].getAddr());out.println("电话:"+stus[i].getTel());//输出其他内容.....out.println("----------");}System.out.println("请按任意键继续");buf.read();//}catch(Exception e){out.print(e);}}public void 姓名查询(String name){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(stuInfos[i].getName().equals(name)){result[r]=stuInfos[i];r++;}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生return;}else{显示学生(result, r);}}public void 学号查询(String number ){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(Integer.toString(stuInfos[i].getNumber()).equals(number)){result[r]=stuInfos[i];r++;//补全}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生}else{显示学生(result, r);}}public void 查找菜单(){//全字匹配int choice;try{do{System.out.println("查找界面");//System.out.println("1:按姓名查询");System.out.println("2:按学号查询");System.out.println("0:返回上级");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入姓名");//获得输入的姓名String name = buf.readLine();姓名查询(name);break;case 2:System.out.println("请输入学号");String number = buf.readLine();学号查询(number);//获得输入的学号break;default:System.out.println("对不起,出现异常!");//异常:7}}while(choice!=0);}catch(Exception e){out.print(e);}}public boolean 修改学生(int number) {boolean flag = false;try{for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number) {BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));StuInfo stu = new StuInfo();System.out.print("\n请输入学生信息\n");System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());stu.setNumber(number);stuInfos[i]=stu;System.out.print("修改完成啦!");//提示修改完成break;}}}catch(Exception e){out.print(e);}return flag;}public boolean 删除学生(int number){boolean flag = false;for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number){if(rt==0){recycle = new StuInfo[101];}recycle[rt]=stuInfos[i];for(;i<total-1;i++){stuInfos[i]=stuInfos[i+1];}total--;flag=true;break;}}return flag;}public void 删除页面(){System.out.print("删除页面");//请输入要删除的学号try{int choice;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));System.out.println("1:学生信息修改");System.out.println("2:学生信息删除");System.out.println("请输入您的选择(1--2)");//...choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入要修改的学号:");choice = Integer.parseInt(buf.readLine());修改学生(choice);break;case 2:System.out.println("请输入要删除的学号:");choice = Integer.parseInt(buf.readLine());删除学生(choice);break;//补充}/*if(删除学生(choice)){System.out.print("删除成功!");//删除成功}else{System.out.print("删除失败!");//删除失败}*/}catch(Exception e){out.print(e);}}public void showMenu() {try{int choice;do{System.out.println("学生管理系统主菜单界面");System.out.println("1:学生信息录入");System.out.println("2:学生信息浏览");System.out.println("3:学生信息查询");System.out.println("4:学生修改与删除");System.out.println("5:学生信息保存");System.out.println("6:学生信息读取");System.out.println("0:退出系统");System.out.println("请输入您的选择(0--6)");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:信息录入();//break;case 2://补全方法调用显示学生(stuInfos, total);break;case 3:查找菜单();break;case 4:删除页面();break;case 5:保存数据();break;case 6:读取数据();break;default:System.out.print("出现异常!"); //异常:7}}while(choice!=0);}catch(Exception e){System.out.println(e);}// TODO 自动生成的方法存根}public static void main(String[] args) {Student student = new Student();student.showMenu();}}. ..。

学生成绩管理系统源代码

学生成绩管理系统源代码

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <dos.h>#include<ctype.h>#include<conio.h>#include<stddef.h>#include<time.h>#define PRINT1 textcolor(12); cprintf("\r 请按任意键返回主菜单\n\r");textcolor(10); getch();clrscr(); break;int shoudsave=0;struct student /* 学生信息结构体定义*/{char num[10],name[20],cla[4];int score1,score2,score3,total,ave;};typedef struct node{struct student data;struct node *next;}Node,*L;void print1(){cprintf("\r======================================================================= =========");}void print2(){cprintf("\n\r 1.输入学生成绩信息在这里你可以按照提示输入学生的班级,学号,姓名及各科成绩.\n");cprintf("\n\r 2.注销学生成绩信息在这里你可以按照学号或姓名将某名学生的信息从本系统中删除.\n");cprintf("\n\r 3.查询学生成绩信息在这里你可以按照学号或姓名查询某一名学生的信息.\n");cprintf("\n\r 4.修改学生成绩信息在这里你可以按照提示修改某一名学生的学号,姓名及各科成绩.");cprintf("\n\r 5.学生成绩信息排序在这里你可以看到所有学生的各科成绩.\n"); cprintf("\n\r 6.学生成绩信息统计在这里本系统将为你显示所有科目的最高分及最低分所得学生.\n");cprintf("\n\r 7.显示学生成绩信息在这里你可以看到系统中所有学生的信息.\n"); cprintf("\n\r 8.保存学生成绩信息在这里你可以将学生你信息保存到内存中.\n"); cprintf("\n\r 9.帮助学生成绩信息在这里你可以获得帮助信息.\n");cprintf("\n\r 0.退出系统在这里选择是否保存后,你可以安全的退出本系统.\n\n\r ");}void menu(){cprintf("\n\r\xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");cprintf("\r\xba 学生信息导入\xba 学生信息处理\xba");cprintf("\r\xba____________________________________\xba___________________________ _______________\xba");cprintf("\r\xba 1-->输入学生成绩信息\xba 6-->学生成绩信息统计\xba");cprintf("\r\xba 2-->注销学生成绩信息\xba 7-->显示学生成绩信息\xba");cprintf("\r\xba 3-->查询学生成绩信息\xba 8-->保存学生成绩信息\xba");cprintf("\r\xba 4-->修改学生成绩信息\xba 9-->帮助学生成绩信息\xba");cprintf("\r\xba 5-->学生成绩信息排序\xba 0-->退出系统\xba");cprintf("\r\xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd\xcd\xcd\xcd\xc d\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\ xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");}void wrong(){cprintf("\n\r输入错误!请验证后重新输入.\n");}void notfind(){cprintf("\n\r该学生信息不存在!请验证后重新输入.\n");}void printc() /* 此函数用于输出中文格式*/{cprintf("\r学号姓名班级英语数学C语言总分平均分\n ");}void printe(Node *p) /* 此函数用于输出英文格式*/{cprintf("\r%-4s%-4s%4s%5d%5d%8d%5d%7d\n\r",p->data.num,p->,p->data.cla,p->dat a.score3,p->data.score2,p->data.score1,p->data.total,p->data.ave);}Node* Locate(L l,char findinfo[],char nameornum[]) /* 该函数用于定位连表中符合要求的接点,并返回该指针*/{Node *r;if(strcmp(nameornum,"num")==0)/* 按学号查询*/{r=l->next;while(r!=NULL){if(strcmp(r->data.num,findinfo)==0)return r;r=r->next;}}else if(strcmp(nameornum,"name")==0) /* 按姓名查询*/{r=l->next;while(r!=NULL){if(strcmp(r->,findinfo)==0)return r;r=r->next;}}return 0;}void input(L l) /* 增加学生*/{Node *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next;/* 将指针置于最末尾*/while(1){ cprintf("\r如果输入完毕,请按任意键返回主菜单\n");cprintf("\r如果你还想输入,请按y(yes)继续\n\r");scanf("%s",num);if(strcmp(num,"y")==0){ cprintf("请你输入学号:");scanf("%s",num); } else break;while(s){if(strcmp(s->data.num,num)==0){printf("\t学号为'%s'的学生已经存在,若要修改请你选择'4 修改'!\n",num);print1();printc();printe(s);print1();printf("\n");getch();return;}s=s->next;}p=(Node *)malloc(sizeof(Node));strcpy(p->data.num,num);cprintf("\r请你输入姓名:");scanf("%s",p->);getchar();cprintf("\r请你输入班级:");scanf("%s",p->data.cla);getchar();cprintf("\r请你输入c语言成绩(0-100):");scanf("%d",&p->data.score1);getchar();cprintf("\r请你输入数学成绩(0-100):");scanf("%d",&p->data.score2);getchar();cprintf("\r请你输入英语成绩(0-100):");scanf("%d",&p->data.score3);getchar();p->data.total=p->data.score3+p->data.score1+p->data.score2;p->data.ave=p->data.total / 3; /* 信息输入已经完成*/p->next=NULL;r=p;shoudsave=1;}}void query(L l) /* 查询学生信息*/{int select;char findinfo[20];Node *p;if(!l->next){cprintf("\n 没有信息可以查询!\n");return;}cprintf("\n1==>按学号查找\n\r2==>按姓名查找\n\r");scanf("%d",&select);if(select==1) /* 学号*/{cprintf("\r请你输入要查找的学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){cprintf(" 查找结果\n\r");print1();printc();printe(p);print1();}elsenotfind();}else if(select==2) /* 姓名*/{cprintf("\r请你输入要查找的姓名:");scanf("%s",findinfo);p=Locate(l,findinfo,"name");if(p){cprintf(" 查找结果\n\r");print1();printc();print1();}elsenotfind();}elsewrong();}void Delete(L l) /* 删除学生信息*/{int select;Node *p,*r;char findinfo[20];if(!l->next){cprintf("\n 没有信息可以删除!\n");return;}cprintf("\n1==>按学号删除\n\r2==>按姓名删除\n\r");scanf("%d",&select);if(select==1){cprintf("\r请你输入要删除的学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);cprintf("\n\r该学生已经成功删除!\n");shoudsave=1;}elsenotfind();}else if(select==2){cprintf("\r请你输入要删除的姓名:");scanf("%s",findinfo);p=Locate(l,findinfo,"name");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);cprintf("\n\r该学生已经成功删除!\n");shoudsave=1;}elsenotfind();}else wrong();}void modify(L l) /*修改学生信息*/{Node *p;char findinfo[20];if(!l->next){cprintf("\n\r没有信息可以修改!\n");return;}cprintf("\r请你输入要修改的学生学号:");scanf("%s",findinfo);p=Locate(l,findinfo,"num");if(p){cprintf("\r请你输入新学号(原来是%s):",p->data.num);scanf("%s",p->data.num);cprintf("\r请你输入新姓名(原来是%s):",p->);scanf("%s",p->);getchar();cprintf("\r请你输入新班级(原来是%s):",p->data.cla);scanf("%s",p->data.cla);cprintf("\r请你输入新的c语言成绩(原来是%d分):",p->data.score1);scanf("%d",&p->data.score1);getchar();cprintf("\r请你输入新的数学成绩(原来是%d分):",p->data.score2);scanf("%d",&p->data.score2);getchar();cprintf("\r请你输入新的英语成绩(原来是%d分):",p->data.score3);scanf("%d",&p->data.score3);p->data.total=p->data.score3+p->data.score1+p->data.score2;p->data.ave=p->data.total/3;cprintf("\n\r信息修改成功!\n");shoudsave=1;}elsenotfind();}void display(L l){/*显示全部学生信息*/int count=0;Node *p;p=l->next;if(!p){cprintf("\n\r 没有信息可以显示!\n");return;}cprintf(" 显示结果");print1();printc();while(p){ if(count%5==0) getch();printe(p);p=p->next;count++;}print1();cprintf("\n");}void Statistic(L l) /*统计学生信息*/{Node *pm_max,*pe_max,*pc_max,*pt_max,*pa_max; /* 用于指向分数最高的接点*/ Node *pm_min,*pe_min,*pc_min,*pt_min,*pa_min;Node *r=l->next;if(!r){cprintf("\n\r 没有信息可以统计!\n");return ;}pm_max=pe_max=pc_max=pt_max=pa_max=pm_min=pe_min=pc_min=pt_min=pa_min=r; while(r!=NULL){if(r->data.score1>=pc_max->data.score1)pc_max=r;if(r->data.score1<=pc_min->data.score1)pc_min=r;if(r->data.score2>=pm_max->data.score2)pm_max=r;if(r->data.score2<=pm_min->data.score2)pm_min=r;if(r->data.score3>=pe_max->data.score3)pe_max=r;if(r->data.score3<=pe_min->data.score3)pe_min=r;if(r->data.total>=pt_max->data.total)pt_max=r;if(r->data.total<=pt_min->data.total)pt_min=r;if(r->data.ave>=pa_max->data.ave)pa_max=r;if(r->data.ave<=pa_min->data.ave)pa_min=r;r=r->next;}cprintf("====================================统计结果====================================\n");cprintf("\r总分最高者: %-16s %d分\n",pt_max->,pt_max->data.total); cprintf("\r平均分最高者: %-16s %d分\n",pa_max->,pa_max->data.ave); cprintf("\r英语最高者: %-16s %d分\n",pe_max->,pe_max->data.score3); cprintf("\r数学最高者: %-16s %d分\n",pm_max->,pm_max->data.score2); cprintf("\rc语言最高者: %-16s %d分\n\r",pc_max->,pc_max->data.score1); cprintf("\r总分最低者: %-16s %d分\n",pt_min->,pt_min->data.total); cprintf("\r平均分最低者: %-16s %d分\n",pa_min->,pa_min->data.ave); cprintf("\r英语最低者: %-16s %d分\n",pe_min->,pe_min->data.score3); cprintf("\r数学最低者: %-16s %d分\n",pm_min->,pm_min->data.score2); cprintf("\rc语言最低者: %-16s %d分\n\r",pc_min->,pc_min->data.score1); print1();}void Sort(L l){L ll;Node *p,*rr,*s;ll=(L)malloc(sizeof(Node)); /* 用于做新的连表*/ll->next=NULL;if(l->next==NULL){cprintf("\n\r 没有信息可以排序!\n");return ;}p=l->next;while(p){s=(Node*)malloc(sizeof(Node)); /* 新建接点用于保存信息*/s->data=p->data;s->next=NULL;rr=ll;while(rr->next!=NULL && rr->next->data.total>=p->data.total)rr=rr->next;if(rr->next==NULL)rr->next=s;else{s->next=rr->next;rr->next=s;}p=p->next;}free(l);l->next=ll->next;cprintf("\n\r 排序已经完成!\n");}void Save(L l) /* */{FILE* fp;Node *p;int flag=1,count=0;fp=fopen("c:\\student","wb");if(fp==NULL){cprintf("\n\r 重新打开文件时发生错误!\n");exit(1);}p=l->next;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next;count++;}else{flag=0;break;}}if(flag){cprintf("\n\r 文件保存成功.(有%d条信息已经保存.)\n\r",count);shoudsave=0;}fclose(fp);}void main() /* */{L l; /* 链表*/FILE *fp; /* 文件指针*/int count=0 ,i,menu_select; /*菜单选择*/char ch ,creat;Node *p,*r;time_t it;clrscr();textmode(C80);window(1,1,80,25);textbackground(1); clrscr();textcolor(10);printf("\r 学生成绩管理系统");printf("\r -------扬州大学信息工程学院软件0902班") ;printf("\r 设计人员:李天鹏");l=(Node*)malloc(sizeof(Node));l->next=NULL;r=l;fp=fopen("c:\\student","rb");if(fp==NULL){cprintf("\n\r 该文件还未存在,是否需要创建?(y/n,Y/N)\n\r");scanf("%c",&creat);if(creat=='y'||creat=='Y'){fp=fopen("c:\\student","wb");}elseexit(0);}gotoxy(9,11); textcolor(12);cprintf("\n\r 文件已经打开,系统正在导入信息");for(i=0;i<6;i++){ cprintf(".");sleep(1);}textcolor(10);gotoxy(9,11); cprintf("\n ");while(!feof(fp)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp)) /* 将文件的内容放入接点中*/{p->next=NULL;r->next=p;r=p; /* 将该接点挂入连中*/count++;}}fclose(fp);/* 关闭文件*/gotoxy(1,3);cprintf("\n\r信息导入完毕,系统共导入%d条信息",count);sleep(1);while(1){ menu();textcolor(12);cprintf("\r现在时间: "); it=time(NULL);cprintf(ctime(&it));cprintf("\r左边数字对应功能选择,请按0--9选择操作:\n\r");textcolor(10) ;scanf("%d",&menu_select);if(menu_select==0){if(shoudsave==1){ getchar(); textcolor(128+12);cprintf("\n\r 信息已经改动,是否将改动保存到文件中(y/n Y/N)?\n\r"); scanf("%c",&ch);if(ch=='y'||ch=='Y')Save(l);}cprintf("\n\r 你已经成功退出学生成绩信息系统,欢迎下次继续使用!\n"); break;}switch(menu_select){case 1: clrscr(); input(l); clrscr(); break; /* 输入学生*/case 2: clrscr(); Delete(l); PRINT1 /* 删除学生*/case 3: clrscr(); query(l); PRINT1 /* 查询学生*/case 4: clrscr(); modify(l); PRINT1 /* 修改学生*/case 5: clrscr(); Sort(l); PRINT1case 6: clrscr(); Statistic(l); PRINT1case 7: clrscr(); display(l); PRINT1case 8: clrscr(); Save(l); PRINT1 /* 保存学生*/case 9: clrscr(); cprintf(" ==========帮助信息==========\n");print2(); PRINT1 ;default: wrong(); getchar(); break;}}}。

java课程设计题目及代码

java课程设计题目及代码

java课程设计题目及代码题目:学生成绩管理系统设计一个学生成绩管理系统,能够实现以下功能:1. 添加学生信息:录入学生的姓名、学号、性别等基本信息。

2. 添加学生成绩:录入学生的各门成绩,包括语文、数学、英语等课程。

3. 查找学生成绩:根据学号或姓名查找学生的成绩信息。

4. 修改学生成绩:根据学号或姓名修改学生的成绩信息。

5. 删除学生成绩:根据学号或姓名删除学生的成绩信息。

6. 统计学生成绩:统计全班学生的各门课程的平均分、最高分和最低分。

代码实现如下:```javaimport java.util.ArrayList;import java.util.HashMap;import java.util.Map;import java.util.Scanner;class Student {private String name;private String studentId;private String gender;private Map<String, Integer> scores;public Student(String name, String studentId, String gender) { = name;this.studentId = studentId;this.gender = gender;this.scores = new HashMap<>();}public String getName() {return name;}public String getStudentId() {return studentId;}public String getGender() {return gender;}public Map<String, Integer> getScores() {return scores;}public void addScore(String subject, int score) {scores.put(subject, score);}public void updateScore(String subject, int score) { scores.put(subject, score);}public void removeScore(String subject) {scores.remove(subject);}}class GradeManagementSystem {private ArrayList<Student> students;public GradeManagementSystem() {students = new ArrayList<>();}public void addStudent(String name, String studentId, String gender) {students.add(new Student(name, studentId, gender));}public Student findStudentById(String studentId) {for (Student student : students) {if (student.getStudentId().equals(studentId)) {return student;}}return null;}public Student findStudentByName(String name) {for (Student student : students) {if (student.getName().equals(name)) {return student;}}return null;}public void addScore(String studentId, String subject, int score) {Student student = findStudentById(studentId);if (student != null) {student.addScore(subject, score);}}public void updateScore(String studentId, String subject, int score) {Student student = findStudentById(studentId);if (student != null) {student.updateScore(subject, score);}}public void removeScore(String studentId, String subject) {Student student = findStudentById(studentId);if (student != null) {student.removeScore(subject);}}public void printStudentInfo(Student student) {System.out.println("姓名:" + student.getName());System.out.println("学号:" + student.getStudentId());System.out.println("性别:" + student.getGender());System.out.println("成绩:");for (Map.Entry<String, Integer> entry :student.getScores().entrySet()) {System.out.println(entry.getKey() + ":" +entry.getValue());}}public void printClassStatistics() {int chineseTotal = 0;int mathTotal = 0;int englishTotal = 0;int chineseMax = 0;int mathMax = 0;int englishMax = 0;int chineseMin = Integer.MAX_VALUE;int mathMin = Integer.MAX_VALUE;int englishMin = Integer.MAX_VALUE;for (Student student : students) {Map<String, Integer> scores = student.getScores();if (scores.containsKey("语文")) {int chineseScore = scores.get("语文");chineseTotal += chineseScore;chineseMax = Math.max(chineseMax, chineseScore);chineseMin = Math.min(chineseMin, chineseScore); }if (scores.containsKey("数学")) {int mathScore = scores.get("数学");mathTotal += mathScore;mathMax = Math.max(mathMax, mathScore);mathMin = Math.min(mathMin, mathScore);}if (scores.containsKey("英语")) {int englishScore = scores.get("英语");englishTotal += englishScore;englishMax = Math.max(englishMax, englishScore); englishMin = Math.min(englishMin, englishScore); }}int studentCount = students.size();double chineseAverage = (double) chineseTotal / studentCount;double mathAverage = (double) mathTotal / studentCount; double englishAverage = (double) englishTotal / studentCount;System.out.println("语文最高分:" + chineseMax);System.out.println("数学最高分:" + mathMax);System.out.println("英语最高分:" + englishMax);System.out.println("语文最低分:" + chineseMin);System.out.println("数学最低分:" + mathMin);System.out.println("英语最低分:" + englishMin);System.out.println("语文平均分:" + chineseAverage); System.out.println("数学平均分:" + mathAverage); System.out.println("英语平均分:" + englishAverage); }}public class Main {public static void main(String[] args) {GradeManagementSystem system = new GradeManagementSystem();// 添加学生信息system.addStudent("张三", "001", "男");system.addStudent("李四", "002", "女");system.addStudent("王五", "003", "男");// 添加学生成绩system.addScore("001", "语文", 90);system.addScore("001", "数学", 85);system.addScore("001", "英语", 92);system.addScore("002", "语文", 80);system.addScore("002", "数学", 75);system.addScore("002", "英语", 88);system.addScore("003", "语文", 95);system.addScore("003", "数学", 90);system.addScore("003", "英语", 97);// 查找学生成绩Student student = system.findStudentById("001"); if (student != null) {system.printStudentInfo(student);}// 修改学生成绩system.updateScore("002", "数学", 78);student = system.findStudentById("002");if (student != null) {system.printStudentInfo(student);}// 删除学生成绩system.removeScore("003", "语文");student = system.findStudentById("003");if (student != null) {system.printStudentInfo(student);}// 统计学生成绩system.printClassStatistics();}}```这是一个简单的学生成绩管理系统,通过添加学生信息、添加学生成绩、查找学生成绩、修改学生成绩、删除学生成绩和统计学生成绩等功能,可以对学生的成绩进行管理和操作。

基于JAVA的学生成绩管理系统的设计与实现(含源文件)

基于JAVA的学生成绩管理系统的设计与实现(含源文件)

基于JAVA的学生成绩管理系统的设计与实现摘要:本文按照目前流行的B/S体系结构模式,结合现有的学生成绩管理系统的现状,采用SQL Server 2000数据库和JAVA技术,设计开发了学生成绩管理系统系统,本系统分为前台页面和后台管理两大部分,主要实现成绩查询、成绩删除、成绩添加、成绩修改四大主体功能。

在细节方面,着重考虑了用户添加成绩、成绩查询两方面的简易操作,力求为客户带来方便。

关键词:B/S模式;JA V A;SQL ServerAbstract:This according to the popular B / S architecture model, combined with the current status of student achievement management system using SQL Server 2000 database and JAVA technology, design and development of student achievement management system, the system is divided into front page and back office management two parts, the main accomplishment query results to delete, add scores, results modify the four main functions. In detail, the focus to consider the user to add results, performance query both easy to operate, and strive to bring convenience for customers.Key words:B/S mode;JA V A;SQL Server近年来,随着高校的扩招,运用常规的方法对学生成绩的管理变得越来越困难,因此学校迫切的需要一种高效的系统来帮助其管理学生的成绩。

[工学]学生信息管理系统完整源码

[工学]学生信息管理系统完整源码

学生信息管理系统完整源代码注:本系统采用C/S结构,运用Java GUI知识编写,数据库为SQL SERVER 2005,没有采用典型的三级框架结构,所以代码有冗余,仅供参考。

一、数据表及数据源首先创建数据库,包含数据表如下:数据库创建完成后,新建一个名为SIMS的数据源,不会建数据源的同学可以在去搜索创建数据源的详细步骤,这里的数据名称一定要为SIMS,否则在以后程序连接数据库的语句中会出现错误。

二、操作演示三、代码部分创建Java工程,创建名称为SIMS的包,一下Java类均包含在一个包内。

1.登录界面package SIMS;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.text.SimpleDateFormat;import java.util.*;import java.util.Date;public class login extends JFrame implements ActionListener{String userID; //保留用户输入IDString password; //保留用户输入passwordJLabel jlID=new JLabel("用户ID:"); //使用文本创建标签对象 JLabel jlPwd=new JLabel("密码:");JTextField jtID=new JTextField(); //创建ID输入框JPasswordField jpPwd=new JPasswordField(); //创建密码输入框ButtonGroup bg=new ButtonGroup(); //创建ButtonGroup组件对象JPanel jp=new JPanel(); //创建Panel容器JLabel jl=new JLabel();JRadioButton jrb1=new JRadioButton("管理员");JRadioButton jrb2=new JRadioButton("教师");JRadioButton jrb3=new JRadioButton("学生",true);JButton jb1=new JButton("登录");JButton jb2=new JButton("重置");public login(){this.setLayout(null); //设置窗口布局管理器this.setTitle("学生信息管理系统"); //设置窗口标题this.setBounds(200,150,500,300); //设置主窗体位置大小和可见性this.setVisible(true); //设置窗口的可见性this.setResizable(false);jlID.setBounds(150,60,100,20); //设置ID框属性jtID.setBounds(220,60,100,20); //设置ID输入框属性jlPwd.setBounds(150,90,100,20); //设置密码框属性jpPwd.setBounds(220,90,100,20); //设置密码输入框属性jp.setBounds(35,120,400,250); //设置JPanel容器属性jb1.setBounds(160,170,60,20); //设置登录按钮属性jb2.setBounds(250,170,60,20); //设置取消按钮属性jb1.addActionListener(this); //设置登录按钮监听器jb2.addActionListener(this); //设置取消按钮监听器jl.setBounds(340,75,130,20); //设置提示框属性bg.add(jrb1); //将所有空间加入窗体bg.add(jrb2);bg.add(jrb3);this.add(jlID);this.add(jlPwd);this.add(jtID);this.add(jpPwd);this.add(jb1);this.add(jb2);this.add(jl);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);this.add(jp);centerShell(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(( (screenWidth - shellWidth) / 2),((screenHeight - shellHeight) / 2) );}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(userID);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入IDpassword=jpPwd.getText(); //获取用户输入密码if(e.getSource()==jb1){ //处理登录事件if(userID.equals("") || password.equals("")){jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("请输入用户ID和密码");}else{Connection con=null;try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"","");//获取连接字符串Statement stat=con.createStatement();if(jrb1.isSelected())//如果登录选中的管理员{ResultSet rs=stat.executeQuery("select * from Admin"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectAdmin_Pwd,Admin_Name from Admin where Admin_ID='"+userID+"'");//从表Admin获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new admin(rss.getString(2));//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb2.isSelected()){ResultSet rs=stat.executeQuery("select * from Teacher_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectTea_Pwd,Tea_Names from Teacher_Info where Tea_ID='"+userID+"'");//从表Teacher_Info获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new teacher(rss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb3.isSelected()){ResultSet rs=stat.executeQuery("select * from Student_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rsss=stat.executeQuery("selectStu_Pwd,Stu_Name from Student_Info where Stu_ID='"+userID+"'");//从表Student_Info获取信息while(rsss.next()){String str=rsss.getString(1);if(str.equals(password)){new student(rsss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}}catch(Exception ex){ex.getStackTrace();}finally{try{con.close();}catch(Exception exc){exc.printStackTrace();}}}}else if(e.getSource()==jb2){ //处理登录事件jtID.setText("");jpPwd.setText("");jrb3.setSelected(true);jl.setText("");}}public static void main(String[] args){new login();}}2.添加课程package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_course extends JFrame implements ActionListener{ static add_course ss;String courseID=""; //课程名String coursename=""; //课程名String count=""; //课时JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlcoursename=new JLabel("课程名:");JLabel jlcount=new JLabel("课时:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtcoursename=new JTextField();JTextField jtcount=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_course(){ //添加教师账号信息this.setTitle("添加课程信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(title);this.add(jlcoursename);this.add(jlcount);this.add(jtcourseID);this.add(jtcoursename);this.add(jtcount);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加课程信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlcoursename.setBounds(180,140,100,20);jlcount.setBounds(180,200,100,20);jtcourseID.setBounds(250,80,140,20);jtcoursename.setBounds(250,140,140,20);jtcount.setBounds(250,200,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容coursename=jtcoursename.getText();count=jtcount.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || coursename.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){warning.setText("课程ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!count.equals("")){temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name,Course_Count)values('"+courseID+"','"+coursename+"','"+count+"')");}else{temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name) values('"+courseID+"','"+coursename+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");warning.setText("");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtcourseID.setT ext("");jtcoursename.setText("");jtcount.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}}3.添加学生package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_student extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("学号:"); //创建文本框对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField();JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_student(){this.setTitle("添加学生账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加学生账号信息");title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20);submit.addActionListener(this);reset.addActionListener(this);this.setSize(600,400);centerShell(this);this.setVisible(true);this.setResizable(false); //设置窗体不可变大小this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){ //判断是否已输入必填信息warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否相同warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Stu_ID from Student_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd) values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){ //重置所有控件warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}//public static void main(String args[]){// new add_student();//}}4.添加教师package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_teacher extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("教工号:"); //使用文本框创建标签对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField(); //创建文本框对象JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_teacher(){ //添加教师账号信息this.setTitle("添加教师账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加教师账号信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否一致warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Tea_ID from Teacher_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd)values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}// public static void main(String[] args){// new add_teacher();// }}5.添加授课信息package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_tc extends JFrame implements ActionListener{static add_tc ss;String courseID=""; //课程名String teachername=""; //课程名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlteachername=new JLabel("教师号:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtteachername=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_tc(){ //添加授课信息this.setTitle("添加授课信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(jlteachername);this.add(title);this.add(jtcourseID);this.add(jtteachername);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加授课信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlteachername.setBounds(180,140,100,20);jtcourseID.setBounds(250,80,140,20);jtteachername.setBounds(250,140,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,250,60,20);reset.setBounds(300,250,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容teachername=jtteachername.getText();int temp=0,flag1=0,flag2=0,flag3=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || teachername.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){flag1=1; //判断课程ID存在break;}}ResultSet rss=stat.executeQuery("select Tea_ID fromTeacher_Info");while(rss.next()){if(rss.getString(1).equals(teachername)){flag2=1; //判断教师ID存在break;}}if(flag1!=1){warning.setText("课程ID不存在");}else if(flag2!=1){warning.setText("教师ID不存在");}ResultSet rsss=stat.executeQuery("select Course_ID,T ea_ID from tc");while(rsss.next()){if(rsss.getString(1).equals(courseID) &&rsss.getString(2).equals(teachername)){flag3=1;warning.setText("授课信息重复");。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
int i=0 ; String sql1=null,sql2=null,update=null; String url="jdbc:mysql://localhost:3306/学生成绩系统";
Connection con; Statement stmt; try{ Class.forName("org.gjt.mm.mysql.Driver"); }catch(ng.ClassNotFoundException e1){ System.err.println("ClassNotFoundException:"+e1.getMessage()); }
String sele="select * from 学 生 成 绩 表 where 学 号 ='"+num1+"' and 课 程 名
='"+num2+"'";
ResultSet rs=stmt.executeQuery(sele);
if(rs.next()){
JOptionPane.showMessageDialog(this, "已有该条记录,请核实!");
VALUES
('"+t1.getText()+"','"+t2.getText()+"','"+
t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"')";
String num1=t1.getText();
String num2=t1.getText();
and 课程名='"+num3+"'";
ResultSet rs=stmt.executeQuery(sql1);
if(rs.next()){
stmt.executeUpdate(sql2);
JOptionPane.showMessageDialog(this, "删除成功!");
}
else{
JOptionPane.showMessageDialog(this, "没有此条记录!请重新输入");
='"+num3+"'";
con=DriverManager.getConnection(url,"root","123");
stmt=con.createStatement();
sql1="select * from 学生成绩表 where 学号='"+num1+"' and 姓名='"+num2+"'
gbc.gridx=1;gbc.gridy=2; gbc.insets=new Insets(2,5,2,5); gbL.setConstraints(pa2,gbc); add(pa2);
btu1=new JButton("确定"); btu1.addActionListener(this); btu2=new JButton("退出"); btu2.addActionListener(this); pa4=new JPanel(); pa4.add(btu1); pa4.add(btu2); gbc.gridx=1;gbc.gridy=4;
String sql1=null,sql2=null; String url="jdbc:mysql://localhost:3306/学生成绩系统";
Connection con; Statement stmt; try{ Class.forName("org.gjt.mm.mysql.Driver"); }catch(ng.ClassNotFoundException e1){ System.err.println("ClassNotFoundException:"+e1.getMessage()); }
}Байду номын сангаас
t1.setText("");
stmt.close();
con.close();
}catch(SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
}
}
}}
文件 entry.java 代码
import java.awt.*; import java.awt.event.*; import java.sql.*; import javax.swing.*; class entry extends JFrame implements ActionListener{
if(e.getSource()==but1){
//删除----------------------------
try{
String num1=t1.getText();
String num2=t2.getText();
String num3=t3.getText();
sql2="delete from 学 生 成 绩 表 where 学 号 ='"+num1+"'and 课 程 名
int flag=1; String user,pass; JPanel pa; JLabel lab1,lab2; JTextField tf1; JPasswordField tf2; JButton btu1,btu2; JPanel pa1,pa2,pa4; entry(){ super("学生成绩管理系统"); setBounds(400,200,400,300); GridBagLayout gbL=new GridBagLayout(); GridBagConstraints gbc=new GridBagConstraints(); setLayout(gbL);
stmt.close();
con.close();
}catch(SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
}
}
}
}
文件 deletemessage.java 代码
import java.awt.*; import java.awt.event.*; import java.sql.*; import java.util.*; import javax.swing.*; import javax.swing.table.*; class deletemessage extends JFrame implements ActionListener{
JTextField t1,t2,t3,t4,t5; JTable table; JButton but1; JLabel lab1,lab2,lab3,lab4,lab5; JPanel p1; addmessage(){
super("增加"); setBounds(350,100,470,400); setLayout(new GridLayout(1,1,10,10)); p1=new JPanel(); lab1=new JLabel("学号"); t1=new JTextField(10); lab2=new JLabel("姓名"); t2=new JTextField(10); lab3=new JLabel("课程名"); t3=new JTextField(10); lab4=new JLabel("状态"); t4=new JTextField(10); lab5=new JLabel("成绩"); t5=new JTextField(10); but1=new JButton("添加"); but1.addActionListener(this); p1.add(lab1); p1.add(t1); p1.add(lab2); p1.add(t2); p1.add(lab3); p1.add(t3); p1.add(lab4); p1.add(t4); p1.add(lab5); p1.add(t5); p1.add(but1); add(p1); setVisible(true); } public void actionPerformed(ActionEvent e){
gbc.fill=GridBagConstraints.HORIZONTAL; gbc.anchor=GridBagConstraints.CENTER; lab1=new JLabel("请输入帐号"); lab2=new JLabel("请输入密码"); tf2=new JPasswordField(10);
if(e.getSource()==but1){
//添加-------------------
try{
con=DriverManager.getConnection(url,"root","123");
相关文档
最新文档