一秒学会!拖拖拽拽,设计个图书借阅管理系统,图书借阅管理系统总结

Tina 622 2022-07-01

在企业文化建设中,会有不少公司在创办自己的图书馆,以营造更好的学习氛围,为员工提供优良的学习环境。


但图书的借出、归还、图书信息管理对于行政人员来说是个比较麻烦的事,总是拿纸笔来登记、记录不仅麻烦、易丢失,而且对所有图书及人员的借阅数据进行分析。


缺乏有效的统计和分析,便难以了解各分类图书的借阅频次或者各部门人员的借阅次数,知晓哪些是受欢迎的图书,哪些人员爱读书,无法完美实现团队阅读文化、学习氛围的营造和建设。


那么想要一款无需编码、任意定制的在线、移动图书管理系统,该从何做起呢?


下面我们一起来看!


图书信息表

用来记录、管理企业图书馆的所有图书信息。

  • 字段设置:

图书编号-单行文本,书名-当行文本,图书分类-下拉框/单选按钮,作者-单行文本,出版社-单行文本,定价-数字,借阅状态-单行文本(默认值:可借阅)

*注:“图书编号”可以开启单行文本的扫码输入,直接扫图书的出版条形码获取图书的唯一编码。 如下图。


图书借阅申请

用来获取员工的借阅申请,借出记录,归还记录信息。并根据借出、归还,自动修改图书信息表里的图书借阅状态(简道云的智能助手功能)。

图书借阅是需要有人来审批的,所以这个表单采用流程表单设计。

流程设计如下(根据自己公司内部流程定制):

  • 字段设置:

① 员工申请节点:

借阅状态-单行文本(默认值:可借阅;用来限制用户浏览到的图书都是可借阅的)

部门-部门单选

借阅人-成员单选

书名-单行文本(数据联动)

图书信息-关联查询(关联条件限定,根据图书名称来唯一限定)

② 借阅审批节点:

借阅审批-单选按钮

借出时间-日期时间

到期时间-日期时间(可设置默认借阅时长)

借出签字-手写签名(借出东西总是要签字画押确认的)


③ 图书归还节点:

是否归还-单选按钮

归还时间-日期时间

借阅次数-数字(借阅审批=同意为1,否则为0)


借阅状态变更

图书借阅的申请审批过后,员工领取图书并签字确认后,该图书的借阅状态就该变更为已借出,将无法再在借阅申请里出现这本书的书名了(因为有借阅状态的联动设置)。

而当员工归还图书,行政人员做好归还登记后,即填写归还日期后,则改图书的借阅状态就该回复为可借阅状态了。


图书借阅统计分析

图书买了一本本,借阅审批一条条,到底哪些部门、哪些个人在借书?他们有喜欢看什么类型的书?哪本书最受欢迎?

这些就需要看下图了!

这个仪表盘的数据来源于图书信息表和图书借阅审批表,经过数据工厂的加工后的复合数据。

到此,一个图书借阅管理系统就定制完毕了,完全不需要任何码代码的过程,全程拖拽搞定。

图书借阅管理系统java代码

本文实例为大家分享了java实现简单图书借阅系统的具体代码,供大家参考,具体内容如下

直接看代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
package ttt;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
public class Labmsys extends JFrame{
        JTable booktable=null;
        static DefaultTableModel bookmodel=null;
        JTable borrowtable=null;
        static DefaultTableModel bmodel=null;
        JPanel j1=new JPanel();
        JPanel j2=new JPanel();
        JPanel j3=new JPanel();
        JButton button1=new JButton("借书");
        JButton button2=new JButton("还书");
 
    public Labmsys()
    {
        this.setLayout(new BorderLayout());
        this.add(j1,BorderLayout.WEST);
        this.add(j2,BorderLayout.EAST);
        this.add(j3,BorderLayout.CENTER);
        j1.setBorder(new TitledBorder("图书借书表"));
        j2.setBorder(new TitledBorder("图书库存表"));
        this.booktable=bookIn();
        this.borrowtable=borrowIn();
        JScrollPane  jsp1=new JScrollPane(borrowtable);
        JScrollPane  jsp2=new JScrollPane(booktable);
        j1.add(jsp1);
        j2.add(jsp2);
        j3.add(button1);
        j3.add(button2);
        //添加借书监听器
        button1.addActionListener(new ActionListener()
        {
 
            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                int rowNum=booktable.getSelectedRow();
                System.out.println(rowNum);
                if(rowNum>=0)
                {
                    String isbn=booktable.getValueAt(rowNum, 0).toString();
                    System.out.println(isbn);
                    int count=Integer.parseInt((String) booktable.getValueAt(rowNum, 2));
                    String s=JOptionPane.showInputDialog("请输入学号");
                    if(count<=0)
                        JOptionPane.showMessageDialog(null,"图书库存不足");
                    else if (null==s)
                        JOptionPane.showMessageDialog(null,"请输入学号");
                    else{
                        if(borrowBook(isbn,s))
                        {
                            System.out.println("yes");
                            JOptionPane.showMessageDialog(null,"successful!");
                        }
                        else JOptionPane.showMessageDialog(null,"Wrong!");
                    }
                }else JOptionPane.showMessageDialog(null,"Choose book!");
 
            }
      });
        //添加还书监听器
        button2.addActionListener(new ActionListener()
        {
 
            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                int rowNum=borrowtable.getSelectedRow();
                System.out.println(rowNum);
                if(rowNum>=0)
                {
                    String isbn=borrowtable.getValueAt(rowNum, 2).toString();
                    String tablexh = borrowtable.getValueAt(rowNum, 1).toString();
                    System.out.println(isbn);
                    String xh=JOptionPane.showInputDialog("请输入学号");
                    if (!xh.equals(tablexh))
                        JOptionPane.showMessageDialog(null,"学号不正确");
                    else{
                        if(returnBook(isbn))
                        {
                            JOptionPane.showMessageDialog(null,"successful!");
                        }
                        else JOptionPane.showMessageDialog(null,"Wrong!");
                    }
                }else JOptionPane.showMessageDialog(null,"Choose book!");
                }
            });
 
    }
 
    public boolean borrowBook(String isbn, String s) {
                int xh = Integer.parseInt(s);
                int isbn2 =Integer.parseInt(isbn);
                System.out.println("学号:"+xh);
        boolean b=false;
        String driver="com.mysql.jdbc.Driver";
        String url="jdbc:mysql://localhost:3306/test";
        String user="root";
        String password="123456";
 
        Connection conn=null;
        Statement stmt=null;
 
        try {  
               Class.forName(driver); 
               conn = DriverManager.getConnection(url, user, password);  
               stmt = conn.createStatement();  
 
               System.out.println("isbn:"+isbn);
               conn.setAutoCommit(false);
               String sql1 = "update book set count=count-1 where isbn='"+isbn2+"'";
               String sql2 = "insert into borrow(xh,isbn) values('"+xh+"','"+isbn2+"')";
               stmt.executeUpdate(sql1);
 
               stmt.executeUpdate(sql2);
               System.out.println("isbn2:"+isbn2);
               //stmt = (PreparedStatement) conn.prepareStatement("update book set count=count-1 where isbn=?");
 
               conn.commit();
               stmt.close();
               conn.close();
               b=true;
        }
        catch (Exception e) {  
               try{
                   conn.rollback();
               }catch(Exception e1){e1.printStackTrace();}
              }  
              return b;
            }
 
    private boolean returnBook(String isbn) {
        int isbn2 =Integer.parseInt(isbn);
 
           boolean b=false;
           String driver="com.mysql.jdbc.Driver";
           String url="jdbc:mysql://localhost:3306/test";
           String user="root";
           String password="123456";
  
           Connection conn=null;
           Statement stmt=null;
  
           try {  
             Class.forName(driver); 
             conn = DriverManager.getConnection(url, user, password);  
             stmt = conn.createStatement();  
             conn.setAutoCommit(false);
             stmt.executeUpdate("delete from borrow where isbn='"+isbn2+"'");
             stmt.executeUpdate("update book set count=count+1 where isbn='"+isbn2+"'");
             System.out.println("还书isbn2:"+isbn2);
             conn.commit();
             stmt.close();
             conn.close();
             b=true;
             }
           catch (Exception e) {  
               try{
                   conn.rollback();
                   }catch(Exception e1){e1.printStackTrace();}}  
           return b;
    }
 
    private JTable borrowIn() {
        // TODO Auto-generated method stub
        String []head={"id","xh","ISBN"};
        String [][]data=null;
        bookmodel=new DefaultTableModel(data,head);
        JTable t=new JTable(bookmodel);
        String driver="com.mysql.jdbc.Driver";
        String url="jdbc:mysql://localhost:3306/test";
        String user="root";
        String password="123456";
 
        Connection conn=null;
        Statement stmt=null;
        ResultSet rs=null;
        try {  
               Class.forName(driver); 
 
               conn = DriverManager.getConnection(url, user, password);  
               stmt = conn.createStatement();  
               rs=stmt.executeQuery("select * from borrow"); 
               String[] row=new String[3];
               while(rs.next()){
               row[0]=rs.getString(1);
               row[1]=rs.getString(2);
               row[2]=rs.getString(3);
               bookmodel.addRow(row);
               bookmodel.fireTableDataChanged(); }
               rs.close();
               stmt.close();
               conn.close();}
 
        catch (Exception e) {  
               // TODO Auto-generated catch block     
               System.out.println(e);  
              }  
              return t;
    }
  
    public  JTable bookIn() {
        // TODO Auto-generated method stub
        String []head={"ISBN","name","count"};
        String [][]data=null;
        bmodel=new DefaultTableModel(data,head);
        JTable t=new JTable(bmodel);
        String driver="com.mysql.jdbc.Driver";
        String url="jdbc:mysql://localhost:3306/test";
        String user="root";
        String password="123456";
 
        Connection conn=null;
        Statement stmt=null;
        ResultSet rs=null;
        try {  
               Class.forName(driver); 
 
               conn = DriverManager.getConnection(url, user, password);  
               stmt = conn.createStatement();  
               rs=stmt.executeQuery("select * from book"); 
               String[] row=new String[3];
               while(rs.next()){
               row[0]=rs.getString(1);
               row[1]=rs.getString(2);
               row[2]=rs.getString(3);
               bmodel.addRow(row);
               bmodel.fireTableDataChanged(); }
               rs.close();
               stmt.close();
               conn.close();}
 
        catch (Exception e) {  
               // TODO Auto-generated catch block     
               System.out.println(e);  
              }
        return t;  
    }
  
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Labmsys n=new Labmsys(); 
        n.setTitle("图书借阅管理系统");
        n.setSize(1000,500);
        n.setLocationRelativeTo(null);
        n.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        n.setVisible(true);
    }
 
}

数据库:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--
-- Table structure for table `book`
--
 
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
  `ISBN` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `count` int(11) default NULL,
  PRIMARY KEY  (`ISBN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
--
-- Dumping data for table `book`
--
 
LOCK TABLES `book` WRITE;
/*!40000 ALTER TABLE `book` DISABLE KEYS */;
INSERT INTO `book` VALUES (662530,'c#',9),(662545,'python',12),(663520,'c++',6),(663548,'java',8);
/*!40000 ALTER TABLE `book` ENABLE KEYS */;
UNLOCK TABLES;
 
--
-- Table structure for table `borrow`
--
 
DROP TABLE IF EXISTS `borrow`;
CREATE TABLE `borrow` (
  `id` int(11) NOT NULL auto_increment,
  `xh` int(11) NOT NULL,
  `isbn` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
--
-- Dumping data for table `borrow`
--
 
LOCK TABLES `borrow` WRITE;
/*!40000 ALTER TABLE `borrow` DISABLE KEYS */;
INSERT INTO `borrow` VALUES (1006,123456,662545),(1007,456789,663520),(1009,789456,6


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何向wps表添加密码(wps表格怎么加密码怎么设置)
下一篇:wps表如何恢复菜单栏?(wps表格开始菜单自动隐藏如何恢复)
相关文章