📄 student.txt
字号:
{
JOptionPane.showMessageDialog(null,"提示:数据库连接失败了,呵呵!");
}
}
//以下是关闭数据库
public void closeDB()
{
try
{
st.close();
con.close();
}
catch(SQLException e )
{
JOptionPane.showMessageDialog(null,"提示:数据库关闭失败了,呵呵!");
}
}
//以下是针对数据库的各种操作
public void actionPerformed(ActionEvent e)
{
if( e.getSource()==subMenu1[0] ||e.getSource()== subMenu1[1] || e.getSource()==subMenu1[2] )
JOptionPane.showMessageDialog(null,"欢迎使用!本功能不打算实现了!(*^__^*) 嘻嘻……");
///////////////////////////////////////////////////////////////////////////////////
if(e.getSource()==cake )
{ int goodest = 0;
int good = 0;
int bad = 0;
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng where score >='85'");
int i;i=0;
while(rs.next())
{ {String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);} goodest++;i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常了!(*^__^*) 嘻嘻……!");
}
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng where score<='85'and score>='60'");
int i; i=goodest;
while(rs.next())
{{String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);}good++;i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常了!(*^__^*) 嘻嘻……!");
}
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng where score<'60'");
int i; i=goodest+good;
while(rs.next())
{ {String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);}bad++;i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,程序出现异常了!(*^__^*) 嘻嘻……!");
}
DrawMap map = new DrawMap(goodest,good, bad);
}
////////////////////////////////////////////////////////////////////////////////
if(e.getSource()==subMenu3[0] )
{
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng where major like '信%'");
int i; i=0;
while(rs.next())
{
{
String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);
}
i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,无法显示信息安全班学生信息!(*^__^*) 嘻嘻……!");
}
}
///////////////////////////////////////////////////////
if(e.getSource()==subMenu3[1] )
{
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng where major like '计%'");
int i; i=0;
while(rs.next())
{
{
String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);
}
i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉!无法显示计算机班学生信息!(*^__^*) 嘻嘻……!");
}
}
////////////////////////////////////////////////////////
if(e.getSource()==toolBarButton[7] )
{
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng order by id");
int i; i=0;
while(rs.next())
{
{
String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
String se =rs.getString("sex");
String ma = rs.getString("major");
// String bi = rs.getString("birthday");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);
table.setValueAt(se,i,3);
table.setValueAt(ma,i,4);
// table.setValueAt(ma,i,4);
}
i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,无法显示所有在册学生!(*^__^*) 嘻嘻……!");
}
}
/////////////////////////////////////////////////////
if(e.getSource()==roder1 )
{
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng order by score");
int i; i=0;
while(rs.next())
{
{
String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
String se =rs.getString("sex");
String ma = rs.getString("major");
// String bi = rs.getString("birthday");
table.setValueAt(num,i,0);
table.setValueAt(na,i,1);
table.setValueAt(sc,i,2);
table.setValueAt(se,i,3);
table.setValueAt(ma,i,4);
}
i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,没能按成绩从低到高排序!!(*^__^*) 嘻嘻……!");
}
}
///////////////////////////////////////////////////////
if(e.getSource()==roder2 )
{
try{ st=con.createStatement();
rs = st.executeQuery("select * from xuesheng order by score");
int i; i=0;
while(rs.next())
{
{
String num =rs.getString("id");
String na = rs.getString("name");
String sc = rs.getString("score");
String se =rs.getString("sex");
String ma = rs.getString("major");
// String bi = rs.getString("birthday");
table.setValueAt(num,21-i,0);
table.setValueAt(na,21-i,1);
table.setValueAt(sc,21-i,2);
table.setValueAt(se,21-i,3);
table.setValueAt(ma,21-i,4);
}
i++;
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"抱歉,没能按成绩从高到低排序!!(*^__^*) 嘻嘻……!");
}
}
//////////////////////////////////////////////////////
//查找功能的实现
if(e.getSource()==subMenu2[0]||e.getSource()==toolBarButton[0])
{
String idid = JOptionPane.showInputDialog("请输入您要查找的学生学号");
idid=idid.trim();
if(!idid.equals(""))
{
try
{
rs = st.executeQuery("select * from xuesheng where id='"+idid+"'");
int count = 0;
while(rs.next())
{
id =rs.getString("id");
name = rs.getString("name");
major = rs.getString("major");
sex = rs.getString("sex");
score = rs.getString("score");
pic=rs.getString("add");
count++;}
if(count==0)
JOptionPane.showMessageDialog(null,"对不起,没有您要查找的学生!");
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -