-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuanLySach.java
1655 lines (1501 loc) · 80.6 KB
/
QuanLySach.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package quanlythuvien;
/**
*
* @author Đình Phúc
*/
import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.IBodyElement;
import org.apache.poi.xwpf.usermodel.TableRowAlign;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRun;
public class QuanLySach extends javax.swing.JFrame {
private DefaultTableModel model;
private MyConnect myConnect = new MyConnect();
private Connection conn = myConnect.connect();
private PreparedStatement ps = null;
private int rowID = 0;
private boolean fileOut = true; //Cờ xuất file
public QuanLySach() {
initComponents();
model = (DefaultTableModel) Table1.getModel();
showTable(getListSach()); // hiển thị sách trong database
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton10 = new javax.swing.JButton();
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
jMenuItem1 = new javax.swing.JMenuItem();
jPopupMenu1 = new javax.swing.JPopupMenu();
XoaHang = new javax.swing.JMenuItem();
jTabbedPane1 = new javax.swing.JTabbedPane();
jDesktopPane1 = new javax.swing.JDesktopPane();
jScrollPane16 = new javax.swing.JScrollPane();
Table1 = new javax.swing.JTable();
jLayeredPane1 = new javax.swing.JLayeredPane();
tenTG = new javax.swing.JTextField();
tenSach = new javax.swing.JTextField();
giaTien = new javax.swing.JTextField();
tongSoLuong = new javax.swing.JTextField();
maSach = new javax.swing.JTextField();
nXB = new javax.swing.JTextField();
theLoai = new javax.swing.JTextField();
namXB = new javax.swing.JTextField();
soLuongCon = new javax.swing.JTextField();
jLayeredPane2 = new javax.swing.JLayeredPane();
jLabel3 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
comboTimKiem = new javax.swing.JComboBox<>();
jLabel8 = new javax.swing.JLabel();
timKiem = new javax.swing.JTextField();
nhap = new javax.swing.JButton();
jLayeredPane3 = new javax.swing.JLayeredPane();
xoa = new javax.swing.JButton();
them = new javax.swing.JButton();
sua = new javax.swing.JButton();
seeAll = new javax.swing.JButton();
jLayeredPane4 = new javax.swing.JLayeredPane();
xuatSach = new javax.swing.JButton();
AddToDB = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jDesktopPane4 = new javax.swing.JDesktopPane();
TKTenSach = new javax.swing.JButton();
TKTheLoai = new javax.swing.JButton();
TKNXB = new javax.swing.JButton();
thongKeSach = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
Table2 = new javax.swing.JTable();
jLabel14 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
xuatTKe = new javax.swing.JButton();
jButton10.setText("jButton10");
jMenuItem1.setText("jMenuItem1");
XoaHang.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
XoaHang.setText("Xóa Hàng");
XoaHang.setToolTipText("");
XoaHang.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
XoaHangActionPerformed(evt);
}
});
jPopupMenu1.add(XoaHang);
setTitle("LÊ ĐÌNH PHÚC _ 20163184 _ Quản Lý Sách");
jTabbedPane1.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
jTabbedPane1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jDesktopPane1.setBackground(new java.awt.Color(3, 48, 80));
jDesktopPane1.setForeground(new java.awt.Color(255, 255, 255));
Table1.setAutoCreateRowSorter(true);
Table1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
Table1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
" Mã Sách", " Tên Sách", " Tên Tác Giả", " Nhà Xuất Bản", " Năm Xuất Bản", " Giá Tiền", " Thể Loại", " Số Lượng Còn", " Tổng Số Lượng"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
Table1.setComponentPopupMenu(jPopupMenu1);
Table1.setRowHeight(24);
Table1.addAncestorListener(new javax.swing.event.AncestorListener() {
public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
}
public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
Table1AncestorAdded(evt);
}
public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
}
});
Table1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
Table1MouseClicked(evt);
}
});
jScrollPane16.setViewportView(Table1);
tenTG.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
tenTG.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tenTGActionPerformed(evt);
}
});
tenSach.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
giaTien.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
tongSoLuong.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
maSach.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
maSach.setToolTipText("Sxxx ( Ví dụ S001)");
nXB.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
theLoai.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
namXB.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
namXB.setToolTipText("YYYY-MM-DD");
soLuongCon.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLayeredPane1.setLayer(tenTG, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(tenSach, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(giaTien, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(tongSoLuong, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(maSach, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(nXB, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(theLoai, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(namXB, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(soLuongCon, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jLayeredPane1Layout = new javax.swing.GroupLayout(jLayeredPane1);
jLayeredPane1.setLayout(jLayeredPane1Layout);
jLayeredPane1Layout.setHorizontalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(nXB, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tenTG, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(maSach, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tenSach, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(soLuongCon, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(theLoai, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(giaTien, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(namXB, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tongSoLuong, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(30, Short.MAX_VALUE))
);
jLayeredPane1Layout.setVerticalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(maSach, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(tenSach, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(tenTG, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(nXB, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(namXB, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(giaTien, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(theLoai, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(soLuongCon, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(tongSoLuong, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Tên Tác Giả");
jLabel9.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel9.setForeground(new java.awt.Color(255, 255, 255));
jLabel9.setText("Tổng Số Lượng");
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Nhà Xuất Bản");
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setText("Thể Loại");
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Giá Tiền");
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setText("Năm Xuất Bản");
jLabel10.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Số Lượng Còn");
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Tên Sách");
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Mã Sách");
jLayeredPane2.setLayer(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane2.setLayer(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jLayeredPane2Layout = new javax.swing.GroupLayout(jLayeredPane2);
jLayeredPane2.setLayout(jLayeredPane2Layout);
jLayeredPane2Layout.setHorizontalGroup(
jLayeredPane2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jLayeredPane2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addGroup(jLayeredPane2Layout.createSequentialGroup()
.addGap(2, 2, 2)
.addComponent(jLabel6))
.addComponent(jLabel7)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addContainerGap())
);
jLayeredPane2Layout.setVerticalGroup(
jLayeredPane2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(55, 55, 55)
.addComponent(jLabel2)
.addGap(56, 56, 56)
.addComponent(jLabel3)
.addGap(43, 43, 43)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(46, 46, 46)
.addComponent(jLabel5)
.addGap(55, 55, 55)
.addComponent(jLabel6)
.addGap(57, 57, 57)
.addComponent(jLabel7)
.addGap(57, 57, 57)
.addComponent(jLabel10)
.addGap(58, 58, 58)
.addComponent(jLabel9)
.addContainerGap())
);
comboTimKiem.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
comboTimKiem.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Tìm Kiếm Theo Mã Sách", "Tìm Kiếm Theo Tên Sách", "Tìm Kiếm Theo Thể Loại", "Tìm Kiếm Theo Tên Tác Giả", "Tìm Kiếm Theo Nhà Xuất Bản" }));
comboTimKiem.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
comboTimKiemMouseClicked(evt);
}
});
comboTimKiem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboTimKiemActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
jLabel8.setForeground(new java.awt.Color(255, 255, 255));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Tìm Kiếm: ");
timKiem.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
timKiem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
timKiemActionPerformed(evt);
}
});
nhap.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
nhap.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/if_import-download-save_2931171.png"))); // NOI18N
nhap.setText("Nhập File");
nhap.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nhapActionPerformed(evt);
}
});
xoa.setBackground(new java.awt.Color(255, 0, 52));
xoa.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
xoa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/remove.png"))); // NOI18N
xoa.setText("Xóa");
xoa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xoaActionPerformed(evt);
}
});
them.setBackground(new java.awt.Color(204, 255, 204));
them.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
them.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/ínert.png"))); // NOI18N
them.setText("Thêm");
them.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
themActionPerformed(evt);
}
});
sua.setBackground(new java.awt.Color(255, 255, 56));
sua.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
sua.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/sửa.png"))); // NOI18N
sua.setText("Sửa");
sua.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
suaActionPerformed(evt);
}
});
jLayeredPane3.setLayer(xoa, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane3.setLayer(them, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane3.setLayer(sua, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jLayeredPane3Layout = new javax.swing.GroupLayout(jLayeredPane3);
jLayeredPane3.setLayout(jLayeredPane3Layout);
jLayeredPane3Layout.setHorizontalGroup(
jLayeredPane3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(them)
.addGap(51, 51, 51)
.addComponent(sua, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(xoa, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29))
);
jLayeredPane3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {sua, them});
jLayeredPane3Layout.setVerticalGroup(
jLayeredPane3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jLayeredPane3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jLayeredPane3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(them, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sua, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xoa, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jLayeredPane3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {sua, them, xoa});
seeAll.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
seeAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/see.png"))); // NOI18N
seeAll.setText("Hiện Thị Tất Cả");
seeAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
seeAllActionPerformed(evt);
}
});
xuatSach.setBackground(new java.awt.Color(0, 204, 204));
xuatSach.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
xuatSach.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/if_output-1_2916359.png"))); // NOI18N
xuatSach.setText("Xuất File");
xuatSach.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xuatSachActionPerformed(evt);
}
});
jLayeredPane4.setLayer(xuatSach, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jLayeredPane4Layout = new javax.swing.GroupLayout(jLayeredPane4);
jLayeredPane4.setLayout(jLayeredPane4Layout);
jLayeredPane4Layout.setHorizontalGroup(
jLayeredPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jLayeredPane4Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(xuatSach))
);
jLayeredPane4Layout.setVerticalGroup(
jLayeredPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(xuatSach, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
);
AddToDB.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
AddToDB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/add dâtbase.png"))); // NOI18N
AddToDB.setText("Thêm Vào CSDL");
AddToDB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AddToDBActionPerformed(evt);
}
});
jDesktopPane1.setLayer(jScrollPane16, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(jLayeredPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(jLayeredPane2, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(comboTimKiem, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(timKiem, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(nhap, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(jLayeredPane3, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(seeAll, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(jLayeredPane4, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane1.setLayer(AddToDB, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jDesktopPane1Layout = new javax.swing.GroupLayout(jDesktopPane1);
jDesktopPane1.setLayout(jDesktopPane1Layout);
jDesktopPane1Layout.setHorizontalGroup(
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLayeredPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(24, 24, 24)
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE))
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addComponent(jLayeredPane3)
.addGap(18, 18, 18))
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addComponent(comboTimKiem, 0, 0, Short.MAX_VALUE)
.addGap(42, 42, 42)
.addComponent(jLayeredPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(timKiem, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 1211, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addComponent(nhap)
.addGap(173, 173, 173)
.addComponent(AddToDB)
.addGap(115, 115, 115)
.addComponent(seeAll)
.addGap(168, 168, 168))))
);
jDesktopPane1Layout.setVerticalGroup(
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLayeredPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jDesktopPane1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 677, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jLayeredPane3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(timKiem, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane16))
.addGap(18, 18, 18)
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(seeAll, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nhap, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(AddToDB, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(comboTimKiem, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLayeredPane4))
.addGap(18, 18, 18))
);
jTabbedPane1.addTab("Cập Nhật Sách & Tìm Kiếm", jDesktopPane1);
jDesktopPane4.setBackground(new java.awt.Color(3, 48, 80));
TKTenSach.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
TKTenSach.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/statistic.png"))); // NOI18N
TKTenSach.setText("Theo Tên Sách");
TKTenSach.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TKTenSachActionPerformed(evt);
}
});
TKTheLoai.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
TKTheLoai.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/statistic.png"))); // NOI18N
TKTheLoai.setText("Theo Thể Loại");
TKTheLoai.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TKTheLoaiActionPerformed(evt);
}
});
TKNXB.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
TKNXB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/statistic.png"))); // NOI18N
TKNXB.setText("Theo Nhà Xuất Bản");
TKNXB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TKNXBActionPerformed(evt);
}
});
thongKeSach.setFont(new java.awt.Font("Tahoma", 0, 28)); // NOI18N
thongKeSach.setForeground(new java.awt.Color(255, 255, 255));
thongKeSach.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
thongKeSach.setText("Thống Kê Sách ");
Table2.setAutoCreateRowSorter(true);
Table2.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
Table2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
}
));
Table2.setRowHeight(26);
jScrollPane1.setViewportView(Table2);
jLabel14.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel14.setForeground(new java.awt.Color(255, 255, 255));
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel14.setText("GVHD: ThS LÊ THỊ HOA");
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
jLabel12.setForeground(new java.awt.Color(255, 255, 255));
jLabel12.setText("Thống Kê Sách:");
xuatTKe.setBackground(new java.awt.Color(0, 153, 51));
xuatTKe.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
xuatTKe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/quanlythuvien/icon/if_output-1_2916359.png"))); // NOI18N
xuatTKe.setText("Xuất File");
xuatTKe.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
xuatTKeActionPerformed(evt);
}
});
jDesktopPane4.setLayer(TKTenSach, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(TKTheLoai, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(TKNXB, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(thongKeSach, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(jLabel14, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(jLabel12, javax.swing.JLayeredPane.DEFAULT_LAYER);
jDesktopPane4.setLayer(xuatTKe, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jDesktopPane4Layout = new javax.swing.GroupLayout(jDesktopPane4);
jDesktopPane4.setLayout(jDesktopPane4Layout);
jDesktopPane4Layout.setHorizontalGroup(
jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane4Layout.createSequentialGroup()
.addGroup(jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane4Layout.createSequentialGroup()
.addGap(80, 80, 80)
.addGroup(jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jDesktopPane4Layout.createSequentialGroup()
.addComponent(TKTheLoai, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(xuatTKe))
.addComponent(TKTenSach, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TKNXB, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jDesktopPane4Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
.addComponent(thongKeSach, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1069, Short.MAX_VALUE))
);
jDesktopPane4Layout.setVerticalGroup(
jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDesktopPane4Layout.createSequentialGroup()
.addComponent(thongKeSach, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(TKTenSach, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53)
.addGroup(jDesktopPane4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TKTheLoai, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(xuatTKe, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(42, 42, 42)
.addComponent(TKNXB, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 423, Short.MAX_VALUE)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1)
);
jDesktopPane4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {TKNXB, TKTheLoai});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jDesktopPane4)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jDesktopPane4)
);
jTabbedPane1.addTab("Thống Kê", jPanel3);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 925, Short.MAX_VALUE)
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void tenTGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tenTGActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tenTGActionPerformed
private void xoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xoaActionPerformed
int choose = JOptionPane.showConfirmDialog(null, "Bạn có muốn thay xóa sách không ?",
"Quản Lý Sách _ Xóa", JOptionPane.YES_NO_OPTION);
if (choose == 0) {
boolean flag = remove();
if (flag) {
clearData();
// Xóa dòng tại vị trí rowID lấy từ action mouse click
model.removeRow(rowID);
}
} else {
clearData();
}
}//GEN-LAST:event_xoaActionPerformed
private void suaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_suaActionPerformed
int choose = JOptionPane.showConfirmDialog(null, "Bạn có muốn thay đổi dữ liệu không ?",
"Quản Lý Sách _ Sửa", JOptionPane.YES_NO_OPTION);
if (choose == 0) {
boolean flag = update();
if (flag) {
clearData();
}
}
}//GEN-LAST:event_suaActionPerformed
private void themActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_themActionPerformed
Sach s = new Sach();
s.setMaSach(maSach.getText());
s.setTenSach(tenSach.getText());
s.setTenTG(tenTG.getText());
s.setNXB(nXB.getText());
s.setNamXB(namXB.getText());
s.setGiaTien(Integer.parseInt(giaTien.getText()));
s.setTheLoai(theLoai.getText());
s.setSoLuongCon(Integer.parseInt(soLuongCon.getText()));
s.setTongSoLuong(Integer.parseInt(tongSoLuong.getText()));
boolean flag = addSach(s); //Nếu thêm sách thành công
if (flag) {
model.addRow(new Object[]{
s.getMaSach(), s.getTenSach(), s.getTenTG(), s.getNXB(), s.getNamXB(),
s.getGiaTien(), s.getTheLoai(), s.getSoLuongCon(), s.getTongSoLuong()
});
clearData();
}
}//GEN-LAST:event_themActionPerformed
private void Table1AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_Table1AncestorAdded
}//GEN-LAST:event_Table1AncestorAdded
private void TKTenSachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TKTenSachActionPerformed
ArrayList<Sach> sach = new ArrayList<Sach>();
int i = 0;
thongKeSach.setText("Thống Kê Sách Theo Tên Sách");
DefaultTableModel modelTK = (DefaultTableModel) Table2.getModel();
modelTK.setColumnIdentifiers(new Object[]{
" STT", " Tên Sách", " Số Lượng Còn ", " Tổng Số Lượng"
});
sach = tKeTheoTenSach();
removeAllRowTKe();
for (Sach s : sach) {
modelTK.addRow(new Object[]{
++i, s.getTenSach(), s.getSoLuongCon(), s.getTongSoLuong()
});
}
}//GEN-LAST:event_TKTenSachActionPerformed
private void TKTheLoaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TKTheLoaiActionPerformed
ArrayList<Sach> sach = new ArrayList<Sach>();
int i = 0;
thongKeSach.setText("Thống Kê Sách Theo Thể Loại");
DefaultTableModel modelTK = (DefaultTableModel) Table2.getModel();
modelTK.setColumnIdentifiers(new Object[]{
" STT", " Thể Loại", " Số Lượng Còn", " Tổng Số Lượng"
});
sach = tKeTheoTheLoai();
removeAllRowTKe();
for (Sach s : sach) {
modelTK.addRow(new Object[]{
++i, s.getTheLoai(), s.getSoLuongCon(), s.getTongSoLuong()
});
}
}//GEN-LAST:event_TKTheLoaiActionPerformed
private void TKNXBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TKNXBActionPerformed
ArrayList<Sach> sach = new ArrayList<Sach>();
int i = 0;
thongKeSach.setText("Thống Kê Sách Theo Nhà Xuất Bản");
DefaultTableModel modelTK = (DefaultTableModel) Table2.getModel();
modelTK.setColumnIdentifiers(new Object[]{
" STT", " Nhà Xuất Bản", " Số Lượng Còn", " Tổng Sô Lượng"
});
sach = tKeTheoNXB();
removeAllRowTKe();
for (Sach s : sach) {
modelTK.addRow(new Object[]{
++i, s.getTheLoai(), s.getSoLuongCon(), s.getTongSoLuong()
});
}
}//GEN-LAST:event_TKNXBActionPerformed
private void comboTimKiemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTimKiemActionPerformed
fileOut = false; //Cờ xuất file
ArrayList<Sach> sach = new ArrayList<Sach>();
Object obj = evt.getSource();
if (obj == comboTimKiem) {
int index = comboTimKiem.getSelectedIndex();
switch (index) {
case 0:
sach = tKTheoMaSach();
break;
case 1:
sach = tKTheoTenSach();
break;
case 2:
sach = tKTheoTheLoai();
break;
case 3:
sach = tKTheoTenTG();
break;
case 4:
sach = tKTheoNXB();
break;
}
removeAllRow();
showTable(sach);
}
}//GEN-LAST:event_comboTimKiemActionPerformed
private void Table1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Table1MouseClicked
rowID = Table1.getSelectedRow();
maSach.setText(Table1.getValueAt(rowID, 0).toString());
tenSach.setText(Table1.getValueAt(rowID, 1).toString());
tenTG.setText(Table1.getValueAt(rowID, 2).toString());
nXB.setText(Table1.getValueAt(rowID, 3).toString());
namXB.setText(Table1.getValueAt(rowID, 4).toString());
giaTien.setText(Table1.getValueAt(rowID, 5).toString());
theLoai.setText(Table1.getValueAt(rowID, 6).toString());
soLuongCon.setText(Table1.getValueAt(rowID, 7).toString());
tongSoLuong.setText(Table1.getValueAt(rowID, 8).toString());
}//GEN-LAST:event_Table1MouseClicked
private void addRowData2(XWPFTable table, int lastRowPosition) {
for (int i = lastRowPosition - 1; i < Table2.getRowCount(); i++) {
XWPFTableRow newRow = table.createRow();
for (int j = 0; j < table.getRow(i).getTableCells().size(); j++) {
newRow.getCell(j).setText(Table2.getValueAt(i, j).toString());
}
}
}
private void xuatSachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xuatSachActionPerformed
String fileName = System.getProperty("user.home");
String f1 = "\\Documents\\NetBeansProjects\\Quanlythuvien\\Quản Lý Sách\\";
String f2 = null;
if (fileOut == true) {
f2 = "Thông Tin Sách.docx";
} else {
if (comboTimKiem.getSelectedItem().equals("Tìm Kiếm Theo Mã Sách")) {
f2 = "Tìm Kiếm Sách Theo Mã Sách.docx";
} else if (comboTimKiem.getSelectedItem().equals("Tìm Kiếm Theo Tên Sách")) {
f2 = "Tìm Kiếm Sách Theo Tên Sách.docx";
} else if (comboTimKiem.getSelectedItem().equals("Tìm Kiếm Theo Thể Loại")) {
f2 = "Tìm Kiếm Sách Theo Thể Loại.docx";
} else if (comboTimKiem.getSelectedItem().equals("Tìm Kiếm Theo Tên Tác Giả")) {
f2 = "Tìm Kiếm Sách Theo Tên Tác Giả.docx";
} else {
f2 = "Tìm Kiếm Sách Theo Nhà Xuất Bản.docx";
}
}
fileName = fileName + f1 + f2;
try {
InputStream file = new FileInputStream(fileName);
XWPFDocument hdoc = new XWPFDocument(OPCPackage.open(file));
Iterator bodyElementIterator = hdoc.getBodyElementsIterator();
// Chỗ này lại còn phải điều hướng fileOut
// for (XWPFParagraph p : hdoc.getParagraphs()) {
// List<XWPFRun> runs = p.getRuns();
// if (runs != null) {
// for (XWPFRun r : runs) {
// r.setFontSize(12);
// r.setFontFamily("Times New Roman");
// String text = r.getText(0);
// if (text != null) {
// if (text.contains("ngayxxx")) {
// SimpleDateFormat day = new SimpleDateFormat("dd");
// SimpleDateFormat month = new SimpleDateFormat("MM");
// SimpleDateFormat year = new SimpleDateFormat("yyyy");
// Date date = new Date();
// String ngay = day.format(date);
// String thang = month.format(date);
// String nam = year.format(date);
// text = text.replace("ngayxxx", "Ngày " + ngay + " Tháng " + thang + " Năm " + nam);
// r.setText(text, 0);
// break;
// }
// }
// }
// }
// }
while (bodyElementIterator.hasNext()) {
IBodyElement element = (IBodyElement) bodyElementIterator.next();
if ("TABLE".equalsIgnoreCase(element.getElementType().name())) {
//Danh sách tất cả Table trong file word
List<XWPFTable> tableList = element.getBody().getTables();
//Duyệt qua danh sách tất cả các table
for (XWPFTable table : tableList) {
//Căn bảng ở giữa file
table.setTableAlignment(TableRowAlign.CENTER);
// Xóa các dòng thừa trước khi thêm mới
while (table.getRow(1) != null) {
table.removeRow(1);
}
//Thêm các dòng từ jTable vào table trong word
for (int i = 1; i <= Table1.getRowCount(); i++) {
XWPFTableRow newRow = table.createRow();
for (int j = 0; j < table.getRow(i).getTableCells().size(); j++) {
newRow.getCell(j).setText(Table1.getValueAt(i - 1, j).toString());
}
}
}
}
}
OutputStream out = new FileOutputStream(fileName);
hdoc.write(out);
out.close();
} catch (IOException | InvalidFormatException ex) {
Logger.getLogger(QuanLySach.class.getName()).log(Level.SEVERE, null, ex);
}
//Mở file
try {
File myFile = new File(fileName);
Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
// no application registered for PDFs
ex.printStackTrace();
}
}//GEN-LAST:event_xuatSachActionPerformed
private void timKiemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timKiemActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_timKiemActionPerformed
private void nhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nhapActionPerformed
// TODO add your handling code here:
// đường dẫn
String path = null;
JFileChooser fileChooser = new JFileChooser();
// show ra một bảng chọn file
int rVal = fileChooser.showOpenDialog(null);
// nếu nhấn nút ok (tuỳ chọn APPROVE_OPTION)
if (rVal == JFileChooser.APPROVE_OPTION) {
String fileName = fileChooser.getSelectedFile().getName();
String dir = fileChooser.getCurrentDirectory().toString();
path = dir + "\\" + fileName;
} // nếu nhấn nút cancel trong bảng
else if (rVal == JFileChooser.CANCEL_OPTION) {
return;