package mypackage;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
public class SearchFrame
{
public static void main(String args[])
{
SearchBox ss=new SearchBox("查询信息");
}
}
class SearchBox extends Frame implements ActionListener,ItemListener
{
Choice choice;
Label show;
TextField information;
Button ok,cancel;
Connection con;
Statement stmt;
ResultSet rs;
TextArea info;
String name;
int index;
SearchBox(String s)
{
setLayout(new FlowLayout());
setTitle(s);
setBackground(Color.gray);
choice=new Choice();
choice.add("编号");
choice.add("学院");
choice.add("班级");
choice.add("学号");
choice.add("姓名");
choice.add("性别");
choice.add("年龄");
choice.add("入团时间");
show=new Label("请输入关键信息:");
information=new TextField(20);
ok=new Button("确定");
cancel=new Button("取消");
choice.addItemListener(this);
ok.addActionListener(this);
cancel.addActionListener(this);
add(choice);
add(show);
add(information);
add(ok);
add(cancel);
info=new TextArea();
add(info);
info.append("编号 "+"学院 "+" 班级 "+" 学号 "+" 姓名 "+"性别 "+"年龄 "+"入团时间"+"\n");
setSize(500,300);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
validate();
}
public void itemStateChanged(ItemEvent e)
{
name=choice.getSelectedItem();
index=choice.getSelectedIndex();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==cancel)
{
System.exit(0);
}
else if(e.getSource()==ok)
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ex)
{}
try
{
con=DriverManager.getConnection("jdbc:odbc:moon","","");
//stmt=con.createStatement();
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
switch(index)
{
case 0:
{
rs=stmt.executeQuery("select * from Student where 编号='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 1:
{
rs=stmt.executeQuery("select * from Student where 学院='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 2:
{
rs=stmt.executeQuery("select * from Student where 班级='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 3:
{
rs=stmt.executeQuery("select * from Student where 学号='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 4:
{
rs=stmt.executeQuery("select * from Student where 姓名='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 5:
{
rs=stmt.executeQuery("select * from Student where 性别='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 6:
{
rs=stmt.executeQuery("select * from Student where 年龄='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
case 7:
{
rs=stmt.executeQuery("select * from Student where 入团时间='"+information.getText()+"'");
while(rs.next())
{
info.append(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getInt(7)+" "+rs.getString(8)+"\n");
}
}
}
con.close();
stmt.close();
}
catch(SQLException ex)
{
System.out.print(ex.toString());
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于netbeans的团员信息管理系统
共64个文件
class:54个
java:9个
mdb:1个
3星 · 超过75%的资源 需积分: 20 22 下载量 51 浏览量
2011-06-03
06:26:42
上传
评论 2
收藏 73KB RAR 举报
温馨提示
该程序是基于netbeans的java程序,主要实现的团员基本信息的添加、删除、修改等
资源推荐
资源详情
资源评论
收起资源包目录
团员信息管理系统.rar (64个子文件)
团员信息管理系统
StudentSearchBox$1.class 567B
FirstWindow.class 4KB
db.mdb 260KB
StudentFrame.class 385B
ChangeBox.class 5KB
SearchBox.class 6KB
AdditionBox.class 4KB
WindowBox.class 4KB
SearchFrame.class 368B
StudentSearch.class 379B
TeacherFrame.java 3KB
AdditionFrame.java 2KB
StudentFrame.java 2KB
WindowBox$1.class 536B
HelpBox.class 1KB
HelpBox$1.class 527B
AdditionBox$1.class 547B
mypackage
StudentSearchBox$1.class 567B
FirstWindow.class 4KB
StudentFrame.class 385B
ChangeBox.class 5KB
SearchBox.class 6KB
AdditionBox.class 4KB
WindowBox.class 4KB
SearchFrame.class 368B
StudentSearch.class 379B
WindowBox$1.class 536B
HelpBox.class 1KB
HelpBox$1.class 527B
AdditionBox$1.class 547B
AdditionFrame.class 374B
SecondWindow$1.class 550B
DeleteBox.class 3KB
StudentSearchBox.class 4KB
DeleteFrame.class 368B
SearchBox$1.class 537B
TeacherFrame.class 384B
LoginFrame.class 378B
DeleteBox$1.class 537B
FirstWindow$1.class 546B
SecondWindow.class 3KB
ChangeFrame.class 368B
ChangeBox$1.class 537B
HelpFrame.class 362B
AdditionFrame.class 374B
SecondWindow$1.class 550B
DeleteBox.class 3KB
StudentSearchBox.class 4KB
DeleteFrame.java 2KB
DeleteFrame.class 368B
SearchBox$1.class 537B
TeacherFrame.class 384B
SearchFrame.java 5KB
LoginFrame.class 378B
DeleteBox$1.class 537B
FirstWindow$1.class 546B
LoginFrame.java 3KB
SecondWindow.class 3KB
StudentSearch.java 2KB
HelpFrame.java 1KB
ChangeFrame.class 368B
ChangeBox$1.class 537B
HelpFrame.class 362B
ChangeFrame.java 3KB
共 64 条
- 1
资源评论
- wokaory2012-02-26class文件、Access数据库
tianqi901028
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功