《java程序设计》学生管理系统报告.docx

上传人:b****9 文档编号:28713504 上传时间:2023-07-19 格式:DOCX 页数:25 大小:158.62KB
下载 相关 举报
《java程序设计》学生管理系统报告.docx_第1页
第1页 / 共25页
《java程序设计》学生管理系统报告.docx_第2页
第2页 / 共25页
《java程序设计》学生管理系统报告.docx_第3页
第3页 / 共25页
《java程序设计》学生管理系统报告.docx_第4页
第4页 / 共25页
《java程序设计》学生管理系统报告.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

《java程序设计》学生管理系统报告.docx

《《java程序设计》学生管理系统报告.docx》由会员分享,可在线阅读,更多相关《《java程序设计》学生管理系统报告.docx(25页珍藏版)》请在冰豆网上搜索。

《java程序设计》学生管理系统报告.docx

《java程序设计》学生管理系统报告

 

 

《Java程序设计》

结课报告

 

学生信息管理系统

第1章系统简介

1.1系统功能

本系统主要功能:

1)通过数据校验如果数据校验成功,显示主界面;

2)登入后查询所有学生信息;

3)窗体实现对学生信息的增加、删除、修改;

4)模糊查询,根据姓名或者一个字查询;

5)实现子管理员的注册,并且写入注册信息到记事本,并实现可以用新注册的管理账号登入系统主界面

1.2系统引用例子

课本P275页15.5和课本P386页21.6

第2章表的设计

2.1系统数据库表结构

将系统数据库表结构用表的形式画出,如:

字段名

字段类型

长度

主/外键

字段值约束

对应中文名

SNO

Int

10

P

Notnull

学生编号

SNAME

Varchar

20

Notnull

学生名字

SSEX

Varchar

1

Notnull

学生性别

表2.1用户表(JBXX)

SAGE

Int

2

Notnull

学生年龄

 

字段名

字段类型

长度

主/外键

字段值约束

对应中文名

SNO

Int

10

P

Notnull

学生编号

JNAME

Varchar

20

Notnull

家长名字

JTEL

Int

10

Notnull

家庭电话

表2.2家庭信息表(JTXX)

注册子管理员的记事本1111.TXT内信息如下:

yyyy#yyyy

linlin#linlin

admin1#1111

admin2#2222

admin3#3333

admin4#4444

opop#opop

uuuu#uuuu

bbbb#bbbb

tttt#tttt

 

第3章连接数据库的实现

3.1SQLServer数据库连接的关键代码

publicclassDButil{

Connectioncon=null;

Stringname="linqun";

Stringpassname="linqun";

Stringul1="jdbc:

oracle:

thin:

@127.0.0.1:

1521:

orcl";

publicConnectiongetconn(){

try{

Class.forName("oracle.jdbc.driver.OracleDriver");

System.out.println("数据库驱动加载成功");

con=DriverManager.getConnection(ul1,name,passname);

System.out.println("数据库连接成功");

}catch(Exceptione){

System.out.println(e);

}

returncon;

}

publicvoiddbclose(Connectionconn,Statementsta,ResultSetrs){

try{

if(rs!

=null)

rs.close();

if(conn!

=null)

conn.close();

if(sta!

=null)

sta.close();

}catch(Exceptione){

e.printStackTrace();

}finally{

System.out.println("数据库释放!

");}

}

}

系统登录模块设计

4.1.1、运行效果图

图4.1登录主界面效果图

4.1.2、主要代码

publicclassloginextendsJDialog{

staticPreparedStatementSQL;

privatestaticfinallongserialVersionUID=1L;

privateJLabell_Id=newJLabel("登陆账户",JLabel.CENTER);

privateJLabell_pw=newJLabel("登陆密码",JLabel.CENTER);

privateJTextFieldt_Id=newJTextField(10);

privateJPasswordFieldt_pw=newJPasswordField(10);

privateJButtonbtnLogin;

privateJButtonbtnAdd;

privateJButtonbtnClose;

intnum=3;

publiclogin(){

super();

DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();

this.setLocation((screenSize.width-300)/2,(screenSize.height-200)/2);

this.setResizable(false);

getContentPane().setBackground(newColor(225,225,225));

getContentPane().setLayout(null);

initialize();

}

protectedvoidinitialize(){

setTitle("系统登录");

l_Id.setBounds(48,43,53,25);

t_Id.setBounds(110,43,150,25);

l_pw.setBounds(48,93,53,25);

t_pw.setBounds(110,93,150,25);

getContentPane().add(l_Id);

getContentPane().add(l_pw);

getContentPane().add(t_Id);

getContentPane().add(t_pw);

btnLogin=newJButton();

btnLogin.setText("登录");

btnLogin.setBounds(20,142,85,28);

btnLogin.setBackground(newColor(244,243,239));btnLogin.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){addBtnLoginActionListener();

}

});

getContentPane().add(btnLogin);

btnAdd=newJButton();

btnAdd.setText("注册");

btnAdd.setBounds(105,142,85,28);

btnAdd.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

addNewzc=newaddNew();

setVisible(false);

zc.setVisible(true);

}

});

getContentPane().add(btnAdd);

btnClose=newJButton();

btnClose.setText("关闭");

btnClose.setBounds(190,142,85,28);

btnClose.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

dispose();

System.exit(-1);

}

});

getContentPane().add(btnClose);

}

privatevoidaddBtnLoginActionListener(){

Stringid=t_Id.getText();

Stringpassword=newString(t_pw.getPassword());

if(id.equals("")){

JOptionPane.showMessageDialog(this,"帐号不可为空","提示",

JOptionPane.WARNING_MESSAGE);

return;

}elseif(password.equals("")){

JOptionPane.showMessageDialog(this,"密码不可为空","提示",

JOptionPane.WARNING_MESSAGE);

return;

}else{

toolst=newtools();

booleansuccess=false;//TODO:

数据校验

success=t.eqes(id,password);

if(success){//如果数据校验成功显示主界面

JOptionPane.showMessageDialog(this,"成功登录","提示",

JOptionPane.INFORMATION_MESSAGE);

newmainView();

this.dispose();

}else{

--num;

if(num==0){

JOptionPane.showMessageDialog(this,"用户名或者密码错误!

您没有机会了");

System.exit(0);

}else{

JOptionPane.showMessageDialog(this,"用户名或者密码错误!

您还有"+num+"次机会");

}

}

}

}

publicDimensiongetPreferredSize(){

returnnewDimension(320,170);

}

publicvoidshow(){

Toolkittk=Toolkit.getDefaultToolkit();

Dimensionscreen=tk.getScreenSize();

Dimensiond=getSize();

this.setLocation((screen.width-d.width)/2,(screen.height-d.height)/2);

//输入密码后回车相当于点击了登录按钮

getRootPane().setDefaultButton(btnLogin);

t_pw.requestFocus();

setDefaultCloseOperation(DISPOSE_ON_CLOSE);

setSize(300,220);

super.show();

}

publicstaticvoidmain(String[]args){

DButilutil=newDButil();

util.getconn();

loginloginFrame=newlogin();

loginFrame.setVisible(true);

}

}

4.2.1、运行效果图

图4.2登录后系统界面效果图

4.2.2、主要代码

publicmainView(){

super();

setTitle("所有学生信息");

setBounds(350,150,700,400);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

finalJScrollPanescrollPane=newJScrollPane();

con=db.getconn();

VectortableValueV,columnNameV;//存放列名

columnNameV=newVector();

columnNameV.add("学号");

columnNameV.add("名字");

columnNameV.add("性别");

columnNameV.add("年龄");

tableValueV=newVector();

scrollPane.setViewportView(table);

finalJPanelpanel=newJPanel();

getContentPane().add(panel,BorderLayout.SOUTH);

panel.add(newJLabel("编号:

"));

aTextField=newJTextField("",5);

panel.add(aTextField);

panel.add(newJLabel("姓名:

"));

bTextField=newJTextField("",5);

panel.add(bTextField);

panel.add(newJLabel("性别:

"));

cTextField=newJTextField("",5);

panel.add(cTextField);

panel.add(newJLabel("年龄:

"));

dTextField=newJTextField("",5);

panel.add(dTextField);

}

4.3.1、增加信息(121,白娘子,M,22)后运行效果图如下:

图4.3增加一个记录效果图

4.3.2、主要代码

finalJButtonaddButton=newJButton("添加");

addButton.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

userDaoadd=newuserDaoImpl();

useru=newuser();

u.setSno(Integer.parseInt(aTextField.getText()));

u.setsName(bTextField.getText());

u.setSsex(cTextField.getText());

u.setSage(Integer.parseInt(dTextField.getText()));

add.addUser(u);

setVisible(false);

newmainView();

}

});

panel.add(addButton);

4.3.3、删除信息编号为120的学生信息后结果如下:

图4.4删除一个记录效果图

4.3.4、主要代码:

finalJButtondelButton=newJButton("删除");delButton.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

userDaodel=newuserDaoImpl();

userud=newuser();

intselectedRow=table.getSelectedRow();//获得被选中行的索引

if(selectedRow!

=-1)//判断是否存在被选中行

del.deleUser(Integer.parseInt(aTextField.getText()));

setVisible(false);

tableModel.removeRow(selectedRow);

}

});

panel.add(delButton);

4.3.5、修改信息(105,关美眉,F,41)为(105,关大侠,M,30)后运行效果图如下:

图4.5修改一个记录效果图

4.3.6、主要代码:

panel.add(searchButton);finalJButtonupdButton=newJButton("修改");

updButton.addActionListener(newActionListener(){

publicvoidactionPerformed(ActionEvente){

userDaoupdate=newuserDaoImpl();

userupe=newuser();

aTextField.setEditable(false);

intselectedRow=table.getSelectedRow();//获得被选中行的索引

if(selectedRow!

=-1){//判断是否存在被选中行

upe.setSno(Integer.parseInt(aTextField.getText()));

upe.setsName(bTextField.getText());

upe.setSsex(cTextField.getText());

upe.setSage(Integer.parseInt(dTextField.getText()));

update.updateUser(upe);

setVisible(false);

newmainView();

}

}

});

panel.add(updButton);

4.4.1、运行效果图

图4.6查询记录集效果图

查询姓赵的人信息:

图4.7查询结果图

查询名字带“山”的人信息:

图4.8查询结果图

4.4.2、主要代码:

publicsearch(){

setTitle("根据姓名查询学生信息");

setLayout(newBorderLayout());

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

validate();

setBounds(350,150,650,400);

finalJPanelpane=newJPanel();

jl=newJLabel("输入姓或者名查询");

TextField=newJTextField("",5);

jb1=newJButton("查询");

jb2=newJButton("返回");

pane.add(jl);

pane.add(TextField);

pane.add(jb1);

pane.add(jb2);

getContentPane().add(pane,BorderLayout.NORTH);

jb1.addActionListener(this);

jb2.addActionListener(this);

setVisible(true);

}

publicvoidactionPerformed(ActionEvente){

if(e.getActionmand().equals("查询")){

JScrollPanejsp=newJScrollPane();

VectortableValueV,columnNameV;

columnNameV=newVector();

columnNameV.add("学号");

columnNameV.add("名字");

columnNameV.add("性别");

columnNameV.add("年龄");

tableValueV=newVector();

userDaouser=newuserDaoImpl();

useru=user.searchByName(TextField.getText());

VectorrowV=newVector();

rowV.add(u.getSno());

rowV.add(u.getsName());

rowV.add(u.getSsex());

rowV.add(u.getSage());

tableValueV.add(rowV);

tableModel=newDefaultTableModel(tableValueV,columnNameV);

table=newJTable(tableModel);

jsp=newJScrollPane(table);

jsp.setViewportView(table);

getContentPane().add(jsp,BorderLayout.CENTER);

setVisible(true);

}

if(e.getActionmand().equals("返回")){

newmainView();

}

}

4.5.1、运行效果图

图4.9注册子管理员效果图

4.5.2、主要代码:

publicaddNew(){

setDefaultCloseOperation(EXIT_ON_CLOSE);

load();

this.setVisible(true);

DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();

this.setLocation((screenSize.width-300)/2,

(screenSize.height-200)/2);

this.setResizable(false);

this.setTitle("注册子管理员界面");

this.setVisible(true);

this.addWindowListener(newWindowAdapter(){

publicvoidwindowClosing(WindowEvente){

System.exit(0);

}

});

}

publicvoidload(){

Pane

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1