java课程设计---团体
课设题目:学生信息管理系统
一、团队成员介绍
周汉麟(组长):网络1511 201521123030
吴敏烽(组员):网络1512 201521123044
二、项目git地址
【课设】
吴敏烽
http://git.oschina.net/min21/javakeshe/commits/master
周汉麟
http://git.oschina.net/iamfinethinkyou/javakeshe
三、码云提交记录
四、项目功能架构图与主要功能流程图
项目主要功能流程图
五、项目运行截图
六、项目关键代码(不能太多)
//学生信息管理系统登录界面
public boolean equals(){
if("admin".equals(name)&&"admin".equals(password)){
return true;
}else{
return false;
}
}
};
class ActionHandle{
private JFrame frame=new JFrame("学生信息管理系统");
private JTextField name=new JTextField();//设置文本框
private JPasswordField pass=new JPasswordField();
private JLabel but1=new JLabel("用户名:");
private JLabel but2=new JLabel("密 码:");
private JButton but3=new JButton("登陆");
private JButton but4=new JButton("重置");
public ActionHandle(){
but3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(e.getSource()==but3){
String sname=name.getText();
String spass=new String(pass.getPassword());
LoginCheck log=new LoginCheck(sname,spass);
if(log.equals()){
try {
new Menu();
} catch (Exception e1) {
e1.printStackTrace();
}
frame.setVisible(false);
}else{
JOptionPane.showMessageDialog(null, "登录失败,错误的用户名或密码!");
}
}
}
});
//框架设置:
frame.setLayout(null);
but1.setBounds(80, 40 , 80,30);
name.setBounds(140,40, 120, 30); //
but2.setBounds(80, 80 , 80,30);
pass.setBounds(140,80, 120, 30);
but3.setBounds(100, 150 , 60,30);
but4.setBounds(180, 150 , 60,30);
frame.setSize(400,330);
frame.setLocation(300, 200);
frame.add(but1);
frame.add(name);
frame.add(pass);
frame.add(but2);
frame.add(but3);
frame.add(but4);
frame.setVisible(true);
}
}
public class Enter{
public static void main(String[] args) {
new ActionHandle();
}
}
//添加信息:(修改信息和这个类似)
but1.addActionListener(new ActionListener() { // 增加,内部类
public void actionPerformed(ActionEvent e) {
if (e.getSource() == but1) {
but3.setEnabled(false);//使but3这个按钮变灰不可点击了
String number1 = number.getText();
if (number1.length() == 12) {
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));//读回对象
has = (Hashtable) in.readObject(); in.close();
} catch (Exception e1) {
}
} else {
JOptionPane.showMessageDialog(null, "请输入12位数字的学号");
}
//
if (number1.length() == 12) {
if (has.containsKey(number1)) { JOptionPane.showMessageDialog(null, "该生信息已存在,请到修改页面修改!");
} else {
String name1 = name.getText();
String dor1 = dor.getText();
String address1 = address.getText();
String sex1 = sex.getText();
String date1 = date.getText();
String pol1 = pol.getText();
String phone1 = phone.getText();
Person per = null;
per = new Person(number1, name1, dor1, address1, sex1, date1, pol1, phone1);
has.put(number1, per);// ???
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(has);
out.close();
JOptionPane.showMessageDialog(null, "添加成功!");
} catch (Exception e1) {}
}
}
}
}
});
//文件的保存和显示:
but4.addActionListener(new ActionListener() { // 查看
public void actionPerformed(ActionEvent e) {
if (e.getSource() == but4) {
but3.setEnabled(false);
String number1 = number.getText();
if (number1.length() == 12) {
if (has.containsKey(number1)) {
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
has = (Hashtable) in.readObject();
in.close();
} catch (Exception e1) {
}
Person per = (Person) has.get(number1);
name.setText(per.getName());
dor.setText(per.getDor());
address.setText(per.getAddress());
sex.setText(per.getSex());
date.setText(per.getDate());
pol.setText(per.getPol());
phone.setText(per.getPhone());
but3.setEnabled(true);
} else {
JOptionPane.showMessageDialog(null, "学号不存在");
}
} else {
JOptionPane.showMessageDialog(null, "请输入12位数字的学号");
}
}
}
});
but5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == but5) {
frame1.setVisible(true);
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
has = (Hashtable) in.readObject();
in.close();
} catch (Exception ee) {
}
if (has.isEmpty()) {
show.append("目前还没有学生的信息记录!\n");
// append(s:String)向文本域的文本追加字符串,简单的说就像system.out.println()
} else {
for (Enumeration enu = has.elements(); enu.hasMoreElements();) {
//存入内存的内容如果不经过遍历是显示不出来的
Person per = (Person) enu.nextElement();
String str = " <学号>:" + per.getNum() + "\n" + " <姓名>:" + per.getName() + "\n" + " <宿舍号>:"
+ per.getDor() + "\n" + " <家庭住址>:" + per.getAddress() + "\n" + " <性别>:"
+ per.getSex() + "\n" + "<出生日期>:" + per.getDate() + "\n" + " <政治面貌>:"
+ per.getPol() + "\n" + " <电话>:" + per.getPhone() + "\n" + "\n";
show.append(str);
}
String str2 = "------------------------------结束---------------------------------------------------"
+ "\n";
show.append(str2);
}
}
}
});
but0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == but0) {
frame.setVisible(false);
new ActionHandle();
}
}
});
七、尚待改进或者新的想法
1.功能比较齐全,增删改查都有,虽然GUI设计得比较简陋。
2.需要完善添加统计学生各门科目成绩,班级平均分等。
八、团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长。
成员 | 负责模块 | 博客地址 |
---|---|---|
周汉麟(组长) | Person类、Menu类的增、删、改、查 | 【博客地址】http://www.cnblogs.com/Min21/p/7063877.html |
吴敏烽(组员) | Enter类(学生信息系统的登录)、Menu类的查看、显示 | 【博客地址】http://www.cnblogs.com/lamfinethinkyou/p/7063919.html |