完整word版图书管理系统源代码Word格式文档下载.docx
- 文档编号:17905762
- 上传时间:2022-12-12
- 格式:DOCX
- 页数:23
- 大小:21.35KB
完整word版图书管理系统源代码Word格式文档下载.docx
《完整word版图书管理系统源代码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《完整word版图书管理系统源代码Word格式文档下载.docx(23页珍藏版)》请在冰豆网上搜索。
d。
add(menu);
menu。
add(a);
add(b);
menu.add(c);
//添加菜单组
a。
setText(”系统管理"
);
a.setFont(newFont("
Dialog”,0,12));
b。
setText("
读者管理"
setFont(newFont("
Dialog"
0,12));
c。
setText(”书籍管理"
setFont(newFont(”Dialog”,0,12));
//生成系统管理菜单组的选项
aa。
登录"
aa.setFont(newFont("
Dialog”,0,12));
ab。
setText(”退出登录”);
ab.setFont(newFont("
Dialog”,0,12));
ac。
退出系统"
setFont(newFont(”Dialog"
0,12));
//生成读者管理菜单组的选项
bb.setText(”查询读者信息"
bb.setFont(newFont("
Dialog”,0,12));
//生成书籍管理菜单组的选项
ca。
添加书籍"
,0,12));
cb。
删除书籍"
0,12));
cc.setText(”查询读书信息"
cc.setFont(newFont(”Dialog"
cd.setText("
更新书籍”);
cd。
setFont(newFont(”Dialog”,0,12));
//添加系统管理菜单组
a.add(aa);
add(ab);
a.add(ac);
//添加读者管理菜单组
b.add(bb);
//添加书籍管理菜单组
add(ca);
add(cb);
add(cc);
add(cd);
//添加事件侦听
aa.addActionListener(this);
ab.addActionListener(this);
ac.addActionListener(this);
bb。
addActionListener(this);
ca.addActionListener(this);
cb.addActionListener(this);
cc。
setJMenuBar(menu);
}
publicvoidactionPerformed(ActionEvente){
if(e。
getSource()==aa){
UserLoginlogin=newUserLogin(this);
login.setVisible(true);
if(e。
getSource()==ab){
setVisible(false);
MainWindowmainFrame=newMainWindow();
mainFrame。
setLocation(400,150);
mainFrame.setVisible(true);
}
if(e。
getSource()==ac)
{System.exit(0);
}
if(e.getSource()==cc)
{FindBookfindbook=newFindBook();
findbook.setVisible(true);
}
getSource()==bb)
{
FindReaderfindreader=newFindReader();
findreader.setVisible(true);
getSource()==ca)
AddBookaddBook=newAddBook();
addBook。
setVisible(true);
}
if(e.getSource()==cb)
{
DeleteBookdelBook=newDeleteBook();
delBook。
setVisible(true);
getSource()==cd)
UpdateBookupdBook=newUpdateBook();
updBook.setVisible(true);
}}
publicvoidsetenabled(intright)
{if(right==1)
b.setEnabled(true);
setEnabled(true);
if(right==2)
setEnabled(true);
publicstaticvoidmain(String[]args){
MainWindowmainFrame=newMainWindow();
mainFrame。
setLocation(400,200);
2.用户登录界面
importjava.awt.*;
importjava。
awt。
event.*;
swing。
*;
importjava.sql.*;
io。
*;
publicclassUserLoginextendsJFrameimplementsActionListener
{
privatestaticfinallongserialVersionUID=1L;
Stringname;
DataBaseMangerdb=newDataBaseManger();
MainWindowmainFrame;
JFramef=null;
JPanelpanel1,panel2;
JLabelUserLabel,PasswordLabel;
JTextFieldUserTextField;
JPasswordFieldPasswordTextField;
JButtonYesBtn,CancelBtn;
Containerc;
ResultSetrs;
publicUserLogin(MainWindowmainFrame)
{
super(”用户登录”);
this。
mainFrame=mainFrame;
UserLabel=newJLabel("
用户名"
,JLabel.CENTER);
PasswordLabel=newJLabel("
密码”,JLabel。
CENTER);
UserTextField=newJTextField(10);
PasswordTextField=newJPasswordField(10);
YesBtn=newJButton("
确定”);
CancelBtn=newJButton(”取消”);
YesBtn.addActionListener(this);
CancelBtn.addActionListener(this);
panel1=newJPanel();
panel1.setLayout(newGridLayout(2,2));
panel2=newJPanel();
c=getContentPane();
c.setLayout(newBorderLayout());
panel1.add(UserLabel);
panel1.add(UserTextField);
panel1.add(PasswordLabel);
panel1.add(PasswordTextField);
c.add(panel1,BorderLayout。
panel2.add(YesBtn);
panel2。
add(CancelBtn);
c。
add(panel2,BorderLayout。
setSize(300,150);
JLabelJL=newJLabel();
c.add(JL,"
North"
c.add(panel1,"
Center”);
add("
South"
,panel2);
panel1.setBackground(newColor(255,255,255));
setLocation(400,200);
publicvoidactionPerformed(ActionEvente)
{if(e.getSource()==CancelBtn)
{this。
dispose();
else
{char[]password=PasswordTextField。
getPassword();
StringpasswordSTR=newString(password);
StringstrSQL;
strSQL="
select*fromuserswhereuname='
"
+UserTextField。
getText().trim()+"
’andupassword=’"
+passwordSTR+"
'
;
rs=db.getResult(strSQL);
booleanisExist=false;
try
{rs。
next();
mainFrame.loginNo=rs。
getString
(1);
name=rs.getString
(1);
mainFrame.loginName=name;
intright;
right=rs.getInt
(1);
mainFrame。
setenabled(right);
if(name。
length()!
=0)
isExist=true;
catch(Exceptionpe)
{pe.printStackTrace();
}
if(UserTextField。
getText()。
trim()。
equals("
”))
{
JOptionPane.showMessageDialog(null,”用户名不可为空!
return;
if(passwordSTR.equals("
JOptionPane。
showMessageDialog(null,"
密码不可为空!
return;
if(!
isExist)
{JOptionPane。
showMessageDialog(null,"
用户名不存在或者密码不正确!
{JOptionPane.showMessageDialog(null,”登录成功"
this.dispose();
}}}
3.读者信息查询
event。
importjava.sql.*;
importjava.lang。
String;
publicclassFindReaderextendsJFrameimplementsActionListener
{DataBaseMangerdb=newDataBaseManger();
MainWindowmw=newMainWindow();
JLabelselect=newJLabel("
请输入证件号"
JTextFieldjtf=newJTextField(10);
JPanelp1=newJPanel();
JPanelp2=newJPanel();
JPanelp3=newJPanel();
JPanelp4=newJPanel();
JLabellb=newJLabel(”读者信息”);
JButtonfindbt=newJButton("
查询”);
JButtonyesbt=newJButton("
确定"
JTextAreajta=newJTextArea(10,10);
publicFindReader()
{super(”查询读者信息”);
Containerc=getContentPane();
p1。
add(select);
add(jtf);
p1.add(findbt);
c.add(p1,BorderLayout。
NORTH);
p2.add(lb);
p2。
add(jta);
c.add(p2,BorderLayout.CENTER);
p4。
add(yesbt);
c.add(p4,BorderLayout.SOUTH);
yesbt.addActionListener(this);
findbt.addActionListener(this);
setSize(500,300);
setVisible(true);
setLocation(400,150);
publicvoidactionPerformed(ActionEvente)
{
if(e。
getActionCommand()==”确定"
)
this.dispose();
getActionCommand()==”查询"
{
Stringsno=jtf.getText();
StringsqlstrR;
if((mw.loginNo.trim().equals(sno))||(mw。
loginName。
equals(”admin”)))
{sqlstrR="
select*fromreaderwheresno=’"
+sno+”’”;
rs=db。
getResult(sqlstrR);
try
{rs.next();
jta.setText(”"
jta.append(”学号为:
+rs.getString
(1)+"
,”+”姓名为:
+rs。
getString
(2)+"
"
+”性别为:
+rs.getString(3)+"
\n”);
jta.append("
年龄为:
+rs.getString(4)+”,"
+"
密码为:
getString(5)+”,”+"
学院为:
+rs.getString(6)+"
\n"
Stringsqlstr="
select*fromlendbookwheresno=’”+sno+”’”;
rs=db.getResult(sqlstr);
catch(Exceptionpe)
{pe。
printStackTrace();
}}
else
JOptionPane。
showMessageDialog(null,”请输入正确的证件号!
}}}}
4.增加图书信息
awt.event.*;
*;
swing.event。
importjava.sql。
publicclassAddBookextendsJFrameimplementsActionListener
{MainWindowmw=newMainWindow();
DataBaseMangerdb=newDataBaseManger();
ResultSetrs;
JPanela,b,c,d,e,f;
JLabelbname=newJLabel();
JLabelbno=newJLabel();
JLabelbnum=newJLabel();
JLabelauthor=newJLabel();
JLabelpublisher=newJLabel();
JTextFieldtname=newJTextField(20);
JTextFieldtno=newJTextField(20);
JTextFieldtnum=newJTextField(20);
JTextFieldtauthor=newJTextField(20);
JTextFieldtpublisher=newJTextField(20);
JButtonaddbt=newJButton(”添加”);
JPanelp3=newJPanel();
publicAddBook()
{
super("
添加图书"
a=newJPanel();
b=newJPanel();
c=newJPanel();
d=newJPanel();
e=newJPanel();
f=newJPanel();
bname。
书名:
bname.setFont(newFont(”Dialog"
,0,12));
bno。
setText(”索书号:
bno.setFont(newFont("
Dialog”,0,12));
bnum。
setText(”数量:
bnum.setFont(newFont(”Dialog”,0,12));
author。
作者:
publisher.setText(”出版社:
”);
publisher。
a.add(bname);
a。
add(tname);
b.add(bno);
b。
add(tno);
c.add(bnum);
c。
add(tnum);
d。
add(author);
d。
add(tauthor);
e。
add(publisher);
e.add(tpublisher);
f。
add(addbt);
f。
add(yesbt);
add(a);
add(b);
add(c);
add(d);
add(e);
add(f);
setLayout(newGridLayout(8,1));
addbt。
addActionListener(this);
yesbt.addActionListener(this);
setSize(500,300);
setLocation(400,150);
Stringbname,bno,author,publisher;
intbnum;
if(e.getActionCommand()==”确定”)
this.dispose();
getActionCommand()=="
添加”)
{
bname=tname。
getText();
bno=tno.getText();
author=tauthor.getText();
publisher=tpublisher。
bnum=Integer.parseInt(tnum.get
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 版图 管理 系统 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)