基于java的图书管理系统源代码Word文件下载.docx

上传人:b****5 文档编号:18736357 上传时间:2022-12-31 格式:DOCX 页数:88 大小:36.55KB
下载 相关 举报
基于java的图书管理系统源代码Word文件下载.docx_第1页
第1页 / 共88页
基于java的图书管理系统源代码Word文件下载.docx_第2页
第2页 / 共88页
基于java的图书管理系统源代码Word文件下载.docx_第3页
第3页 / 共88页
基于java的图书管理系统源代码Word文件下载.docx_第4页
第4页 / 共88页
基于java的图书管理系统源代码Word文件下载.docx_第5页
第5页 / 共88页
点击查看更多>>
下载资源
资源描述

基于java的图书管理系统源代码Word文件下载.docx

《基于java的图书管理系统源代码Word文件下载.docx》由会员分享,可在线阅读,更多相关《基于java的图书管理系统源代码Word文件下载.docx(88页珍藏版)》请在冰豆网上搜索。

基于java的图书管理系统源代码Word文件下载.docx

JComboBoxaddresst;

Containerc;

JButtonclear,add,exit;

publicbook_add()

{

super("

添加图书信息"

);

c=getContentPane();

c.setLayout(newBorderLayout());

book_id_label=newJLabel("

编号"

JLabel.CENTER);

book_name_label=newJLabel("

名称"

author_label=newJLabel("

作者"

press_label=newJLabel("

出版社"

press_date_label=newJLabel("

出版日期"

price_label=newJLabel("

价格"

book_num_label=newJLabel("

库存数"

borrowed_num_label=newJLabel("

已借阅数"

address=newJLabel("

藏书地址"

book_id_TextField=newJTextField(15);

book_name_TextField=newJTextField(15);

author_TextField=newJTextField(15);

press_TextField=newJTextField(15);

press_date_TextField=newJTextField(15);

price_TextField=newJTextField(15);

book_num_TextField=newJTextField(15);

borrowed_count=newJTextField(15);

borrowed_count.setText("

0"

addresst=newJComboBox();

addresst.addItem("

扬子津图书馆"

荷花池图书馆"

瘦西湖图书馆"

淮海路图书馆"

panel1=newJPanel();

panel1.setLayout(newGridLayout(9,2));

panel1.add(book_id_label);

panel1.add(book_id_TextField);

panel1.add(book_name_label);

panel1.add(book_name_TextField);

panel1.add(press_label);

panel1.add(press_TextField);

panel1.add(author_label);

panel1.add(author_TextField);

panel1.add(press_date_label);

panel1.add(press_date_TextField);

panel1.add(price_label);

panel1.add(price_TextField);

panel1.add(book_num_label);

panel1.add(book_num_TextField);

panel1.add(borrowed_num_label);

panel1.add(borrowed_count);

panel1.add(address);

panel1.add(addresst);

panel2=newJPanel();

panel2.setLayout(newGridLayout(1,3));

clear=newJButton("

清空"

clear.addActionListener(this);

add=newJButton("

添加"

add.addActionListener(this);

exit=newJButton("

退出"

exit.addActionListener(this);

panel2.add(clear);

panel2.add(add);

panel2.add(exit);

c.add(panel1,BorderLayout.CENTER);

c.add(panel2,BorderLayout.SOUTH);

setVisible(true);

}

publicvoidactionPerformed(ActionEvente)

if(e.getSource()==exit)

{

this.dispose();

}

elseif(e.getSource()==clear)

book_id_TextField.setText("

"

book_name_TextField.setText("

author_TextField.setText("

press_TextField.setText("

press_date_TextField.setText("

price_TextField.setText("

book_num_TextField.setText("

elseif(e.getSource()==add)

if(book_id_TextField.getText().trim().equals("

))

{

JOptionPane.showMessageDialog(null,"

书号不能为空"

}

elseif(book_name_TextField.getText().trim().equals("

书名不能为空"

elseif(author_TextField.getText().trim().equals("

作者不能为空"

elseif(press_TextField.getText().trim().equals("

出版社不能为空"

elseif(press_date_TextField.getText().trim().equals("

出版日期不能为空"

elseif(price_TextField.getText().trim().equals("

价格不能为空"

elseif(book_num_TextField.getText().trim().equals("

库存不能为空"

elseif(borrowed_count.getText().trim().equals("

借阅数不能为空"

else{

try{

StringstrSQL="

insertintobook(book_id,book_name,press,author,press_date,price,book_count,borrowed_count,store_address)values('

+book_id_TextField.getText().trim()

+"

'

'

+book_name_TextField.getText().trim()

+press_TextField.getText().trim()

+author_TextField.getText().trim()

+press_date_TextField.getText().trim()

+price_TextField.getText().trim()

+book_num_TextField.getText().trim()

+borrowed_count.getText().trim()

+addresst.getSelectedItem()+"

)"

;

if(db.updateSql(strSQL))

{

this.dispose();

JOptionPane.showMessageDialog(null,"

添加图书成功"

}

else

添加图书失败"

db.closeConnection();

}catch(Exceptionex)

{

System.out.println(ex.toString());

}

}

 

importjavax.swing.*;

importjava.awt.*;

importjava.awt.event.*;

importjava.sql.SQLException;

publicclassbook_deleteextendsJFrameimplementsActionListener{

JLabelTipLabel=newJLabel("

请选择要删除的书名"

JComboBoxbb=newJComboBox();

JButtonyes,exit;

JPanelpanel1=newJPanel();

publicbook_delete()

删除图书信息"

try{

StringstrSQL="

selectbook_namefrombookwherebook_count>

borrowed_count"

rs=db.getResult(strSQL);

while(rs.next())

bb.addItem(rs.getString

(1));

}catch(SQLExceptionsqle){

System.out.println(sqle.toString());

}catch(Exceptionex){

System.out.println(ex.toString());

c.add(TipLabel,BorderLayout.NORTH);

c.add(bb,BorderLayout.CENTER);

yes=newJButton("

确定"

yes.addActionListener(this);

panel1.add(yes);

panel1.add(exit);

c.add(panel1,BorderLayout.SOUTH);

elseif(e.getSource()==yes)

try{

StringstrSQL="

selectborrowed_countfrombookwherebook_name='

+bb.getSelectedItem()+"

rs=db.getResult(strSQL);

if(!

rs.first())

JOptionPane.showMessageDialog(null,"

书库里没有你要删除的书"

else

StringstrSql="

deletefrombookwherebook_name='

+bb.getSelectedItem()

+"

andborrowed_count=0"

rs.first();

intcount=rs.getInt

(1);

if(!

(count==0))

{

JOptionPane.showMessageDialog(null,"

此书还有学生没有还,不可删除"

}

elseif(db.updateSql(strSql))

删除成功"

db.closeConnection();

this.dispose();

else{

删除失败"

}catch(SQLExceptionsqle){

publicclassbook_modifyextendsJFrameimplementsActionListener{

JPanelpanel1,panel2,panel3;

输入书名点确定,将调出此书的相关信息"

JLabelbook_name_label,author_label,

press_label,press_date_label,price_label;

JTextFieldbook_name_TextField,author_TextField,

press_TextField,press_date_TextField,price_TextField;

JButtonclear,yes,update,exit;

publicbook_modify()

修改图书信息"

panel3=newJPanel();

panel3.add(TipLabel);

c.add(panel3,BorderLayout.NORTH);

panel1.setLayout(newGridLayout(6,2));

panel2.setLayout(newGridLayout(1,4));

update=newJButton("

更新"

panel2.add(yes);

panel2.

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

当前位置:首页 > 医药卫生 > 基础医学

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

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