import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.sql.*;
import java.util.Vector;
public class AdmPanel extends JPanel implements ActionListener,ItemListener,MouseListener
{
private static final long serialVersionUID = 1L;//添加默认序列号
JButton b1,b2,b3,b4,b5,b6;
JPanel p1,p2,pCenter;
CardLayout card=null;
JTextField t1=new JTextField(10),
t2=new JTextField(10),
t3=new JTextField(10),
tt1=new JTextField(10),
tt2=new JTextField(10),
tt3=new JTextField(10);
ButtonGroup sex1=new ButtonGroup(),
sex2=new ButtonGroup();
JRadioButton radio1=new JRadioButton("男",true),
radio2=new JRadioButton("女");
JRadioButton r1=new JRadioButton("男",true),
r2=new JRadioButton("女");
JComboBox year,month,date,yy,mm,dd,post;
JTable table1,table2;
Vector<String> vectorColName1=new Vector<String>(),
vectorColName2=new Vector<String>();
Vector<Vector<String>> vector1=new Vector<Vector<String>>(),
vector2=new Vector<Vector<String>>();
DefaultTableModel model1=new DefaultTableModel(vectorColName1,0){
private static final long serialVersionUID = 1L;//添加默认序列号
public boolean isCellEditable(int row, int column)
{
return false;
}
};
DefaultTableModel model2=new DefaultTableModel(vectorColName2,0){
private static final long serialVersionUID = 1L;//添加默认序列号
public boolean isCellEditable(int row, int column)
{
return false;
}
};
AdmPanel()
{
setLayout(new BorderLayout());
t1=new JTextField(10);
t2=new JTextField(10);
t3=new JTextField(10);
tt1=new JTextField(10);
tt2=new JTextField(10);
tt3=new JTextField(10);
sex1.add(radio1);
sex1.add(radio2);
sex2.add(r1);
sex2.add(r2);
year=new JComboBox();
month=new JComboBox();
date=new JComboBox();
yy=new JComboBox();
mm=new JComboBox();
dd=new JComboBox();
post=new JComboBox();
post.addItem("助教");
post.addItem("讲师");
post.addItem("副教授");
post.addItem("教授");
for(int i=1980;i<1995;i++)
year.addItem(i);
for(int i=1;i<=12;i++)
month.addItem(i);
for(int i=1;i<=31;i++)
date.addItem(i);
for(int i=1950;i<1995;i++)
yy.addItem(i);
for(int i=1;i<=12;i++)
mm.addItem(i);
for(int i=1;i<=31;i++)
dd.addItem(i);
year.addItemListener(this);
month.addItemListener(this);
yy.addItemListener(this);
mm.addItemListener(this);
post.addItemListener(this);
b1=new JButton("学生信息管理");
b2=new JButton("教师信息管理");
b3=new JButton("输入");
b4=new JButton("删除");
b5=new JButton("输入");
b6=new JButton("删除");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
JPanel p0=new JPanel();
p0.add(b1);
p0.add(b2);
pCenter=new JPanel();
card=new CardLayout();
pCenter.setLayout(card);
p1=createStuPanel();
p2=createTeaPanel();
pCenter.add("学生信息管理",p1);
pCenter.add("教师信息管理",p2);
add(p0,BorderLayout.NORTH);
add(pCenter,BorderLayout.CENTER);
}
private JPanel createStuPanel()
{
JPanel p=new JPanel();
JScrollPane p1;
JPanel p2=new JPanel();
p.setLayout(new GridLayout(2,1));
SqlManager DBm=SqlManager.createInstance();//单态模式获取实例
DBm.connectDB();
String sql="exec ProcAllStu";
ResultSet rs=DBm.executeQuery(sql);
vectorColName1.addElement("学号");
vectorColName1.addElement("姓名");
vectorColName1.addElement("性别");
vectorColName1.addElement("生日");
vectorColName1.addElement("班级");
model1.setDataVector(vector1,vectorColName1);
table1=new JTable(model1);
table1.addMouseListener(this);
p1=new JScrollPane(table1);
p.add(p1);
try{
while(rs.next()){
Vector<String> rec_vector=new Vector<String>(); //从结果集中取数据放入向量rec_vector中
rec_vector.addElement(rs.getString(1));
rec_vector.addElement(rs.getString(2));
rec_vector.addElement(rs.getString(3));
rec_vector.addElement(rs.getString(4));
rec_vector.addElement(rs.getString(5));
vector1.addElement(rec_vector); //向量rec_vector加入向量vect中
}
//tm.fireTableStructureChanged();//更新表格,显示向量vect的内容
rs.close();
}catch(SQLException e){
e.printStackTrace();
}
DBm.closeDB();
//构造p2
Box base=Box.createHorizontalBox(),
boxleft=Box.createVerticalBox(),
boxright=Box.createVerticalBox();
JPanel pp1=new JPanel(),
pp2=new JPanel(),
pp3=new JPanel(),
pp4=new JPanel(),
pp5=new JPanel(),
pp6=new JPanel(),
psex=new JPanel(),
pbirth=new JPanel();
psex.add(radio1);
psex.add(radio2);
pbirth.add(year);
pbirth.add(month);
pbirth.add(date);
pp1.add(new JLabel("学生编号:"));
pp1.add(t1);
pp2.add(new JLabel("学生姓名:"));
pp2.add(t2);
pp3.add(new JLabel("学生性别:"));
pp3.add(psex);
pp4.add(new JLabel("学生生日:"));
pp4.add(pbirth);
pp5.add(new JLabel("所在班级:"));
pp5.add(t3);
pp6.add(b3);
pp6.add(b4);
boxleft.add(Box.createVerticalStrut(30));
boxleft.add(pp1);
boxleft.add(Box.createVerticalStrut(20));
boxleft.add(pp2);
boxleft.add(Box.createVerticalStrut(20));
boxleft.add(pp3);
boxright.add(Box.createVerticalStrut(20));
boxright.add(pp4);
boxright.add(Box.createVerticalStrut(20));
boxright.add(pp5);
boxright.add(Box.createVerticalStrut(20));
boxright.add(pp6);
base.add(boxleft);
base.add(Box.createHorizontalStrut(80));
base.add(boxright);
p2.add(base);
p.add(p2);
return p;
}
private JPanel createTeaPanel()
{
JPanel p=new JPanel();
JScrollPane p1;
JPanel p2=new JPanel();
p.setLayout(new GridLayout(2,1));
SqlManager DBm=SqlManager.createInstance(); //单态模式获取实例
DBm.connectDB();
String sql="exec ProcAllTea";
ResultSet rs=DBm.executeQuery(sql);
vectorColName2.addElement("教师编号");
vectorColName2.addElement("教师姓名");
vectorColName2.addElement("教师性别");
vectorColName2.addElement("生日");
vectorColName2.addElement("职称");
vectorColName2.addElement("所在院系");
model2.setDataVector(vector2,vectorColName2);
table2=new JTable(model2);
table2.addMouseListener(this);
p1=new JScrollPane(table2);
p.add(p1);
try{
while(rs.next()){
Vector<String> rec_vector=new Vector<String>(); //从结果集中取数据放入向量rec_vector中
rec_vector.addElement(rs.getString(1));
rec_vector.addElement(rs.getString(2));
rec_vector.addElement(rs.getString(3));
rec_vector.addElement(rs.getString(4));
rec_vector.addElement(rs.getString(5));
rec_vector.addElement(rs.getString(6));
vector2.addElement(rec_vector); //向量rec_vector加入向量vect中
}
//tm.fireTableStructureChanged();//更新表格,显示向量vect的内容
rs.close();
}catch(SQLException e){
e.printStackTrace();
}
DBm.closeDB();
//构造p2
Box base=Box.createHorizontalBox(),
boxleft=Box.createVerticalBox(),
boxright=Box.createVerticalBox();
JPanel pp1=new JPanel(),
pp2=new JPanel(),
pp3=new JPanel(),
pp4=new JPanel(),
pp5=new JPanel(),
pp6=new JPanel(),
pp7=new JPanel(),
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
java+sql数据库课程设计-教学管理系统.rar (41个子文件)
java+sql数据库课程设计-教学管理系统
CourseManager_Log.LDF 1024KB
CourseManager_Data.MDF 1.94MB
CourseManage_fat.jar 37KB
CourseManage
.project 388B
src
Logon.java 2KB
ChooseList.java 3KB
MyFrame.java 1KB
SqlManager.java 2KB
StuInfo.java 3KB
TeaInfo.java 3KB
AdmPanel.java 22KB
CourseList.java 6KB
ModifyPassword.java 3KB
TeaPanel.java 2KB
StoreScore.java 3KB
StuPanel.java 2KB
.settings
org.eclipse.jdt.core.prefs 629B
sqljdbc4.jar 455KB
.fatjar 346B
.classpath 301B
bin
AdmPanel$2.class 705B
StuInfo.class 4KB
SqlManager.class 3KB
MyTableRenderer.class 845B
StoreScore$1.class 630B
AdmPanel.class 18KB
AdmPanel$1.class 705B
ModifyPassword.class 4KB
MymyTable.class 683B
MyFrame.class 2KB
MeTable.class 487B
ChooseList.class 3KB
CourseList.class 6KB
Logon.class 4KB
MyTable.class 574B
StoreScore.class 4KB
StuPanel.class 3KB
TeaPanel.class 2KB
TeaPanel$1.class 805B
TeaPanel$2.class 889B
TeaInfo.class 4KB
共 41 条
- 1
资源评论
- zhngshuyun2014-02-19很一般,但没有连接数据库,也没给出连接数据路的方法,个人认为不是很好的资源
- wheedle2014-12-19资源一般,没法链接数据库
- mncialululu2014-06-13没有数据库呀,不好用
u011101328
- 粉丝: 4
- 资源: 52
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功