import java.sql.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.event.*;
public class menu extends JFrame implements ActionListener {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:mry";
ResultSet rs = null;
Connection conn = null;
JPanel jp1 = new JPanel();
JButton jb1 = new JButton("查询学生信息");
JButton jb2 = new JButton("查询课程信息");
JButton jb3 = new JButton("录入学生信息");
JButton jb4 = new JButton("录入院系信息");
JButton jb5 = new JButton("录入教师信息");
JButton jb6 = new JButton("修改学生信息");
JButton jb7 = new JButton("修改院系信息");
JButton jb8 = new JButton("修改教师信息");
JButton jb9 = new JButton("查询选修了某课程的学生信息");
JButton jb10 = new JButton("查询未选修任何课程的学生信息");
JButton jb11 = new JButton("添加选课信息");
JButton jb12 = new JButton("删除院系信息");
JButton jb13 = new JButton("删除学生信息");
JButton jb14 = new JButton("删除教师信息");
public menu() {
setVisible(true);
//setSize(300, 250);
setResizable(false);
try {
Class.forName(sDBDriver);
} catch (java.lang.ClassNotFoundException e) {
System.err.print(e.getMessage());
}
this.add(jp1);
jp1.setLayout(null);
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
jp1.add(jb5);
jp1.add(jb6);
jp1.add(jb7);
jp1.add(jb8);
jp1.add(jb9);
jp1.add(jb10);
jp1.add(jb11);
jp1.add(jb12);
jp1.add(jb13);
jp1.add(jb14);
jb1.setBounds(60, 40, 240, 30);
jb2.setBounds(360, 40, 240, 30);
jb3.setBounds(60, 80, 240, 30);
jb4.setBounds(360, 80, 240, 30);
jb5.setBounds(60, 120, 240, 30);
jb6.setBounds(360, 120, 240, 30);
jb7.setBounds(60, 160, 240, 30);
jb8.setBounds(360, 160, 240, 30);
jb9.setBounds(60, 200, 540, 30);
jb10.setBounds(60, 240, 540, 30);
jb11.setBounds(60, 280, 240, 30);
jb12.setBounds(360, 280, 240, 30);
jb13.setBounds(60, 320, 240, 30);
jb14.setBounds(360, 320, 240, 30);
this.setTitle("主菜单");
this.setBounds(340, 240, 660, 420);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
jb6.addActionListener(this);
jb7.addActionListener(this);
jb8.addActionListener(this);
jb9.addActionListener(this);
jb10.addActionListener(this);
jb11.addActionListener(this);
jb12.addActionListener(this);
jb13.addActionListener(this);
jb14.addActionListener(this);
}
public void actionPerformed(ActionEvent f) {
try {
if (f.getSource() == jb1) {
this.setVisible(false);
new student_information();
}
else if (f.getSource() == jb2) {
this.setVisible(false);
new course_information();
}
else if (f.getSource() == jb3) {
this.setVisible(false);
new insert_student();
}
else if (f.getSource() == jb4) {
this.setVisible(false);
new insert_depart();
}
else if (f.getSource() == jb5) {
this.setVisible(false);
new insert_teacher();
}
else if (f.getSource() == jb6) {
this.setVisible(false);
new modify_student();
//修改学生信息
}
else if (f.getSource() == jb7) {
this.setVisible(false);
new modify_depart();
//修改院系信息
}
else if (f.getSource() == jb8) {
this.setVisible(false);
new modify_teacher();
//修改教师信息
}
else if (f.getSource() == jb9) {
this.setVisible(false);
new select_course(); //查询课程信息
}
else if (f.getSource() == jb10) {
this.setVisible(false);
new select_none(); //查询未选修任何课程的学生信息
}
else if (f.getSource() == jb11) {
this.setVisible(false);
new insert_xuanke();
}
else if (f.getSource() == jb12) {
this.setVisible(false);
new delete_depart(); //删除院系信息
}
else if (f.getSource() == jb13) {
this.setVisible(false);
new delete_student(); //删除学生信息
}
else if(f.getSource() == jb14) {
this.setVisible(false);
new delete_teacher(); //删除教师信息
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new menu();
}
}