激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|JavaScript|易語言|

香港云服务器
服務(wù)器之家 - 編程語言 - JAVA教程 - 圖書信息管理java實現(xiàn)代碼

圖書信息管理java實現(xiàn)代碼

2021-03-24 14:10曉曉jsw JAVA教程

這篇文章主要為大家詳細(xì)介紹了圖書信息管理java實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下

圖書信息管理與讀者信息管理相似,共包括兩部分,圖書添加和圖書查詢與修改,圖書信息添加要求正確輸入圖書的八項信息,并且isbn編號唯一,實現(xiàn)過程中要將isbn作為主鍵。下面看實現(xiàn)過程:

數(shù)據(jù)庫中書籍:

圖書信息管理java實現(xiàn)代碼

添加書籍過程:

圖書信息管理java實現(xiàn)代碼

數(shù)據(jù)庫內(nèi)容增加:

圖書信息管理java實現(xiàn)代碼

 

圖書的查詢與修改:查詢過程可以根據(jù)不同的條件查詢,如isbn,作者,出版社,圖書名稱等,默認(rèn)將所有圖書全部顯示在列表中,輸入查詢條件后再表格中顯示查詢結(jié)果。

本模塊用到標(biāo)簽面板,可以很方便的查詢所需要的信息。修改過程輸入isbn編號后按回車鍵將在下方顯示所有的圖書信息,然后修改圖書信息后所有內(nèi)容就會更新。

圖書查詢:

圖書信息管理java實現(xiàn)代碼

圖書信息修改:

圖書信息管理java實現(xiàn)代碼

添加圖書源代碼如下:addbook.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
package pdsu.bbm.view;
 
import java.awt.borderlayout;
import java.awt.flowlayout;
import java.awt.font;
import java.awt.image;
import java.awt.event.actionevent;
import java.awt.event.actionlistener;
import java.text.parseexception;
import java.text.simpledateformat;
import java.util.date;
import java.util.iterator;
import java.util.list;
import javax.swing.buttongroup;
import javax.swing.imageicon;
import javax.swing.jbutton;
import javax.swing.jcombobox;
import javax.swing.jframe;
import javax.swing.jlabel;
import javax.swing.joptionpane;
import javax.swing.jpanel;
import javax.swing.jtextfield;
import pdsu.bbm.dao.bookdao;
import pdsu.bbm.dao.booktypedao;
import pdsu.bbm.model.book;
import pdsu.bbm.model.booktype;
public class addbook extends jframe implements actionlistener {
 
 private jpanel contentpane;
 private jlabel label_1;
 private jlabel lbll;
 private jlabel label_2;
 private jlabel label_3;
 private jlabel label_4;
 private jlabel label_5;
 jpanel centerppanel;
 jbutton button1, button2, button3;
 private jcombobox combobox_1;
 image icon = new imageicon("image/icon.png").getimage();
 private jtextfield isbnfiled;
 private jtextfield publishfield;
 private jtextfield publishdatefield;
 private jtextfield publishtime;
 private jtextfield unitpricefield;
 private jtextfield booknamefield;
 private jtextfield authorfiled;
 public static void main(string[] args) {
 new addbook();
 }
 public addbook() {
 settitle("添加圖書信息");
 setsize(555, 333);
 seticonimage(icon);
 setlocationrelativeto(null);
 
 settitle("添加圖書信息");
 setsize(555, 334);
 setlocationrelativeto(null);
 setvisible(true);
 centerppanel = new jpanel();
 centerppanel.setlayout(null);
 jlabel label1 = new jlabel("isbn:");
 label1.setfont(new font("宋體", font.plain, 20));
 label1.setbounds(71, 26, 95, 42);
 centerppanel.add(label1);
 
 isbnfiled = new jtextfield();
 isbnfiled.setbounds(120, 30, 110, 30);
 centerppanel.add(isbnfiled);
 isbnfiled.setcolumns(10);
 
 jlabel label = new jlabel("類 別:");
 label.setfont(new font("宋體", font.plain, 20));
 label.setbounds(306, 30, 116, 35);
 centerppanel.add(label);
 
 label_1 = new jlabel("書 名:");
 label_1.setfont(new font("宋體", font.plain, 20));
 label_1.setbounds(50, 75, 154, 50);
 centerppanel.add(label_1);
 
 lbll = new jlabel("作 者:");
 lbll.setfont(new font("宋體", font.plain, 20));
 lbll.setbounds(306, 75, 137, 50);
 centerppanel.add(lbll);
 
 label_2 = new jlabel("出版社:");
 label_2.setfont(new font("宋體", font.plain, 20));
 label_2.setbounds(50, 130, 154, 50);
 centerppanel.add(label_2);
 
 label_3 = new jlabel("出版日期:");
 label_3.setfont(new font("宋體", font.plain, 20));
 label_3.setbounds(285, 135, 137, 50);
 centerppanel.add(label_3);
 
 publishfield = new jtextfield();
 publishfield.setcolumns(10);
 publishfield.setbounds(120, 143, 110, 30);
 centerppanel.add(publishfield);
 
 publishdatefield = new jtextfield();
 publishdatefield.setcolumns(10);
 publishdatefield.setbounds(380, 143, 120, 30);
 centerppanel.add(publishdatefield);
 
 label_4 = new jlabel("印刷次數(shù):");
 label_4.setfont(new font("宋體", font.plain, 20));
 label_4.setbounds(28, 190, 154, 50);
 centerppanel.add(label_4);
 
 publishtime = new jtextfield();
 publishtime.setcolumns(10);
 publishtime.setbounds(120, 203, 110, 30);
 centerppanel.add(publishtime);
 
 label_5 = new jlabel("單 價:");
 label_5.setfont(new font("宋體", font.plain, 20));
 label_5.setbounds(305, 194, 84, 42);
 centerppanel.add(label_5);
 
 unitpricefield = new jtextfield();
 unitpricefield.setcolumns(10);
 unitpricefield.setbounds(380, 203, 120, 30);
 centerppanel.add(unitpricefield);
 getcontentpane().add(centerppanel, borderlayout.center);
 
 booknamefield = new jtextfield();
 booknamefield.setcolumns(10);
 booknamefield.setbounds(120, 86, 110, 30);
 centerppanel.add(booknamefield);
 
 authorfiled = new jtextfield();
 authorfiled.setcolumns(10);
 authorfiled.setbounds(380, 86, 120, 30);
 centerppanel.add(authorfiled);
 
 list<booktype> rs = booktypedao.selectbooktype();
 iterator<booktype> iterator = rs.iterator();
 string[] alltypename = new string[rs.size()];
 int i = 0;
 while (iterator.hasnext()) {
  string typename = iterator.next().gettypename();
  alltypename[i] = typename;
  i++;
 }
 combobox_1 = new jcombobox(alltypename);
 combobox_1.setbounds(380, 30, 120, 30);
 combobox_1.setfont(new font("宋體", font.plain, 16));
 
 centerppanel.add(combobox_1);
 buttongroup group = new buttongroup();
 jpanel panel2 = new jpanel();
 panel2.setlayout(new flowlayout());
 button1 = new jbutton("添加");
 button1.setfont(new font("宋體", font.plain, 20));
 
 button2 = new jbutton("關(guān)閉");
 button2.setfont(new font("宋體", font.plain, 20));
 button3 = new jbutton("重置");
 button3.setfont(new font("宋體", font.plain, 20));
 
 panel2.add(button1);
 panel2.add(button3);
 panel2.add(button2);
 button1.addactionlistener(this);
 button2.addactionlistener(this);
 button3.addactionlistener(this);
 getcontentpane().add(panel2, borderlayout.south);
 
 setvisible(true);
 }
 
 @suppresswarnings("unused")
 public void actionperformed(actionevent e) {
 if (e.getsource() == button1) {
  string isbn = isbnfiled.gettext().tostring();
 
  string bookname = booknamefield.gettext();
  string author = authorfiled.gettext();
  string selecttype = combobox_1.getselecteditem().tostring();
  string publish = publishfield.gettext();
  string publishdate = publishdatefield.gettext();
  string time = publishtime.gettext().trim();
  string price = unitpricefield.gettext().trim();
 
  if (isbn.equals("") || bookname.equals("") || author.equals("")
   || selecttype.equals("") || publish.equals("")
   || publishdate.equals("") || time.equals("")
   || price.equals("")) {
  joptionpane.showmessagedialog(this, "請輸入完整信息");
  return;
  } else {
  booktype bt = new booktype();
  book book = new book();
  book.setisbn(isbn);
  book.setbookname(bookname);
  book.setauthor(author);
  bt.settypename(selecttype);
  int m = 0;
  list<booktype> list = booktypedao
   .selectidbytypename(selecttype);
  iterator<booktype> ite = list.iterator();
  while (ite.hasnext()) {
   m = ite.next().getid();
  }
  book.settypeid(m + "");
  book.setpublish(publish);
  try {
   book.setpublishtime(integer.parseint(time));
   book.setunitprice(integer.parseint(price));
  } catch (numberformatexception e1) {
   e1.printstacktrace();
  }
   
   simpledateformat sdf = new simpledateformat("yyyy-mm-dd");
   date regdate = null;
   try {
   regdate =sdf.parse(publishdate);
   } catch (parseexception e1) {
   joptionpane.showmessagedialog(this, "請輸入正確的日期");
   publishdatefield.settext("");
   }
   
   book.setpublishdate(regdate);
  if(regdate==null) return;
   
   if (bookdao.selectbookbyisbn(isbn) != null) {
   joptionpane.showmessagedialog(this, "該isbn編號已存在");
   return;
  } else if (bookdao.insertbook(book) != 0) {
   joptionpane.showmessagedialog(this, "添加成功");
  } else
   joptionpane.showmessagedialog(this, "添加失敗");
  }
 }
 if (e.getsource() == button3) {
  isbnfiled.settext("");
  booknamefield.settext("");
  authorfiled.settext("");
  publishfield.settext("");
  publishdatefield.settext("");
  publishtime.settext("");
  unitpricefield.settext("");
 }
 if (e.getsource() == button2) {
  dispose();
  new mainwindow();
 
 }
 }
 
}

圖書查詢與修改源代碼:bookselectandmodify.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
package pdsu.bbm.view;
 
import java.awt.borderlayout;
import java.awt.dimension;
import java.awt.font;
import java.awt.gridlayout;
import java.awt.image;
import java.awt.event.actionevent;
import java.awt.event.actionlistener;
import java.text.simpledateformat;
import java.util.arraylist;
import java.util.date;
import java.util.iterator;
import java.util.list;
import javax.swing.imageicon;
import javax.swing.jbutton;
import javax.swing.jcombobox;
import javax.swing.jframe;
import javax.swing.jlabel;
import javax.swing.joptionpane;
import javax.swing.jpanel;
import javax.swing.jscrollpane;
import javax.swing.jtabbedpane;
import javax.swing.jtable;
import javax.swing.jtextfield;
import javax.swing.swingconstants;
import javax.swing.table.tablemodel;
import pdsu.bbm.dao.bookdao;
import pdsu.bbm.dao.booktypedao;
import pdsu.bbm.model.book;
import pdsu.bbm.model.booktype;
 
public class bookselectandmodify extends jframe implements actionlistener {
 // 設(shè)置序列號
 private static final long serialversionuid = 1l;
 private jtabbedpane jtabbedpane; // 標(biāo)簽面板
 // selectjp查詢面板 select_conditionjp下拉列表面板 select_resultjp結(jié)果按鈕面板updatejp修改面板
 // updatejp修改面板,bookjp中間面板 buttonjp2按鈕面板
 private jpanel selectjp, select_conditionjp, select_resultjp, buttonjp1,
  bookjp, updatejp, buttonjp2;//
 private jtextfield selectjtf, isbnjtf, booknamejtf, authorjtf,
  printtimejtf, publishjtf, publishdatejtf, unitpricejtf;
 private jlabel isbnjl, booknamejl, authorjl, categoryjl, printtimejl,
  publishjl, publishdatejl, unitpricejl;
 // 重點!
 private jtable jtable;// 定義表格
 private jcombobox choicejcb, booktypejcb;
 private jscrollpane jscrollpane;
 private jbutton selectjb, exitjb, updatejb, resetjb;// 查詢按鈕,退出按鈕,修改按鈕,關(guān)閉按鈕
 private tablemodel getselect;
 private string[] title = { "isbn", "圖書序列", "圖書名稱", "作者", " 出版社 ",
  "出版日期", "印刷次數(shù)", "單價" };
 image icon = new imageicon("image/icon.png").getimage();
 
 public bookselectandmodify() {
 super();
 seticonimage(icon);
 settitle("圖書查詢與修改");
 setbounds(100, 100, 555, 400);
 setlocationrelativeto(null);
 // jtabbedpane選項卡
 jtabbedpane = new jtabbedpane();
 add(jtabbedpane);
 selectjp = new jpanel();
 selectjp.setlayout(new borderlayout());
 jtabbedpane.add("圖書信息查詢", selectjp);
 
 // 查詢條件面板
 select_conditionjp = new jpanel();
 choicejcb = new jcombobox();
 string array[] = { "isbn", "圖書名稱", "圖書序列", "作者", "出版社","所有" };// 設(shè)置為一維數(shù)組
 for (int i = 0; i < array.length; i++) {
  choicejcb.additem(array[i]);
 }
 select_conditionjp.add(choicejcb);
 selectjtf = new jtextfield(20);
 select_conditionjp.add(selectjtf);
 selectjp.add(select_conditionjp, borderlayout.north);
 // 查詢結(jié)果面板
 select_resultjp = new jpanel();
 bookdao dao = new bookdao();
 list<book> list = dao.selectbook();
 jtable = new jtable(getselect(list), title);
 
 // !設(shè)置表格大小不變
 jtable.setautoresizemode(jtable.auto_resize_off);
 // !設(shè)置列寬
 jtable.getcolumnmodel().getcolumn(4).setpreferredwidth(175);
 jscrollpane = new jscrollpane(jtable);// 把表格加入滾動面板
 // 顯示滾動面板邊框
 jscrollpane.setpreferredsize(new dimension(450, 170));
 select_resultjp.add(jscrollpane);
 selectjp.add(select_resultjp, borderlayout.center);
 // 查詢按鈕面板
 buttonjp1 = new jpanel();
 selectjb = new jbutton("查詢");
 selectjb.setfont(new font("宋體", font.plain, 20));
 
 selectjb.addactionlistener(this);
 buttonjp1.add(selectjb);
 exitjb = new jbutton("退出");
 exitjb.setfont(new font("宋體", font.plain, 20));
 exitjb.addactionlistener(this);
 buttonjp1.add(exitjb);
 selectjp.add(buttonjp1, borderlayout.south);
 // 信息修改頁面
 updatejp = new jpanel();
 updatejp.setlayout(new borderlayout());
 jtabbedpane.addtab("圖書信息修改", updatejp);
 bookjp = new jpanel();
 final gridlayout gridlayout = new gridlayout(8, 2);
 // 設(shè)置邊框間的距離
 gridlayout.setvgap(8);
 gridlayout.sethgap(8);
 bookjp.setlayout(gridlayout);
 isbnjl = new jlabel("isbn:");
 isbnjl.setfont(new font("宋體",font.plain,20));
 isbnjl.sethorizontalalignment(swingconstants.center);
 bookjp.add(isbnjl);
 isbnjtf = new jtextfield(20);
 isbnjtf.addactionlistener(this);
 bookjp.add(isbnjtf);
 categoryjl = new jlabel("類 別:");
 categoryjl.setfont(new font("宋體",font.plain,20));
 categoryjl.sethorizontalalignment(swingconstants.center);
 bookjp.add(categoryjl);
 // 下拉列表
 list<booktype> list1 = booktypedao.selectbooktype();
 iterator<booktype> it = list1.iterator();
 string ty[] = new string[list1.size()];
 int i = 0;
 booktypejcb = new jcombobox();
 while (it.hasnext()) {
  ty[i] = it.next().gettypename();
  booktypejcb.additem(ty[i]);
  i++;
 }
 
 bookjp.add(booktypejcb);
 
 booknamejl = new jlabel("書 名:");
 booknamejl.setfont(new font("宋體",font.plain,20));
 booknamejl.sethorizontalalignment(swingconstants.center);
 bookjp.add(booknamejl);
 booknamejtf = new jtextfield();
 booknamejtf.setcolumns(20);
 bookjp.add(booknamejtf);
 
 authorjl = new jlabel("作 者:");
 authorjl.setfont(new font("宋體",font.plain,20));
 authorjl.sethorizontalalignment(swingconstants.center);
 bookjp.add(authorjl);
 authorjtf = new jtextfield();
 authorjtf.setcolumns(20);
 bookjp.add(authorjtf);
 
 publishjl = new jlabel("出版社:");
 publishjl.setfont(new font("宋體",font.plain,20));
 publishjl.sethorizontalalignment(swingconstants.center);
 bookjp.add(publishjl);
 publishjtf = new jtextfield();
 bookjp.add(publishjtf);
 
 publishdatejl = new jlabel("出版日期:");
 publishdatejl.setfont(new font("宋體",font.plain,20));
 publishdatejl.sethorizontalalignment(swingconstants.center);
 bookjp.add(publishdatejl);
 publishdatejtf = new jtextfield();
 publishdatejtf.sethorizontalalignment(swingconstants.left);
 bookjp.add(publishdatejtf);
 
 printtimejl = new jlabel("印刷次數(shù):");
 printtimejl.setfont(new font("宋體",font.plain,20));
 printtimejl.sethorizontalalignment(swingconstants.center);
 bookjp.add(printtimejl);
 printtimejtf = new jtextfield();
 bookjp.add(printtimejtf);
 
 unitpricejl = new jlabel("單 價:");
 unitpricejl.setfont(new font("宋體",font.plain,20));
 unitpricejl.sethorizontalalignment(swingconstants.center);
 bookjp.add(unitpricejl);
 unitpricejtf = new jtextfield();
 bookjp.add(unitpricejtf);
 // 按鈕面板
 // 按鈕面板設(shè)計
 buttonjp2 = new jpanel();
 updatejb = new jbutton("修改");
 updatejb.setfont(new font("宋體", font.plain, 20));
 
 updatejb.addactionlistener(this);
 resetjb = new jbutton("關(guān)閉");
 resetjb.setfont(new font("宋體", font.plain, 20));
 
 resetjb.addactionlistener(this);
 buttonjp2.add(updatejb);
 buttonjp2.add(resetjb);
 updatejp.add(bookjp, borderlayout.center);
 updatejp.add(buttonjp2, borderlayout.south);
 setvisible(true);
 setdefaultcloseoperation(jframe.exit_on_close);
 }
 
 // 將查詢表格加入面板
 private object[][] getselect(list<book> list) {
 // todo auto-generated method stub
 object[][] objects = new object[list.size()][title.length];
 for (int i = 0; i < list.size(); i++) {
  book book = list.get(i);
  objects[i][0] = book.getisbn();
  objects[i][1] = book.gettypeid();// 圖書序列
  objects[i][2] = book.getbookname();// 圖書名稱
  objects[i][3] = book.getauthor();// 圖書作者
  objects[i][4] = book.getpublish();// 出版社
  objects[i][5] = book.getpublishdate();// 出版日期
  objects[i][6] = book.getpublishtime();// 印刷次數(shù)
  objects[i][7] = book.getunitprice();// 單價
 }
 
 return objects;
 
 }
 public void actionperformed(actionevent e) {
 // todo auto-generated method stub
 if(e.getsource()==isbnjtf){
  string isbn=isbnjtf.gettext();
  string typename=null;
  string id=bookdao.selectbookbyisbn(isbn).gettypeid();
  
  typename=booktypedao.selectbyid(id);
  system.out.println(typename);
  booktypejcb.setselecteditem(typename);
  booknamejtf.settext(bookdao.selectbookbyisbn(isbn).getbookname());
  authorjtf.settext(bookdao.selectbookbyisbn(isbn).getauthor());
  publishjtf.settext(bookdao.selectbookbyisbn(isbn).getpublish());
  publishdatejtf.settext(bookdao.selectbookbyisbn(isbn).getpublishdate()+"");
  printtimejtf.settext(bookdao.selectbookbyisbn(isbn).getpublishtime()+"");
  unitpricejtf.settext(bookdao.selectbookbyisbn(isbn).getunitprice()+"");
  
 }
 if (e.getsource() == selectjb) {// 按照isbn編碼查找
  int r = choicejcb.getselectedindex();
  if (r == 0) {
  string name = selectjtf.gettext().trim();
  // 強(qiáng)制轉(zhuǎn)換為線性表類型
  list<book> list = new arraylist<book>();
  book book = bookdao.selectbookbyisbn(name);
  if (book == null) {
   joptionpane.showmessagedialog(this, "該編碼不存在!");
  } else {
   list.add(book);
   object[][] data = getselect(list);
   jtable = new jtable(data, title);
   jtable.getcolumnmodel().getcolumn(4).setpreferredwidth(175);
   jtable.setautoresizemode(jtable.auto_resize_off);
 
   jscrollpane.setviewportview(jtable);
 
  }
  }
 
  if (r == 1) {// 根據(jù)圖書名稱查詢信息
  string name = selectjtf.gettext().tostring();
  list<book> list = bookdao.selectbookbyname(name);
  // 判斷線性表是否為空
  if (list == null || list.size() == 0) {
   joptionpane.showmessagedialog(this, "該圖書不存在!");
  } else {
   object[][] data = getselect(list);
   jtable = new jtable(data, title);
   tianjia();
  }
  }
  if (r == 2) {// 根據(jù)圖書序列查詢信息
  string name = selectjtf.gettext().tostring();
  list<book> list = bookdao.selectbookbytype(name);
  // 判斷線性表是否為空
  if (list == null || list.size() == 0) {
   joptionpane.showmessagedialog(this, "該圖書不存在!");
  } else {
   object[][] data = getselect(list);
   jtable = new jtable(data, title);
   tianjia();
  }
  }
  if (r == 3) { // 根據(jù)作者進(jìn)行查找
  string name = selectjtf.gettext().tostring();
  // 根據(jù)作者進(jìn)行查找
  list<book> list = bookdao.selectbookbyauthor(name);
  // 判斷線性表是否為空
  if (list == null || list.size() == 0) {
   joptionpane.showmessagedialog(this, "該圖書不存在!");
  } else {
   object[][] data = getselect(list);
   jtable = new jtable(data, title);
   tianjia();
  }
  }
  if (r == 4) {// 根據(jù)出版社進(jìn)行查找
  string name = selectjtf.gettext().tostring();
  list<book> list = bookdao.selectbookbypublish(name);
  if (list == null || list.size() == 0) {
   joptionpane.showmessagedialog(this, "該圖書不存在!");
  } else {
   object[][] data = getselect(list);
   jtable = new jtable(data, title);
   tianjia();
 
  }
  }
  if(r==5){
  list<book> list =bookdao.selectbook();
  }
 }
 if (e.getsource() == updatejb) {
  string isbn = isbnjtf.gettext().trim();
  string typename = ((string) booktypejcb.getselecteditem()).trim();
  string id = booktypedao.selectbytypename(typename);
  string bookname = booknamejtf.gettext();
  string author = authorjtf.gettext();
  string publish = publishjtf.gettext();
  string publishdate = publishdatejtf.gettext();
 
  simpledateformat sdf = new simpledateformat("yyyy-mm-dd");
  date regdate = null;
  try {
  regdate = sdf.parse(publishdate);
  } catch (exception e2) {
  e2.printstacktrace();
  joptionpane.showmessagedialog(this, "請輸入正確的日期格式!");
  }
  if (regdate == null)
  return;
  int publishtime = integer.parseint(printtimejtf.gettext());
  int unitprice = integer.parseint(unitpricejtf.gettext());
  // 封裝對象
  book book = new book();
  book.setisbn(isbn);
  book.settypeid(id);
  book.setbookname(bookname);
  book.setauthor(author);
  book.setpublish(publish);
  book.setpublishdate(regdate);
  book.setpublishtime(publishtime);
  book.setunitprice(unitprice);
  book.settypename(typename);
  int result = bookdao.update(book);
  list<book> list2 = new arraylist<book>();
  list2.add(book);
 
  // system.out.println(list2);
 
  if (result == 1) {
  joptionpane.showmessagedialog(this, "修改成功!");
  bookdao bk=new bookdao();
  list<book> list =bk.selectbook();
  jtable =new jtable(getselect(list),title);
  tianjia();
   
  } else {
  joptionpane.showmessagedialog(this, "修改失敗!");
  }
 }
 if (e.getsource() == resetjb) {
  dispose();
  new mainwindow();
 }
 if (e.getsource() == exitjb) {
  dispose();
  new mainwindow();
 }
 }
 
 private void tianjia() {
 jtable.getcolumnmodel().getcolumn(4).setpreferredwidth(175);
 jtable.setautoresizemode(jtable.auto_resize_off);
 
 jscrollpane.setviewportview(jtable);
 
 }
 
 public static void main(string[] args) {
 new bookselectandmodify();
 
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://blog.csdn.net/MyLove621/article/details/54834819

延伸 · 閱讀

精彩推薦
1238
主站蜘蛛池模板: 亚洲片在线 | 成人亚洲一区二区 | 欧美一级爱操视频 | 欧美日韩观看 | 久久久成人一区二区免费影院 | 亚洲va久久久噜噜噜久牛牛影视 | 91久久国产 | 特级a欧美做爰片毛片 | 美女久久 | 性爱视频在线免费 | 久久爽精品区穿丝袜 | 国产一区二区三区精品在线观看 | 一区二区三区无码高清视频 | 永久免费不卡在线观看黄网站 | 一本一道久久久a久久久精品91 | 高清成人在线 | 欧美福利视频一区二区 | 国产免费一区二区三区 | 国产一区二区久久精品 | 色妞妞视频 | 国产高潮好爽受不了了夜色 | 午夜视频啊啊啊 | 13一14毛片免费看 | 九一看片.| 911色_911色sss主站色播 | 操操操日日日干干干 | 毛片av网址| 成年性羞羞视频免费观看 | va视频| 在线观看国产免费视频 | 黄色免费视频在线 | 高清国产午夜精品久久久久久 | 爱视频福利| 一级国产电影 | 欧美精品久久久久久久久老牛影院 | 国产日本欧美在线观看 | 在线观看国产www | 孕妇体内谢精满日本电影 | 香蕉久草视频 | 国产三级精品最新在线 | 精品国产乱码久久久久久久 |