Java版学籍管理系统方案.docx
- 文档编号:1163903
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:37
- 大小:19.64KB
Java版学籍管理系统方案.docx
《Java版学籍管理系统方案.docx》由会员分享,可在线阅读,更多相关《Java版学籍管理系统方案.docx(37页珍藏版)》请在冰点文库上搜索。
Java版学籍管理系统方案
package学籍管理系统;
/*
*Tochangethistemplate,chooseTools|Templates
*andopenthetemplateintheeditor.
*/
/**
*
*@authorAdministrator
*/
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
importjava.util.*;
publicclassDeleteextendsJPanelimplementsActionListener
{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
Hashtable基本信息表=null;
JTextField学号,姓名,专业,年级,出生;
JRadioButton男,女;
JButton删除;
ButtonGroupgroup=null;
FileInputStreaminOne=null;
ObjectInputStreaminTwo=null;
FileOutputStreamoutOne=null;
ObjectOutputStreamoutTwo=null;
Filefile=null;
publicDelete(Filefile)
{
this.file=file;
学号=newJTextField(10);
删除=newJButton("删除");
学号.addActionListener(this);
删除.addActionListener(this);
姓名=newJTextField(10);
姓名.setEditable(false);
专业=newJTextField(10);
专业.setEditable(false);
年级=newJTextField(10);
年级.setEditable(false);
出生=newJTextField(10);
出生.setEditable(false);
男=newJRadioButton("男",false);
女=newJRadioButton("女",false);
group=newButtonGroup();
group.add(男);
group.add(女);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel("输入要删除的学号:
",JLabel.CENTER));
box1.add(学号);
box1.add(删除);
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel("姓名:
",JLabel.CENTER));
box2.add(姓名);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("性别:
",JLabel.CENTER));
box3.add(男);
box3.add(女);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("专业:
",JLabel.CENTER));
box4.add(专业);
Boxbox5=Box.createHorizontalBox();
box5.add(newJLabel("年级:
",JLabel.CENTER));
box5.add(年级);
Boxbox6=Box.createHorizontalBox();
box6.add(newJLabel("出生:
",JLabel.CENTER));
box6.add(出生);
BoxboxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(box6);
boxH.add(Box.createVerticalGlue());
JPanelpCenter=newJPanel();
pCenter.add(boxH);
setLayout(newBorderLayout());
add(pCenter,BorderLayout.CENTER);
validate();
}
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==删除||e.getSource()==学号)
{
Stringnumber="";
number=学号.getText();
if(number.length()>0)
{
try{
inOne=newFileInputStream(file);
inTwo=newObjectInputStream(inOne);
基本信息表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exceptionee)
{
}
if(基本信息表.containsKey(number))
{
Studentstu=(Student)基本信息表.get(number);
姓名.setText(stu.getName());
专业.setText(stu.getDisciping());
年级.setText(stu.getGrade());
出生.setText(stu.getBorth());
if(stu.getSex().equals("男"))
{
男.setSelected(true);
}
else
{
女.setSelected(true);
}
Stringm="确定要删除该学号及全部信息吗?
";
intok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(ok==JOptionPane.YES_OPTION)
{
基本信息表.remove(number);
try
{
outOne=newFileOutputStream(file);
outTwo=newObjectOutputStream(outOne);
outTwo.writeObject(基本信息表);
outTwo.close();
outOne.close();
学号.setText(null);
姓名.setText(null);
专业.setText(null);
年级.setText(null);
出生.setText(null);
}
catch(Exceptionee)
{
System.out.println(ee);
}
}
elseif(ok==JOptionPane.NO_OPTION)
{
学号.setText(null);
姓名.setText(null);
专业.setText(null);
年级.setText(null);
出生.setText(null);
}
}
else
{
Stringwarning="该学号不存在!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
else
{
Stringwarning="必须要输入学号!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
}
}
package学籍管理系统;
/*
*Tochangethistemplate,chooseTools|Templates
*andopenthetemplateintheeditor.
*/
/**
*
*@authorAdministrator
*/
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
importjava.util.*;
publicclassInquestextendsJDialogimplementsActionListener
{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
Hashtable基本信息表=null;
JTextField学号,姓名,专业,年级,出生;
JRadioButton男,女;
JButton查询;
ButtonGroupgroup=null;
FileInputStreaminOne=null;
ObjectInputStreaminTwo=null;
Filefile=null;
publicInquest(JFramef,Filefile)
{
super(f,"查询对话框",false);
this.file=file;
学号=newJTextField(10);
查询=newJButton("查询");
学号.addActionListener(this);
查询.addActionListener(this);
姓名=newJTextField(10);
姓名.setEditable(false);
专业=newJTextField(10);
专业.setEditable(false);
年级=newJTextField(10);
年级.setEditable(false);
出生=newJTextField(10);
出生.setEditable(false);
男=newJRadioButton("男",false);
女=newJRadioButton("女",false);
group=newButtonGroup();
group.add(男);
group.add(女);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel("输入要查询的学号:
",JLabel.CENTER));
box1.add(学号);
box1.add(查询);
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel("姓名:
",JLabel.CENTER));
box2.add(姓名);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("性别:
",JLabel.CENTER));
box3.add(男);
box3.add(女);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("专业:
",JLabel.CENTER));
box4.add(专业);
Boxbox5=Box.createHorizontalBox();
box5.add(newJLabel("年级:
",JLabel.CENTER));
box5.add(年级);
Boxbox6=Box.createHorizontalBox();
box6.add(newJLabel("出生:
",JLabel.CENTER));
box6.add(出生);
BoxboxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(box6);
boxH.add(Box.createVerticalGlue());
JPanelpCenter=newJPanel();
pCenter.add(boxH);
Containercon=getContentPane();
con.add(pCenter,BorderLayout.CENTER);
con.validate();
setVisible(false);
setBounds(100,200,360,270);
addWindowListener(newWindowAdapter()
{publicvoidwindowClosing(WindowEvente)
{
setVisible(false);
}
});
}
publicvoidactionPerformed(ActionEvente)
{
姓名.setText(null);
专业.setText(null);
年级.setText(null);
出生.setText(null);
if(e.getSource()==查询||e.getSource()==学号)
{
Stringnumber="";
number=学号.getText();
if(number.length()>0)
{
try{
inOne=newFileInputStream(file);
inTwo=newObjectInputStream(inOne);
基本信息表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exceptionee)
{
}
if(基本信息表.containsKey(number))
{
Studentstu=(Student)基本信息表.get(number);
姓名.setText(stu.getName());
专业.setText(stu.getDisciping());
年级.setText(stu.getGrade());
出生.setText(stu.getBorth());
if(stu.getSex().equals("男"))
{
男.setSelected(true);
}
else
{
女.setSelected(true);
}
}
else
{
Stringwarning="该学号不存在!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
else
{
Stringwarning="必须要输入学号!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
}
}
package学籍管理系统;
/*
*Tochangethistemplate,chooseTools|Templates
*andopenthetemplateintheeditor.
*/
/**
*
*@authorAdministrator
*/
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
importjava.util.*;
publicclassModifySituationextendsJPanelimplementsActionListener
{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
Hashtable基本信息表=null;
JTextField学号,姓名,专业,年级,出生;
JRadioButton男,女;
ButtonGroupgroup=null;
JButton开始修改,录入修改,重置;
FileInputStreaminOne=null;
ObjectInputStreaminTwo=null;
FileOutputStreamoutOne=null;
ObjectOutputStreamoutTwo=null;
Filefile=null;
publicModifySituation(Filefile)
{
this.file=file;
学号=newJTextField(10);
姓名=newJTextField(10);
专业=newJTextField(10);
年级=newJTextField(10);
出生=newJTextField(10);
group=newButtonGroup();
男=newJRadioButton("男",true);
女=newJRadioButton("女",false);
group.add(男);
group.add(女);
开始修改=newJButton("开始修改");
录入修改=newJButton("录入修改");
录入修改.setEnabled(false);
重置=newJButton("重置");
学号.addActionListener(this);
开始修改.addActionListener(this);
录入修改.addActionListener(this);
重置.addActionListener(this);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel("输入要修改信息的学号:
",JLabel.CENTER));
box1.add(学号);
box1.add(开始修改);
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel("(新)姓名:
",JLabel.CENTER));
box2.add(姓名);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("(新)性别:
",JLabel.CENTER));
box3.add(男);
box3.add(女);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("(新)专业:
",JLabel.CENTER));
box4.add(专业);
Boxbox5=Box.createHorizontalBox();
box5.add(newJLabel("(新)年级:
",JLabel.CENTER));
box5.add(年级);
Boxbox6=Box.createHorizontalBox();
box6.add(newJLabel("(新)出生:
",JLabel.CENTER));
box6.add(出生);
BoxboxH=Box.createVerticalBox();
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(box5);
boxH.add(box6);
boxH.add(Box.createVerticalGlue());
JPanelpCenter=newJPanel();
pCenter.add(boxH);
setLayout(newBorderLayout());
add(pCenter,BorderLayout.CENTER);
JPanelpSouth=newJPanel();
pSouth.add(录入修改);
pSouth.add(重置);
add(pSouth,BorderLayout.SOUTH);
validate();
}
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==开始修改||e.getSource()==学号)
{
Stringnumber="";
number=学号.getText();
if(number.length()>0)
{
try{
inOne=newFileInputStream(file);
inTwo=newObjectInputStream(inOne);
基本信息表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exceptionee)
{
}
if(基本信息表.containsKey(number))
{
录入修改.setEnabled(true);
Studentstu=(Student)基本信息表.get(number);
姓名.setText(stu.getName());
专业.setText(stu.getDisciping());
年级.setText(stu.getGrade());
出生.setText(stu.getBorth());
if(stu.getSex().equals("男"))
{
男.setSelected(true);
}
else
{
女.setSelected(true);
}
}
else
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 学籍 管理 系统 方案