admin 管理员组文章数量: 887021
2024年2月6日发(作者:impactor)
课程设计精品图书If理系统
书生
系统说明:本系统釆用eclipse开发,IDEA, eclipse, myedipse均可运行
界面采用swing实现
数据库:mysql.附sql代码,其余数据库可复制sql代码运行
数据库连接文件
本系统的背景图片可根据自己的需求替换
项目分为管理员和普通用户两种角色
管理员有图书査询、图书借还、账户管理(修改密码、账户信息、借书记录)、图书管理
(増加、修改、删除)的权限
普通用户有图书査询、图书借还、账户管理(修改密码、借书记录)的权限
项目结朴
-温图书系饨
>,JRE 基绽库(JavaSE-12]
IS src y .[« Dao
> dZl
> ®
> <2)
> I/)
> El
v SB Test
> JZ)
击 View
> 通 AccountMsgFacejava
> i£
> (2
> Lfi
> ®
> Si BookSearc h Fac
>
> JZ)
> Si
> JZl
> <2)
>
> E)
> i引用的阵
y 4 datebase
圍
〜〜img
。
。
。
—
y — lib
耳
登录界面:
管理员登录:蘇号root,密码123123 普通用户登录:账号123,密码123123
2
注册界面:
管理员主界面:
E W ill
W
图书査询界面,
fflHW3
I
齐血
IM BA* MKftW
图书查训
讷逸拝査询方式:
y松■.
水
捜
图书借还界面,
| w ・
IMKA* WIHIH- 图书借还 埔输入书号, 检室 竹名: 作帝 状妇 ifc« 账户管理界面: 图书管理界面: 添加图书界面: 图书管理 *MNHCa WAIVKGU M&NIISGft 添加图书 类别:膑弄类琳 , 书名: ______________ 2J 作者: 出版社: 价格: 确定 修改图书界面: 修改图书信息 15 ■;: I 类别:页逸择晒 书名: 作者: 出版社: 状态:。馆 价格: 确定 账户值息界面: AH5记录界面:账户信息 诱盗拝A改方式: 借书记录 普通用户主界面: 普通用户際户管理界面: 背景图片, 账户管理 8 9 数据库文件(): SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS bookcategory*; CREATE TABLE 'bookcategory' ( 'Category' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 1 类别‘, PRIMARY KEY ('Category') USING BTREE )ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci = Compact; INSERT INTO 'bookcategory' VALUES ('军事'); INSERT INTO 'bookcategory' VALUES ('天文'); INSERT INTO 'bookcategory' VALUES ('学术'); INSERT INTO 'bookcategory' VALUES ('小说'); INSERT INTO 'bookcategory' VALUES ('文艺'); INSERT INTO 'bookcategory' VALUES ('科幻'); INSERT INTO 'bookcategory' VALUES ('经济‘); DROP TABLE IF EXISTS booktable,; 10 CREATE TABLE 'booktable' ( 'bookid' int(10) NOT NULL AUTOJNCREMENT COMMENT'书号‘, 'category' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT ' 类别', 'bookname' varchar(lOO) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT'书名,, author' varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT'作者, 'press' varchar(lOO) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT'出版社, price' float(10, 2) NOT NULL COMMENT'价格 'state' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMEN「状态 PRIMARY KEY ( bookid*) USING BTREE, INDEX 'category'('category') USING BTREE, CONSTRAINT 'booktable_ibfk_l* FOREIGN KEY ('category') REFERENCES 'bookcategory' ( Category*) ON DELETE RESTRICT ON UPDATE CASCADE )ENGINE = InnoDB AUTOJNCREMENT = 21 CHARACTER SET = utf8 COLLATE = utf8_general_ci = Compact; INSERT INTO 'booktable VALUES (1,,学术。'《JAVA程序设计教程》*,'刘志宏航空工业出版 社)45.00,在馆,); INSERT INTO 'booktable* VALUES (2,,学术〉,《软件工程》‘,'程成'机械工业出版社',31.50, * 在馆‘); INSERT INTO 'booktable' VALUES (3,'学术* (计算机文化》'(美)帕森斯(Parsons JJf,'电子工 业出版社28.00,,在馆》; INSERT INTO 'booktable' VALUES (4,,文艺〉'《我在未来等你》','刘同','青年光影出版社 36.50,,在馆‘); INSERT INTO 'booktable' VALUES (5,'小说,《西游记》'吴承恩'岳麓出版社33.50,,在馆,); INSERT INTO 'booktable* VALUES (6,'学术'《数据结构(c语言)》 '严蔚敏清华大学出版 社"27.50,,在馆,); 11 INSERT INTO 'booktable' VALUES (7, ,学术。 INSERT INTO 'booktable VALUES (8,'学术《计算机文化基础》,,'李永红','对外经济贸易大 学。32.50,在馆,); INSERT INTO'booktable'VALUES (9, ,学术J《数据库系统实现》/加西亚-莫利纳‘机械工 业出版社',47.00, ,在馆》; INSERT INTO 'booktable' VALUES (10,,文艺,'《数据库系统基础教程》'厄尔曼'机械工业出 版社。38.50,,在馆'); INSERT INTO 'booktable* VALUES (11,'学术 J《数学思维导论》‘Keith Devlin1,'人民邮电出版 枇40.00,,在馆) INSERT INTO 'booktable' VALUES (12,'学术‘《移动应用Ul设计必修课》‘,'余振华'人民邮 电出版社36.00,,在馆'); INSERT INTO 'booktable' VALUES (13,,学术,《快速软件开发》,史蒂夫•迈克康奈尔,,‘清华 大学出版社*, 25.50/在馆,); INSERT INTO 'booktable' VALUES (14,,科幻 J《三体》‘刘慈欣‘重庆出版社31.00,,在馆 INSERT INTO booktable* VALUES (15, ,科幻,,'《海底两万里》 ,镭尔•凡尔纳,,'译林出版社 32.50,,在馆 INSERT INTO 'booktable' VALUES (16,'军事‘《狼牙》'刘猛'北京联合出版公司35.50,,在 馆》; INSERT INTO ,booktable' VALUES (17,'天文'《宇宙的琴弦》'布赖恩•格林','湖南科学技术 岀版社。30.00,,在馆 INSERT INTO booktable VALUES (18,'经济,,'《货币经融学》'弗宙德里克・S•米什金'中国人 民大学出版社60.00/在馆》; 11DROP TABLE IF EXISTS 'borrowrecords'; CREATE TABLE 'borrowrecords* ( 'id' int(10) NOT NULL AUTOJNCREMENT COMMEN「借书序列‘, 'user' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户 名, 'bookid' int(10) NOT NULL COMMENT '书号‘, 'bookname' varchar(SO) CHARACTER SETutf8 COLLATE utf8_general_ci NOT NULL COMMENT, 书名', 12 'borrowtime' date NOT NULL COMMENT ‘借书时间', 'returntime* date NULL DEFAULT NULL COMMENT1 还书时间', 'status' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '状 态: PRIMARY KEY ('id') USING BTREE )ENGINE = InnoDB AUTOJNCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci = Compact; DROP TABLE IF EXISTS 'usertable*; CREATE TABLE 'usertable* ( 'user' varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户 名,, 'studentid' varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 1 学号‘, 'name' varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT名 I 'password* varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT ' 密码', admin' int(10) NOT NULL COMMENT 否为管理员账户1为管理员,0为普通用户,耿 认为0', PRIMARY KEY ('user') USING BTREE )ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci = Compact; 13 user studentid name password admin 「123 |123 123 123123 0 j 1234 1234 1234 123123 0 root root root 123123 1 INSERT INTO 'usertable' VALUES ('123', '123', '123', '123', 0); INSERT INTO 'usertable' VALUES ('root*, 'root*, 'root*, '123', 1); SET FOREIGN_KEY_CHECKS = 1; ft®库表g bookid 3c9o ♦■■n字术 《JAVAft序釦球询孩 换2现出版吐 2 k <«nze> E工业出加 3字术 《计・叔化》 伊DgXPgom J“坦孑工业出如t 4 ftZ MR ■年光彫出或吐 Category 6K 《EM构(cms) 即恩 砂大竽岀版牡 7字术 8任厦綺地大孕岀阪牡 0字术 EH奶.t»;已狰 9字术 9M1 対咄疥倒月大学 tC®E WW SlMIlkttitttt 10 J7X 《以»5翌3砲 娅厄尔JI BUHk 出 CM 学术11字术 《蚊学专姥号沦〉 Keith Devtin 入印曲出扱吐 12字天 人出版吐 13学术 14冲 <=») 或庆岀wt 15 瞬史》 版壮 科幻16 旅合出版公5) 17S9叔 《芥&3蜘 布1鴨花协 18竖济 中国人抵裂蛔之 id user bookid bookname borrowtime returntime 27 1234 13《快速软件开发2019-12-25 2019-12-25 28 root 1 CJAVA^yiSv 2019-12-25 Dao 包下的 : package Dao; import .*; import nPane; public class AdminDao14 price Udtc 45.00 汛1 3150 StS 2800 STB 3&5O StS 3150 E 40.00 E® 32.50 E 47.00 m 3a 50 E 40.00 m 3600 ZBB 25.50 E 31.00 ®S 32-SOEm 3000 阪 60.00 &i status 已还 public static boolean sureuser(String user) { Connection con = DB .connectDBO; PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from usertable where user = ?" try { preSql = eStatement(sqlStr); ing(l, user); rs = eQuery(); boolean flag = false; while(()) { flag = true; return true; ) if(!flag) ( return false; ) (); return false; } catch (SQLException e) ( return false; }) public static void modifypass(String user,String password) Connection con = tDB(); 15 PreparedStatement preSql; String sqlStr = "update usertable set password=? where user = ?"; try { preSql = eStatement(sqlStr); ing(l, password); ing(2, user); int ok = eUpdate(); (); ) catch (SQLException e) { }} public static Boolean adduser(String user, String studentid, String name. String password) ( Connection con = tDB(); PreparedStatement preSql; String sqlStr = "insert into usertable values (?,?,?,?,0)"; try { preSql = eStatement(sqlStr); ing(1, ing(2, ing(3, ing(4, int ok = eUpdate(); (); return true; } catch (SQLException e) ( user); studentid); name); password); essageDiatog(null,"用户名已存在"' 警告",G_MESSAGE); 16 return false; ) }} : package Dao; import .*; import .*; import .*; import t!ableModel; public class BookDao { public BookDao() { } public static void findcategory(JComboBox Connection con = tDBO; PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from bookcategory"; try { preSql = eStatement(sqlStr); rs = eQuery(); 17 while (()) { String category = ing(l); m(category); (); } catch (SQLException e) ( 〃添加图书 public static void addbook(String category,String bookname,String author,String press,String price) { Connection con = tDB(); PreparedStatement preSql; String sqlStr = "insert into booktable(category,bookname,author,press,price,state) values try { preSql = eStatement(sqlStr); ing(l, ing(2, ing(3, ing(4, ing(5, category); bookname); author); press); price); ing(6, ”在馆”); int ok = eUpdate();18 (); ) catch (SQLException e) { }} 〃修改图书 public static void modifybook(int bookid,String category,String bookname,String author,String press,String state,String price) ( Connection con = tDB(); PreparedStatement preSql; String sqlStr = "update booktable set category = ? ,bookname = ? ,author = ?,press = ? ,price = ?,state = ? where bookid = try { preSql = eStatement(sqlStr); ing(l, ing(2, ing(3, ing(4, ing(5, ing(6, (7, bookid); int ok = eUpdate(); (); ) catch (SQLException e) { }) 〃删除图书 public static void deletebook(int bookid) { Connection con = DB .connectDBO; 19 category); bookname); author); press); price); state); PreparedStatement preSql; String sqlStr = "delete from booktable where bookid = ?" try { preSql = eStatement(sqlStr); (l, bookid); int ok = eUpdate(); (); } catch (SQLException e) ( }) //显示所有图书 public static void allbook(DefaultTableModel model) { Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from booktable"; try { preSql = eStatement(sqlStr); rs = eQuery(); while (()) { int bookid = (l); String category = ing(2); String bookname = ing(3); String author = ing(4); String press = ing(5); String price = ing(6); 20 String state = ing(7); (new Vector。((bookid, category, bookname, author, press,price, state))); ) (); ) catch (SQLException e) ( }} //按类别査找图书 public static void findcategory(DefaultTableModel model. String CateGory) { Connection con = tDB(); PreparedStatement preSql; ResultSet rs; CateGory = + CateGory + "%”; String sqlStr = "select * from booktable where category like ?"; try { preSql = eStatement(sqlStr); ing(l, CateGory); rs = eQuery(); boolean flag = false; while (()) { flag = true; int bookid = (l); String category = ing(2); String bookname = ing(3); String author = ing(4); String press = ing(5); 21 String price = ing(6); String state = ing(7); (new Vectoro((bookid, category, bookname, author, press, price,state))); } if Sag) { DOptionPane. shoMMessageDia Log (null,"图书不存在 ","警告",G_MESSAGE'); ) (); ) catch (SQLException e) ( }} //按书号查找图书 public static void findbookid(DefaultTableModel model, int Bookid) ( Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from booktable where bookid try { preSql = eStatement(sqlStr); (l, Bookid); rs = eQuery(); boolean flag = false; while (()) ( flag = true; int bookid = (l); String category = ing(2); String bookname = ing(3); String author = ing(4); 22 String press = ing(S); String price = ing(6); String state = ing(7); (new Vector<>(£ist(bookid, category, bookname, author, press, price,state))); } if (!flag) ( JOptionPane. showMessageDia Log (null,"图书不存在 ","警告”,G_MESSAGE); ) (); } catch (SQLException e) { package Dao; import .*; import ; import .*; import t!ableModel; public class BorrowDao { public BorrowDao() { } 〃借阅图书 public static void Borrow(String user, int bookid. String bookname) { 23 Connection con = tDB(); PreparedStatement preSql; String sqlStr = "insert into borrowrecords(user,bookid,bookname,borrowtime,returntime,statu s) values (?,?,?,now(),null,?)"; try { preSql = eStatement(sqlStr); ing(l, user); (2, bookid); ing(3, bookname); ing(4,"未还”); int ok = eUpdate(); (); ChangeBorrouState(bookid); } catch (SQLException e) { }} 〃借阅图书修改图书状态 private static void ChangeBorrowState(int bookid) { Connection con = DB .connectDBQ; PreparedStatement preSql; String sqlStr = "update booktable set state=? where bookid = ?"; try { preSql = eStatement(sqlStr); ing(l, ”外借”); (2, bookid); int ok = eUpdate(); 24 (); ) catch (SQLException e) { }} 〃还书 public static void Return(String user, int bookid) { Connection con = tDB(); PreparedStatement preSql; String sqlStr = "select now()"; ResultSet rs; Date date=null; try { preSql = eStatement(sqlStr); rs = eQuery(); while(()) { date = e(l); ) sqlStr = "update borrowrecords set returntime = ? where bookid = ? and user = ? and status = ?"; preSql = eStatement(sqlStr); e(l, date); (2, bookid); ing(3, user); ing(4,"未还”); int ok = eUpdate(); sqlStr = "update borrowrecords set status = ? where bookid = ? and user = ? and status = ?"; preSql = eStatement(sqlStr); 25 ing(l,"已还”); (2, bookid); ing(3, user); ing(4,"未还”); ok = eUpdate(); (); ChangeReturnState(bookid); } catch (SQLException e) { }) 〃还书图书修改图书状态 private static void ChangeReturnState(int bookid) { Connection con = tDB(); PreparedStatement preSql; String sqlStr = "update booktable set state=? where bookid = ?"; try { preSql = eStatement(sqlStr); ing(l,"在馆”); (2, bookid); int ok = eUpdate(); (); } catch (SQLException e) ( }} 〃比对还书 public static boolean comparison(String user,int bookid) { 26 Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from borrowrecords where bookid = ? and status = ?"; try { preSql = eStatement(sqlStr); (l, bookid); ing(2,"未还”); rs = eQuery(); while (()) { String user2 = ing(2); if((user)) { return true; )else { return false; }} (); return false; ) catch (SQLException e) { return false; }) public static void allborrow(DefaultTableModel model) ( Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from borrowrecords"; 27 try ( preSql = eStatement(sqlStr); rs = eQuery(); while (()) { String user = ing(2); int bookid = (3); String bookname = ing(4); Date date = e(5); Date date2 = e(6); String status = ing(7); (new Vector<>((user,bookid,bookname,date,date2,status))) ;} (); ) catch (SQLException e) { }} 〃用户名借书记录 public static void userborrow(DefaultTableModel model,String user) { Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from borrowrecords where user =?”; try { preSql = eStatement(sqlStr); ing(1, user); rs = eQuery(); while (()) { int bookid = (3); 28 String bookname = ing(4); Date date = e(5); Date date2 = e(6); String status = ing(7); (new Vector<>((user,bookid,bookname,date,date2,status))) ;} (); } catch (SQLException e) ( }) //书号借书记录 public static void bookidborrow(DefaultTableModel model,int bookid) ( Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from borrowrecords where bookid = try { preSql = eStatement(sqlStr); (l, bookid); rs = eQuery(); while (()) { String user = ing(2); String bookname = ing(4); Date date = e(5); Date date2 = e(6); 29 String status = ing(7); (new Vector<>((user,bookid,bookname,date,date2,status))) ;} (); } catch (SQLException e) {} }) (数据库连接类): package Dao; import .*; public class DB { public static Connection connectDB() { String url = "jdbc:mysql:// localhost:3306/tsglsys?sepverTimezone=GMT%2B8"; try { Class ./orA/ame(". cj .jdbc. Driver"); } catch (Exception e) ( } Connection con = null; try { con = nection(url, "root", "1234"); } catch (SQLException e) ( } return con; }} 30 : package Dao; import .*; import nPane; public class LandDao ( public static Boolean test(String user. String password) ( Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from usertable where user = ?" try { preSql = eStatement(sqlStr); ing(l, user); rs = eQuery(); boolean flag = false; while(()) { flag = true; String password2 = ing(4); if (!((password2))) { DOptionPane. shoMMessageDia Log (null,"密码错误"警告",JOptionPane .UARNING_MESSAGE); return false;}} if(!flag) ( JOptionPane. showMessageDia Log (null,"用户名不存在"' 31 "警告",G_MESSAGE); return false; ) (); return true; ) catch (SQLException e) { JOptionPane. showMessageDia Log (null,"用户名不存在"'" 警告”,JOptionPane .MARNING_MESSAGE); return false; }} 〃确定是否为管理员 public static boolean sureadmin(String user) { Connection con = tDB(); PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from usertable where user = ?" try { preSql = eStatement(sqlStr); ing(l, user); rs = eQuery(); while(()) { int admin = (5); if (admin==l) { return true; 32 )else { return false; }} (); return true; ) catch (SQLException e) { return false; })} Test 包 : package Test; import .*; import Event; import Listener; import .*; import o; import ace; import ce; public class LandTest { private JLabel jLabel = new J Label ("图书管理系统”);33 private DLabel jLabel2 = new 3Label("用户名:"); private DLabel jLabel3 = new 3Label("密 码:”); private Font font = new Font("宋体, 40); private Font font2 = new Font("宋体”,, 25); private Font font3 = new Font("宋体",, 20); private DTextField field = new 3TextField(22); private DPasswordField field2 = new 3PasswordField(22); private JButton button = new J Button ("登陆”); private JButton button2 = new JButton("注册”); private private private private 3Panel JPanel JPanel JPanel JPanel jPanel = new JPanel(); jPanel2 = new jPanel3 = new jPanel4 = new jPanelS = new JPanel(); 3Panel(); JPanel(); 3Panel(); private private JFrame frame = new J Frame ("登陆”); private Dimension dimension = new Dimension(30, 30); private Dimension dimension2 = new Dimension(100, 50); public String user; private String password; public LandTest() { frame .setTitle("登陆”); e(550, 500); ationRelativeTo(null); 35 out(null); Toolkit t = auLtTooLkit^; Image image = ge(""); nimage(image); addassembly(); transparent(); addEvent(); Icon i = new Imageicon(""); JLabel Label = new JLabel(i); nds(0, 0, 550, 500); (Label); izable(false); frame. setDef aultCloseOperation (J F name. EXIT_ON_CLOSE'); ible(true);} private void addassembly() { t(font); j t(font2); j t(font2); t(font3); t(font3); t(font3); t(font3); ferredSize(dimension); ferredSize(dimension); ferredSize(dimension2); ferredSize(dimension2); (jLabel); 35 (jLabel2); (field); (jLabel3); (field2); (button); (button2); nds(0, 60, 550, 80); nds(0, 160, 550, 80); nds(0, 250, 550, 60); nds(100, 325, 150, 80); nds(275, 325, 150, 80); (jPanel); (jPanel2); (jPanel3); (jPanel4); (jPanelS);} private void transparent() ( que(false); que(false); que(false); que(false); que(false); que(false); que(false); que(false); que(false); que(false);) private void addEvent() { ionListener(new ActionListener() { 36 public void actionPerformed(ActionEvent e) { user = t().trim(); password = t(); if((user, password)) { DOptionPane. shoMMessageDia Log (null f "登陆成功”); e(); new MainFace(user); )else { empty。; }} }); ionListener(new ActionListener() ( public void actionPerformed(ActionEvent e) ( e(); new LogonFace();) }); } private void empty() { field. setText(,,H); t("”); } public static void main(String[] args) ( new LandTest(); }} 37 View 包 : package View; import .*; import .*; import ; import .*; import .*; import Dao; public class ABorrowBookFace extends JFrame ( private DPanel jPanel = new JPanel(); private DLayeredPane jLayeredPane = new 3LayeredPane(); private JLabel jLabel = new J Label ("借书记录”); private JLabel jLabel2 = new JLabel(,f请选择査询方式:“); private DTextField field = new 3TextField(20); private 3ComboBox private JButton button = new JButton("搜索”); private Font font = new Font("宋体”,, 40); 38 private Font font2 = new private Font font3 = new private Font font4 = new Font("宋体“,, 20); Font("宋体",, 18); Font(“宋体",, 17); model = new DefaultTableModel(); public DefaultTableModel private String s; private int num; public ABorrowBookFace() { Icon i = new Imageicon(""); JLabel Label = new JLabel(i); nds(0, 0, 850, 100); setLayout(null); setSize(850, 65。); setLocationRelativeTo(null); t(font); j nds(345, 80, 400, 100); j t(font4); nds(95, 140, 250, 30); box. additem (“按照用户名查找”); box. additem (”按照书号査找”); t(font3); nds(95, 175, 160, 30); que(false); t(font2); kground();39 nds(325, 175, 200, 30); que(false); t(font2); nds(590, 173, 80, 35); kground(); que(false); (jLabel); (jLabel2); (box); (field); (button); umn("用户名", new Vector umn("书号",new Vector ()); umn("借书日期",new Vector Vector umn("状态",new Vector JTable jTable = new 3Table(model); JScrollPane pane = new JScrollPane(jTable); nds(80, 220, 690, 340); (pane); rou^model); setTitle("借书记录“); 40 setResizable(false); addEvent(); JTableHeader head = leHeader(); ferredSize(new Dimension(th(), 30)); t(new Font("宋体",, 20)); kground(); Height(30); t(new Font(”宋体”,_BASELINEf 17)); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); izontalAlignment(DefaultTableCellRenderer.C£ NTER); aultRenderer(, renderer); nds(0, 0, 850, 250); que(false); out(null); setContentPane(jLayeredPane); add(jPanel); add(Label); setVisible(true); } private void addEvent() ( s ="按照用户名査找”; mListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (teChange() == ED) ( s = (String) m(); 41 }} }); ionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Count(O); if ((”按照用户名査找")){ try ( String user = t().trim(); rrow(model, user); ) catch (Exception el) { } } else if ((”按照书号查找”)){ try { num = nt(t().trim()); borrou^model, num); ) catch (Exception el) {}) field. setText(^,,,); }}); }) : package View; import .*; import .*; import .*; 42 import .*; import .*; import ; public class AccountMsaFace extends JFrame { private DPanel jPanel = new JPanel(); private DLayeredPane jLayeredPane = new 3LayeredPane(); private J Label j Label = new J Label ("账户信息"); private Font font = new Font("宋体”', 40); public DefaultTableModel model = new DefaultTableModel(); public AccountMsgFace() { Icon i = new Imagelcon(""); JLabel Label = new JLabel(i); nds(0, 0, 800, 100); setLayout(null); setSize(800, 600); setLocationRelativeTo(null); t(font); nds(315, 80, 400, 100); (jLabel); umn("用户名",new Vector umn("学号new Vector umn("姓名",new Vector umn("是否为管理员",new Vector DTable jTable = new JTable(model); JScrollPane pane = new JScrollPane(jTable); 43 nds(80, 160, 640, 350); (pane); JTableHeader head = leHeader(); ferredSize(new Dimension(th(), 30)); t(new Font("宋体",, 20)); kground(); Height(30); t(new Font(“宋体",_BASELINE, 17)); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); izontalAlignment(DefaultTableCellRenderer.C£ NTER); aultRenderer(; renderer); borrow(model); nds(0, 0, 800, 200); que(false); out(null); setContentPane(jLayeredPane); setTitleC* 账户信息“); setResizable(false); add(jPanel); add(Label); setVisible(true); } private void borrow(DefaultTableModel model) ( 44 Connection con = DB .connectDBO; PreparedStatement preSql; ResultSet rs; String sqlStr = "select * from usertable"; try { preSql = eStatement(sqlStr); rs = eQuery(); while (()) ( String user = ing(l); String studentid = ing(2); String name = ing(3); int flag = (S); String admin; if (flag == 1) ( admin =”是"; ) else { admin ="否“; ) (new Vector<>(£ist(user, studentid, name, admin))); ) (); } catch (SQLException e) ( ) }} : package View; 45 import .*; import .*; import .*; import .*; import o; public class AddBookFace extends JFrame( private DPanel jPanel = new 3Panel(); private DLabel jLabel = new J Label ("添加图书");private JLabel jLabel2 = new JLabel("类 另!j :"); private JLabel jLabel3 = new JLabel("书 名:"); private JLabel jLabel4 = new JLabel("作 者:”); private JLabel jLabelS = new JLabel("出版社:"); 46 private JLabel jLabel6 = new 3Label("价格:"); private private private private private JTextField DTextField DTextField JTextField field = new 3TextField(20); field2 = new field3 = new field4 = new JTextField(20); 3TextField(20); JTextField(20); new 3ComboBox 3ComboBox private JButton button = new 3Button("确定”); private Font font = new Font("宋体, 40); private Font font2 = new Font("宋体", private Font font3 = new Font(” 宋体”, public DefaultTableModel model = new DefaultTableModel(); private String s; public AddBookFace() ( Icon i = new Imagelcon(""); JLabel Label = new JLabel(i); nds(0, 0, 580, 100); setLayout(null); setSize(580, 650); setTitle("添加图书”); setLocationRelativeTo(null); t(font); nds(195, 80, 400, 100); j t(font2); nds(125, 200, 250, 30); j t(font2); nds(125, 260, 250, 30); j t(font2); 47 , 25);, 20); nds(125, 320, 250, 30); t(font2); nds(125, 380, 250, 30); j t(font2); nds(125, 440, 250, 30); box. additem ("请选择类别"); BookDao. findcategory (box); t(font3); nds(245, 200, 200, 30); que(false); t(font3); kground(); nds(245, 260, 200, 30); que(false); t(font3); kground(); nds(245, 320, 200, 30); que(false); t(font3); kground(); nds(245, 380, 200, 30); que(false);48 t(font3); kground(); nds(245, 440, 200, 30); que(false); t(font2); nds(120, 515, 325, 35); kground(); que(false); (jLabel); (jLabel2); (jLabel3); (jLabel4); (jLabels); (jLabel6); (box); (field); (field2); (field3); (field4); (button); add(); nds(0, 0, 850, 650); que(false); out(null); add(jPanel); add(Label); 49
版权声明:本文标题:java+swing+mysql图书管理系统(附完整源代码) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1707227574h512500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论