分析与设计.docx
- 文档编号:15866953
- 上传时间:2023-07-08
- 格式:DOCX
- 页数:28
- 大小:103.96KB
分析与设计.docx
《分析与设计.docx》由会员分享,可在线阅读,更多相关《分析与设计.docx(28页珍藏版)》请在冰点文库上搜索。
分析与设计
学生信息管理系统
1:
学生信息管理系统的主要功能如下:
二、数据库设计
Student(学号,姓名,性别,民族,籍贯,入学年份,专业,学院,生日)
Course(课程号,课程名,授课教师,教室,课程类型,上课时间)
SC(学号,课程号,成绩)
三、详细设计
(一)数据库操作
1、连接数据库类:
DatabaseOperation.java。
其中主要方法:
打开数据库连接publicvoidopenConn()
执行sql查询语句,返回结果集rspublicResultSetexecuteQuery(Stringsql)
执行sql修改语句,publicvoidexecuteUpdate(Stringsql)
以及对应的关闭方法。
(二)学生信息的操作,包括增加、修改、删除及查询学生信息的数据库操作;界面的设计;
1、学生类对应的数据库操作:
StuBean.java
其中主要方法:
●添加学生信息:
publicvoidstuAdd(intstuId,Stringname,Stringsex,Stringbirth,Stringhome,Stringethnic,Stringyear,Stringmajor,Stringcollege)
●修改学生信息:
根据学生的学号进行修改相关信息
publicvoidstuModify(Stringnum,Stringname,Stringsex,Stringbirth,Stringhome,Stringethnic,Stringyear,Stringmajor,Stringcollege)
●删除学生信息:
publicvoidstuDel(Stringnum)
●根据学号查询学生信息:
publicString[]stuSearch(Stringnum):
根据学号查找学生的其他信息,其他信息保存到数组中返回。
●学生信息综合查询(按照一个条件进行查询)
publicString[][]stuAllSearch(Stringcolname,Stringcolvalue):
根据提供的参数和参数值进行查询,因为查询的结果可能有多条信息,所以把相应的记录存放到二维数组中。
●学生信息综合查询(查询某范围内的记录)
publicString[][]stuAllSearch(Stringcolname,Stringcolvalue,Stringcolvalue2):
根据提供的参数和参数的范围值进行查询,查询结果存在二维数组中返回。
●获得新的学号
publicintgetStuId():
学号是学生的主键,所以在表中不能出现相同的学号,所以在设计时根据表中已有的学号的最大值而通过程序来产生学号。
●获得student表中的所有学号snum
publicString[]getAllId():
在界面设计中需要选择学号,并进行学号对应的学生信息进行修改、删除等操作,所以定义了此方法。
2、学生信息操作界面的设计
添加学生信息界面
修改学生信息界面
删除学生信息界面
通过上面的三个界面,可以分析它们有共同之处,在界面的上面部分都是显示学生的所有的信息,最下面的按钮部分在不同的功能中有所不同,因此在设计界面类时抽象出它们的共同的父类,这样的话有利于复用。
●共同的父类:
/**
*学生信息综合管理类
*提供主界面,供其他类继承
*/
publicclassStuInfoextendsJFrameimplementsActionListener{
ContainercontentPane;
JPanelcenterPanel=newJPanel();
JPanelupPanel=newJPanel();
JPaneldownPanel=newJPanel();
//框架的大小
DimensionfaceSize=newDimension(800,500);
JLabeljLabel1=newJLabel();
JLabeljLabel2=newJLabel();
JLabeljLabel3=newJLabel();
JLabeljLabel4=newJLabel();
JLabeljLabel5=newJLabel();
JLabeljLabel6=newJLabel();
JLabeljLabel7=newJLabel();
JLabeljLabel8=newJLabel();
JLabeljLabel9=newJLabel();
JTextFieldsNum=newJTextField(15);
JTextFieldsName=newJTextField(15);
JTextFieldsSex=newJTextField(15);
JTextFieldsSethnic=newJTextField(15);
JTextFieldsBirth=newJTextField(15);
JTextFieldsYear=newJTextField(15);
JTextFieldsMajor=newJTextField(15);
JTextFieldsCollege=newJTextField(15);
JTextFieldsHome=newJTextField(46);
JButtonsearchInfo=newJButton();
JButtonaddInfo=newJButton();
JButtonmodifyInfo=newJButton();
JButtondeleteInfo=newJButton();
JButtonclearInfo=newJButton();
JButtonsaveInfo=newJButton();
JButtoneixtInfo=newJButton();
JButtonjBSee=newJButton();
JButtonjBSearch=newJButton();
JButtonjBExit=newJButton();
JButtonjBSum=newJButton();
JButtonjBGrade=newJButton();
GridBagLayoutgirdBag=newGridBagLayout();
GridBagConstraintsgirdBagCon;
publicStuInfo(){
//设置框架的大小
this.setSize(faceSize);
//设置标题
this.setTitle("学生综合信息管理");
this.setResizable(false);
//设置程序图标
this.setIconImage(newImageIcon("icon.gif").getImage());
try{
init();
}catch(Exceptione){
e.printStackTrace();
}
}
publicvoidinit()throwsException{
contentPane=this.getContentPane();
contentPane.setLayout(newBorderLayout());
//中部面板的布局
centerPanel.setLayout(girdBag);
jLabel1.setText("学号:
");
jLabel1.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=0;
girdBagCon.gridy=0;
girdBagCon.insets=newInsets(10,10,10,1);
girdBag.setConstraints(jLabel1,girdBagCon);
centerPanel.add(jLabel1);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=1;
girdBagCon.gridy=0;
girdBagCon.insets=newInsets(10,1,10,15);
girdBag.setConstraints(sNum,girdBagCon);
centerPanel.add(sNum);
jLabel2.setText("姓名:
");
jLabel2.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=2;
girdBagCon.gridy=0;
girdBagCon.insets=newInsets(10,15,10,1);
girdBag.setConstraints(jLabel2,girdBagCon);
centerPanel.add(jLabel2);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=3;
girdBagCon.gridy=0;
girdBagCon.insets=newInsets(10,1,10,10);
girdBag.setConstraints(sName,girdBagCon);
centerPanel.add(sName);
jLabel3.setText("性别:
");
jLabel3.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=0;
girdBagCon.gridy=1;
girdBagCon.insets=newInsets(10,10,10,1);
girdBag.setConstraints(jLabel3,girdBagCon);
centerPanel.add(jLabel3);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=1;
girdBagCon.gridy=1;
girdBagCon.insets=newInsets(10,1,10,15);
girdBag.setConstraints(sSex,girdBagCon);
centerPanel.add(sSex);
jLabel4.setText("民族:
");
jLabel4.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=2;
girdBagCon.gridy=1;
girdBagCon.insets=newInsets(10,15,10,1);
girdBag.setConstraints(jLabel4,girdBagCon);
centerPanel.add(jLabel4);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=3;
girdBagCon.gridy=1;
girdBagCon.insets=newInsets(10,1,10,10);
girdBag.setConstraints(sSethnic,girdBagCon);
centerPanel.add(sSethnic);
jLabel5.setText("出生日期:
");
jLabel5.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=0;
girdBagCon.gridy=2;
girdBagCon.insets=newInsets(10,10,10,1);
girdBag.setConstraints(jLabel5,girdBagCon);
centerPanel.add(jLabel5);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=1;
girdBagCon.gridy=2;
girdBagCon.insets=newInsets(10,1,10,15);
girdBag.setConstraints(sBirth,girdBagCon);
centerPanel.add(sBirth);
jLabel6.setText("入学时间:
");
jLabel6.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=2;
girdBagCon.gridy=2;
girdBagCon.insets=newInsets(10,15,10,1);
girdBag.setConstraints(jLabel6,girdBagCon);
centerPanel.add(jLabel6);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=3;
girdBagCon.insets=newInsets(10,1,10,10);
girdBag.setConstraints(sYear,girdBagCon);
centerPanel.add(sYear);
jLabel7.setText("学院:
");
jLabel7.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=0;
girdBagCon.gridy=3;
girdBagCon.insets=newInsets(10,10,10,1);
girdBag.setConstraints(jLabel7,girdBagCon);
centerPanel.add(jLabel7);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=1;
girdBagCon.gridy=3;
girdBagCon.insets=newInsets(10,1,10,15);
girdBag.setConstraints(sCollege,girdBagCon);
centerPanel.add(sCollege);
jLabel8.setText("专业:
");
jLabel8.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=2;
girdBagCon.gridy=3;
girdBagCon.insets=newInsets(10,15,10,1);
girdBag.setConstraints(jLabel8,girdBagCon);
centerPanel.add(jLabel8);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=3;
girdBagCon.gridy=3;
girdBagCon.insets=newInsets(10,1,10,10);
girdBag.setConstraints(sMajor,girdBagCon);
centerPanel.add(sMajor);
jLabel9.setText("籍贯:
");
jLabel9.setFont(newFont("Dialog",0,12));
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=0;
girdBagCon.gridy=4;
girdBagCon.insets=newInsets(10,10,10,1);
girdBag.setConstraints(jLabel9,girdBagCon);
centerPanel.add(jLabel9);
girdBagCon=newGridBagConstraints();
girdBagCon.gridx=1;
girdBagCon.gridy=4;
girdBagCon.gridwidth=3;
girdBagCon.insets=newInsets(10,1,10,10);
girdBag.setConstraints(sHome,girdBagCon);
centerPanel.add(sHome);
contentPane.add(centerPanel,BorderLayout.CENTER);
sNum.setEditable(false);
sName.setEditable(false);
sSex.setEditable(false);
sSethnic.setEditable(false);
sBirth.setEditable(false);
sYear.setEditable(false);
sMajor.setEditable(false);
sCollege.setEditable(false);
sHome.setEditable(false);
}
/**
*下部面板的布局
*/
publicvoiddownInit(){
searchInfo.setText("查询");
searchInfo.setFont(newFont("Dialog",0,12));
downPanel.add(searchInfo);
addInfo.setText("增加");
addInfo.setFont(newFont("Dialog",0,12));
downPanel.add(addInfo);
modifyInfo.setText("修改");
modifyInfo.setFont(newFont("Dialog",0,12));
downPanel.add(modifyInfo);
deleteInfo.setText("删除");
deleteInfo.setFont(newFont("Dialog",0,12));
downPanel.add(deleteInfo);
saveInfo.setText("保存");
saveInfo.setFont(newFont("Dialog",0,12));
downPanel.add(saveInfo);
clearInfo.setText("清空");
clearInfo.setFont(newFont("Dialog",0,12));
downPanel.add(clearInfo);
eixtInfo.setText("退出");
eixtInfo.setFont(newFont("Dialog",0,12));
downPanel.add(eixtInfo);
contentPane.add(downPanel,BorderLayout.SOUTH);
//添加事件侦听
searchInfo.addActionListener(this);
addInfo.addActionListener(this);
modifyInfo.addActionListener(this);
deleteInfo.addActionListener(this);
saveInfo.addActionListener(this);
clearInfo.addActionListener(this);
eixtInfo.addActionListener(this);
modifyInfo.setEnabled(false);//修改
deleteInfo.setEnabled(false);//删除
saveInfo.setEnabled(false);//保存
clearInfo.setEnabled(false);//清空
}
/**
*事件处理
*/
publicvoidactionPerformed(ActionEvente){
Objectobj=e.getSource();
if(obj==searchInfo){//查询
}
elseif(obj==addInfo){//增加
}
elseif(obj==modifyInfo){//修改
}
elseif(obj==deleteInfo){//删除
}
elseif(obj==saveInfo){//保存
}
elseif(obj==clearInfo){//清空
setNull();
}
elseif(obj==eixtInfo){//退出
this.dispose();
}
}
/**
*将文本框清空
*/
publicvoidsetNull(){
sNum.setTex
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 分析 设计