图书管理系统实验报告+源代码.docx

上传人:b****5 文档编号:5185566 上传时间:2022-12-13 格式:DOCX 页数:46 大小:1.16MB
下载 相关 举报
图书管理系统实验报告+源代码.docx_第1页
第1页 / 共46页
图书管理系统实验报告+源代码.docx_第2页
第2页 / 共46页
图书管理系统实验报告+源代码.docx_第3页
第3页 / 共46页
图书管理系统实验报告+源代码.docx_第4页
第4页 / 共46页
图书管理系统实验报告+源代码.docx_第5页
第5页 / 共46页
点击查看更多>>
下载资源
资源描述

图书管理系统实验报告+源代码.docx

《图书管理系统实验报告+源代码.docx》由会员分享,可在线阅读,更多相关《图书管理系统实验报告+源代码.docx(46页珍藏版)》请在冰豆网上搜索。

图书管理系统实验报告+源代码.docx

图书管理系统实验报告+源代码

图书信息管理系统

课程设计:

图书信息管理系统

设计人员:

林俊柱

开发环境:

eclipse

数据库:

sqlserver2005

说明:

数据库里面的用户名为”sa”,密码为:

”1111”

登录程序所用的用户名为:

ljz,密码为:

0000,

当然,也可以使用注册功能,注册完成后使用自己的用户名和密码登录

设计思路:

该图书信息管理系统主要便于图书管理员管理教师的书籍借阅情况。

该程序实现的功能总共有五个板块:

1、教师信息管理:

包含了增加、删除、修改、查询教师信息等功能;

2、图书信息管理:

包含了增加、删除、修改、查询图书信息等功能;

3、借书登记:

登记教师借阅图书的相关信息;

4、还书登记:

登记教师归还图书的相关信息;

5、催还:

查询出并列出教师借阅图书超过期限的相关信息,以便催促教师还书.

 

 

数据库的设计思路为:

 

 

Teacher(读者号,姓名,性别,年龄,部门,联系方式)

Book(ISBN,书名,作者,出版社,价格,类型)

Borrow(读者号,ISBN,借阅日期,归还日期,办理人,归还办理人)

(横线为主键,蓝色字体为外键)

管理员信息表:

Administrator(管理员编号,管理员密码,管理员姓名,性别,年龄,联系电话)

数据库的连接:

publicclassDataclass{

privatestaticConnectionconn=null;

StringdriverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";

StringdbURL="jdbc:

sqlserver:

//localhost:

1433;DatabaseName=Java课程设计数据库";

StringuserName="sa";//默认用户名

StringuserPwd="1111";//密码

//构造函数

publicDataclass(){//用于连接数库

try{

if(conn==null){

Class.forName(driverName);

conn=DriverManager.getConnection(dbURL,userName,userPwd);

}

else

return;

}

catch(Exceptione){//捕获数据库连接不成功异常

e.printStackTrace();

}

}

publicstaticResultSetexecuteQuery(Stringsql){//传送返回结果集的SQL语句

try{

if(conn==null)

newDataclass();//调用构造函数连接数据库

returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE).executeQuery(sql);//返回可滚动的并发事件

}

catch(SQLExceptione){//捕获访问数据库失败异常

e.printStackTrace();

returnnull;

}

}

publicstaticbooleanexecuteUpdate(Stringsql){//发送不返回结果集的SQL语句

try{

if(conn==null)

newDataclass();//调用构造函数连接数据库

inti=conn.createStatement().executeUpdate(sql);

if(i!

=0)

returntrue;

}

catch(SQLExceptione){//捕获访问数据库失败异常

System.out.println(e.getMessage());

returnfalse;//不成功返回-1

}

returnfalse;

}

publicstaticvoidclose(){//断开数据库连接方法

try{

conn.close();

}

catch(SQLExceptione){

e.printStackTrace();

}

finally{

conn=null;//设置数据库连接对象为空

}

}

}

 

登录界面的实现:

代码为:

publicclassKCSJDLextendsJFrame{

JTextFieldtextField1;

JPasswordFieldtextField2;

publicKCSJDL(){

try{//设置Windows观感

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}catch(Exceptione){

System.out.println("LookandFeelException");

System.exit(0);

}

setTitle("图书管理系统登录界面");

setBounds(400,200,376,300);

setResizable(false);

Containercon=getContentPane();

JLabellblNewLabel=newJLabel();

lblNewLabel.setIcon(newImageIcon("images/head.jpg"));

JPanelJpanel1=newJPanel();

Jpanel1.setLayout(newGridLayout(2,1,0,0));

JPanelJpanel1_1=newJPanel();

Jpanel1_1.setLayout(newFlowLayout(FlowLayout.CENTER,5,30));

Jpanel1.add(Jpanel1_1);

JLabellblNewLabel2=newJLabel("管理员编号:

");

Jpanel1_1.add(lblNewLabel2);

textField1=newJTextField();

Jpanel1_1.add(textField1);

textField1.setColumns(25);

JPanelJpanel1_2=newJPanel();

Jpanel1_2.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel1.add(Jpanel1_2);

JLabellabel_1=newJLabel("管理员密码:

");

Jpanel1_2.add(label_1);

textField2=newJPasswordField();

Jpanel1_2.add(textField2);

textField2.setColumns(25);

JPanelJpanel2=newJPanel();

JLabellabel=newJLabel("");

JButtonbutton1=newJButton("登录");

JButtonbutton2=newJButton("注册");

Jpanel2.add(label);

Jpanel2.add(button1);

Jpanel2.add(button2);

con.add(lblNewLabel,"North");

con.add(Jpanel1,"Center");

con.add(Jpanel2,"South");

textField1.addActionListener(newKCSJDLEvent(this));

textField2.addActionListener(newKCSJDLEvent(this));

button1.addActionListener(newKCSJDLEvent(this));

button2.addActionListener(newKCSJDLEvent(this));

}

publicstaticvoidmain(String[]args){

KCSJDLtest=newKCSJDL();

test.setVisible(true);

test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

 

注册界面的实现:

代码为:

publicclassKCSJZCextendsJFrame{

privateButtonGroupbuttonGroup=newButtonGroup();

JTextFieldtextField1_1;

JTextFieldtextField2_1;

JTextFieldtextField3_1;

JTextFieldtextField4_1;

JTextFieldtextField4_2;

JRadioButtonradioButton1;

JRadioButtonradioButton2;

publicKCSJZC(){

try{//设置Windows观感

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}catch(Exceptione){

System.out.println("LookandFeelException");

System.exit(0);

}

setTitle("注册");

setBounds(400,200,500,550);

setResizable(false);

Containercon=getContentPane();

JLabellblNewLabel=newJLabel();

lblNewLabel.setIcon(newImageIcon("images/ZC.png"));

con.add(lblNewLabel,"North");

JPanelJpanel=newJPanel();

Jpanel.setBorder(newTitledBorder(null,"管理员注册",TitledBorder.CENTER,TitledBorder.TOP,null,null));

Jpanel.setLayout(newGridLayout(5,1,0,0));

con.add(Jpanel,"Center");

JPanelJ1=newJPanel();

J1.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel.add(J1);

JLabellb1_1=newJLabel("管理员编号:

");

textField1_1=newJTextField();

textField1_1.setColumns(20);

JLabellb1_2=newJLabel("");

J1.add(lb1_1);

J1.add(textField1_1);

J1.add(lb1_2);

JPanelJ2=newJPanel();

J2.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel.add(J2);

JLabellb2_1=newJLabel("管理员密码:

");

textField2_1=newJTextField();

textField2_1.setColumns(20);

JLabellb2_2=newJLabel("确认密码:

");

JTextFieldtextField2_2=newJTextField();

textField2_2.setColumns(20);

J2.add(lb2_1);

J2.add(textField2_1);

J2.add(lb2_2);

J2.add(textField2_2);

JPanelJ3=newJPanel();

J3.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel.add(J3);

JLabellb3_1=newJLabel("管理员姓名:

");

textField3_1=newJTextField();

textField3_1.setColumns(20);

JLabellb3_2=newJLabel("性别:

");

radioButton1=newJRadioButton("男");//""

buttonGroup.add(radioButton1);

JLabellb3_3=newJLabel("");

radioButton2=newJRadioButton("女");

buttonGroup.add(radioButton2);

J3.add(lb3_1);

J3.add(textField3_1);

J3.add(lb3_2);

J3.add(radioButton1);

J3.add(lb3_3);

J3.add(radioButton2);

JPanelJ4=newJPanel();

J4.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel.add(J4);

JLabellb4_1=newJLabel("年龄:

");

textField4_1=newJTextField();

textField4_1.setColumns(20);

JLabellb4_2=newJLabel("联系电话:

");

textField4_2=newJTextField();

textField4_2.setColumns(20);

J4.add(lb4_1);

J4.add(textField4_1);

J4.add(lb4_2);

J4.add(textField4_2);

JPanelJ5=newJPanel();

J5.setLayout(newFlowLayout(FlowLayout.CENTER,5,20));

Jpanel.add(J5);

JButtonJb1=newJButton("注册");

Jb1.setIcon(newImageIcon("images/JY.png"));

Jb1.addActionListener(newenrollEvent(this));

JButtonJb2=newJButton("返回登录界面");

Jb2.setIcon(newImageIcon("images/GH.png"));

Jb2.addActionListener(newenrollEvent(this));

J5.add(Jb1);

J5.add(Jb2);

}

}

 

首页界面的实现:

代码为:

classKCSJMainextendsJFrame{

JButtonJbutton[]=newJButton[6];

JPanelJpanel;

JPanelJpanel1;

JPanelJpanel2;

JPanelJpanel3;

JPanelJpanel4;

JPanelJpanel5;

JTextFieldtextField_1;

JTextFieldtextField_2;

JTextFieldtextField_3;

JTextFieldtextField_4;

JTextFieldtextField_5;

publicKCSJMain(){

try{//设置Windows观感

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}catch(Exceptione){

System.out.println("LookandFeelException");

System.exit(0);

}

setTitle("图书管理系统");

setBounds(150,150,950,620);

setResizable(false);

Containercon=getContentPane();

Stringstr[]={"首页","教师信息管理","图书信息管理","借书登记","还书登记","催还"};

StringPfilename[]={"images/c6.png","images/p1.png","images/p2.png","images/p3.png","images/p4.png","images/p5.png"};

for(inti=0;i

Jbutton[i]=newJButton(str[i]);

Jbutton[i].setIcon(newImageIcon(Pfilename[i]));

Jbutton[i].setHorizontalTextPosition(JButton.CENTER);

Jbutton[i].setVerticalTextPosition(JButton.BOTTOM);

}

JPanelpanel=newJPanel();

panel.setBorder(newLineBorder(Color.LIGHT_GRAY));

for(inti=0;i

panel.add(Jbutton[i]);

}

//左边

JPaneljpanel=newJPanel();

jpanel.setBorder(newLineBorder(Color.LIGHT_GRAY));

jpanel.setLayout(newBoxLayout(jpanel,BoxLayout.Y_AXIS));

JPanelpanel_1=newJPanel();

panel_1.setBorder(newTitledBorder(UIManager.getBorder("TitledBorder.border"),"欢迎使用图书管理系统",TitledBorder.CENTER,TitledBorder.TOP,null,newColor(0,0,0)));

jpanel.add(panel_1);

JTextAreatextArea=newJTextArea();

textArea.setColumns(30);

textArea.setRows(5);

textArea.setText("【功能简要介绍】:

\n该系统可以对教师读者以及图\n书进行管理,包括增删改查等功能\n,方便于管理,是管理员的小小\n助手!

");

textArea.setBackground(SystemColor.control);

textArea.setEditable(false);

panel_1.add(textArea);

JPanelpanel_2=newJPanel();

panel_2.setBorder(newTitledBorder(null,"您好,欢迎登录图书管理系统",TitledBorder.CENTER,TitledBorder.TOP,null,null));

jpanel.add(panel_2);

JPaneljp=newJPanel();

jp.setLayout(newGridLayout(5,1,0,0));

panel_2.add(jp);

Stringstr1[]={"管理员编号:

","管理员姓名:

","性别:

","年龄:

","联系电话:

"};

JPanelJP[]=newJPanel[str1.length];

JLabellabel[]=newJLabel[str1.length];

for(inti=0;i

JP[i]=newJPanel();

label[i]=newJLabel(str1[i]);

JP[i].add(label[i]);

jp.add(JP[i]);

}

textField_1=newJTextField();

textField_1.setColumns(20);

JP[0].add(textField_1);

textField_2=newJTextField();

textField_2.setColumns(20);

JP[1].add(textField_2);

textField_3=newJTextField();

textField_3.setColumns

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

当前位置:首页 > 高等教育 > 艺术

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

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