一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

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

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

服務(wù)器之家 - 編程語言 - JAVA教程 - java實(shí)現(xiàn)科研信息管理系統(tǒng)

java實(shí)現(xiàn)科研信息管理系統(tǒng)

2021-04-06 11:35pointer_y JAVA教程

這篇文章主要為大家詳細(xì)介紹了java科研信息管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、前言

本學(xué)期學(xué)習(xí)了java語言,在學(xué)期的結(jié)束,寫一個(gè)有操作界面,與數(shù)據(jù)庫關(guān)聯(lián)的管理系統(tǒng),用來鞏固自己本學(xué)習(xí)所學(xué)的知識(shí)。
用到的知識(shí):java基礎(chǔ),java界面設(shè)計(jì)(gui),oracle數(shù)據(jù)庫(需要掌握數(shù)據(jù)庫的基本操作語句),鏈接數(shù)據(jù)庫。
使用的開發(fā)工具:myeclipse professional 2014

二、設(shè)計(jì)

我們管理的屬性有:項(xiàng)目編號(hào),項(xiàng)目名稱,參與人員,負(fù)責(zé)人,項(xiàng)目開始時(shí)間,結(jié)束時(shí)間。科研項(xiàng)目系統(tǒng)主要有四個(gè)功能,對(duì)科研項(xiàng)目的增加、刪除、修改、查詢。以及為增加系統(tǒng)安全性所設(shè)計(jì)的登陸模式。

2.1 增加:向數(shù)據(jù)庫的表中增加科研項(xiàng)目的所有信息

java實(shí)現(xiàn)科研信息管理系統(tǒng)

添加后在控制臺(tái)使用sql語句查找,驗(yàn)證是否已添加至數(shù)據(jù)庫中。

java實(shí)現(xiàn)科研信息管理系統(tǒng)

2.2 查詢:通過具有唯一性的項(xiàng)目編號(hào)查找該項(xiàng)目的所有信息

java實(shí)現(xiàn)科研信息管理系統(tǒng)

2.3 修改:根據(jù)項(xiàng)目編號(hào)選中要修改的項(xiàng)目,并重新輸入項(xiàng)目信息進(jìn)行修改

java實(shí)現(xiàn)科研信息管理系統(tǒng) java實(shí)現(xiàn)科研信息管理系統(tǒng)

2.4 刪除:通過具有唯一性的項(xiàng)目編號(hào)刪除對(duì)應(yīng)項(xiàng)目的所有信息

java實(shí)現(xiàn)科研信息管理系統(tǒng)

三、窗體源碼

3.1 登錄界面

?
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
package 科研信息管理系統(tǒng);
 
import java.awt.*;
import java.awt.event.*;
 
import javax.swing.*;
 
public class loginwindows extends frame implements windowlistener,actionlistener
{
 public label lglabel; //用戶名標(biāo)簽
 public label pwdlabel; //密碼標(biāo)簽
 public textfield lgtext; //用戶名文本框
 public textfield pwdtext; //密碼文本框
 public button lgbt;   //登錄按鈕
 public button quitbt;  //退出按鈕
 
  public loginwindows()
  {
   super();
   this.setsize(400, 300);
   this.settitle("科研信息管理系統(tǒng)");
   this.setlayout(null);
 
   lglabel=new label();
   lglabel.settext("登錄賬號(hào):");
   lglabel.setsize(60, 30);
   lglabel.setlocation(70,70);
 
   pwdlabel=new label();
   pwdlabel.settext("密  碼:");
   pwdlabel.setsize(60,30);
   pwdlabel.setlocation(70, 150);
 
   lgtext=new textfield();
   lgtext.setsize(180, 30);
   lgtext.setlocation(140, 70);
 
   pwdtext=new textfield();
   pwdtext.setsize(180,30);
   pwdtext.setlocation(140, 150);
 
   lgbt=new button();
   lgbt.setlabel("登錄");
   lgbt.setsize(60,30);
   lgbt.setlocation(120, 220);
 
   quitbt=new button();
   quitbt.setlabel("退出");
   quitbt.setsize(60,30);
   quitbt.setlocation(220,220);
   quitbt.addactionlistener(this);
   lgbt.addactionlistener(this);
   this.addwindowlistener(this);
 
   this.add(lglabel);
   this.add(pwdlabel);
   this.add(lgtext);
   this.add(pwdtext);
   this.add(lgbt);
   this.add(quitbt);
   this.setvisible(true);
 
  }
  public static void main(string args[])
  {
   loginwindows main=new loginwindows();
 
  }
 @override
 public void actionperformed(actionevent e) {
 
  button bt=(button) e.getsource();
  if(bt.getlabel().equals("退出"))
  {
   system.exit(0);
  }
  else {
  if ((lgtext.gettext().equals(""))||(pwdtext.gettext().equals("")))
   {
    joptionpane.showmessagedialog(this,"賬號(hào)或密碼為空");
   }
   else
   {
     if ((lgtext.gettext().equals("admin"))&&(pwdtext.gettext().equals("111")))
   //if((lgtext.gettext().equals(""))||(pwdtext.gettext().equals("")))
    {
     this.setvisible(false);
    // sqlwindow sql=new sqlwindow();
     windowsview w=new windowsview();
     w.sciencepro();
 
    }
    else {
     joptionpane.showmessagedialog(this, "沒有權(quán)限");
    }
   }}}
 
 
 
 
 
 
 @override
 public void windowopened(windowevent e) {
  // todo auto-generated method busb
 
 }
 
 @override
 public void windowclosing(windowevent e) {
  // todo auto-generated method busb
  system.exit(0);
 }
 
 @override
 public void windowclosed(windowevent e) {
  // todo auto-generated method busb
 
 }
 
 @override
 public void windowiconified(windowevent e) {
  // todo auto-generated method busb
 
 }
 
 @override
 public void windowdeiconified(windowevent e) {
  // todo auto-generated method busb
 
 }
 
 @override
 public void windowactivated(windowevent e) {
  // todo auto-generated method busb
 
 }
 
 @override
 public void windowdeactivated(windowevent e) {
  // todo auto-generated method busb
 
 }
}

3.2主窗體源碼

?
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
package 科研信息管理系統(tǒng);
import javax.swing.*;
 
import java.awt.*;
import java.awt.event.*;
 
import javax.swing.event.*;
import javax.swing.tree.*;
 
public class windowsview implements treeselectionlistener,actionlistener //窗口類
{
 jframe main;
 jpanel leftpa;
 jpanel uppa;
 jpanel downpa;
 
 ///查詢用控件
 jlabel numla; //通過項(xiàng)目編號(hào)查詢
 jtextfield numtxt;
 jbutton numbt;
 
 jtextfield nametxt; //顯示項(xiàng)目名稱的文本框
 jtextfield peopletxt; //顯示參與人員
 jtextfield principaltxt; //顯示主要負(fù)責(zé)人
 jtextfield timestarttxt; //顯示開始時(shí)間的文本框
 jtextfield timeendtxt; //顯示預(yù)期結(jié)束時(shí)間的文本框
 
 //增加用控件
 jlabel anumla;
 jlabel anamela;
 jlabel apeoplela;
 jlabel aprincipalla;
 jlabel atimestartla;
 jlabel atimeendla;
 
 jtextfield anumtxt;
 jtextfield anametxt;
 jtextfield apeopletxt;
 jtextfield aprincipaltxt;
 jtextfield atimestarttxt;
 jtextfield atimeendtxt;
 jbutton addbt;
 jtable showtable;
 
 //刪除用控件
 jlabel dnumla;
 jbutton dnumbt;
 jtextfield dnumtxt;
 
 //修改用控件
 jlabel alnumla;
 jtextfield allnumtxt;
 jbutton alsebt;
 jbutton albt;
 
 jlabel allnumla;
 jlabel alnamela;
 jlabel alpeoplela;
 jlabel alprincipalla;
 jlabel altimestartla;
 jlabel altimeendla;
 jtextfield alnumtxt;
 jtextfield alnametxt;
 jtextfield alpeopletxt;
 jtextfield alprincipaltxt;
 jtextfield altimestarttxt;
 jtextfield altimeendtxt;
 
 public void sciencepro()
 {
  main=new jframe();
  main.setsize(800,800);
  main.settitle("科研信息管理");
  main.setlayout(null);
 
 
  leftpa=new jpanel();
  leftpa.setsize(150, 600);
  leftpa.setlocation(0, 0);
  leftpa.setbackground(color.white);
  initleftpanel();
  main.add(leftpa);
 
  uppa=new jpanel();
  uppa.setsize(650, 400);
  uppa.setlocation(150, 0);
  uppa.setbackground(color.gray);
  main.add(uppa);
 
  downpa=new jpanel();
  downpa.setsize(650, 400);
  downpa.setlocation(150, 400);
  downpa.setbackground(color.orange);
  main.add(downpa);
 
 
  main.setvisible(true);
 }
 
 private void initleftpanel()
 {
  string[] strs={"查詢","增加","刪除","修改"};
  jtree tree=new jtree(strs);
  tree.addtreeselectionlistener(this);
  leftpa.add(tree);
 }
 
 public void valuechanged(treeselectionevent e)
 {
  jtree tree=(jtree)e.getsource();
  defaultmutabletreenode selectionnode =(defaultmutabletreenode)tree.getlastselectedpathcomponent();
  string str=selectionnode.tostring();
  if(str.equals("查詢"))
  {
   initupdownpawhensearch();
  }
  if(str.equals("增加"))
  {
   initupdownpawhenadd();
  }
  if(str.equals("刪除"))
  {
   initupdownpawhendelete();
  }
  if(str.equals("修改"))
  {
   initupdownpawhenalert();
  }
 }
 
 private void initupdownpawhensearch()
 {
  //清空上下面板上的控件
  uppa.removeall();
  downpa.removeall();
  //動(dòng)態(tài)的加載上面板的控件
  uppa.setlayout(null);
  numla=new jlabel();
  numla.settext("請(qǐng)輸入項(xiàng)目編號(hào)");
  numla.setlocation(40, 60);
  numla.setsize(100, 40);
 
 
  numtxt=new jtextfield();
  numtxt.setlocation(180, 60);
  numtxt.setsize(200, 30);
 
 
  numbt=new jbutton();
  numbt.settext("查詢");
  numbt.addactionlistener(this);
  numbt.setlocation(250, 160);
  numbt.setsize(60, 30);
  uppa.add(numla);
  uppa.add(numtxt);
  uppa.add(numbt);
  uppa.validate();
  uppa.repaint();
  numbt.addactionlistener(this);
  //動(dòng)態(tài)的加載下面板的控件
 
  nametxt=new jtextfield();
  nametxt.setlocation(80, 50);
  nametxt.setsize(300, 30);
 
  peopletxt=new jtextfield();
  peopletxt.setlocation(80, 100);
  peopletxt.setsize(300, 30);
 
  principaltxt=new jtextfield();
  principaltxt.setlocation(80, 150);
  principaltxt.setsize(300, 30);
 
  timestarttxt=new jtextfield();
  timestarttxt.setlocation(80, 200);
  timestarttxt.setsize(300, 30);
 
  timeendtxt=new jtextfield();
  timeendtxt.setlocation(80,250);
  timeendtxt.setsize(300, 30);
 
  downpa.setlayout(null);
  downpa.add(nametxt);
  downpa.add(peopletxt);
  downpa.add(principaltxt);
  downpa.add(timestarttxt);
  downpa.add(timeendtxt);
  downpa.validate();
  downpa.repaint();
 
 }
 
 public void actionperformed(actionevent e)
 {
  jbutton bt=(jbutton)e.getsource();
  //bt.addactionlistener(this);
  if(bt.gettext().equals("查詢"))
  {
   if(numtxt.gettext().equals(""))
   {
    joptionpane.showmessagedialog(null, "請(qǐng)輸入項(xiàng)目編號(hào)");
   }
   else
   {
    dealsearch deal=new dealsearch();
    string inf=deal.findprobynum(integer.parseint(numtxt.gettext().trim()));
    if((inf!=null)&&(!inf.equals("")))
    {
     string[] strs=inf.split(",");
     nametxt.settext(strs[1]);
     peopletxt.settext(strs[2]);
     principaltxt.settext(strs[3]);
     timestarttxt.settext(strs[4]);
     timeendtxt.settext(strs[5]);
    }
   }
  }
  if(bt.gettext().equals("新增"))
  {
   if (anumtxt.gettext().equals("")||anametxt.gettext().equals("")||apeopletxt.gettext().equals("")||aprincipaltxt.gettext().equals("")||atimestarttxt.gettext().equals("")||atimeendtxt.gettext().equals(""))
   {
    joptionpane.showmessagedialog(null, "輸入中不能有空值!!");
   }
   else
   {
    scienceproject s=new scienceproject();
    s.setnum(integer.parseint(anumtxt.gettext()));
    s.setname(anametxt.gettext());
    s.setpeople(apeopletxt.gettext());
    s.setleader(aprincipaltxt.gettext());
    s.settimestart(atimestarttxt.gettext());
    s.settimefinish(atimeendtxt.gettext());
    dealadd deal=new dealadd();
    deal.add(s);
   }
  }
  if(bt.gettext().equals("刪除"))
  {
   if(integer.parseint(dnumtxt.gettext())==0)
   {
    joptionpane.showmessagedialog(null, "不能刪除空的項(xiàng)目編號(hào)!!");
   }
   else
   {
    dealdelete deal=new dealdelete();
    deal.delete(integer.parseint(dnumtxt.gettext().trim()));
   }
  }
  if(bt.gettext().equals("提交"))
  {
   if(integer.parseint(allnumtxt.gettext())==0)
   {
    joptionpane.showmessagedialog(null, "不能修改空的項(xiàng)目編號(hào)!!");
   }
   else
   {
    dealsub deal=new dealsub();
    deal.submit(integer.parseint(allnumtxt.gettext()));
   }
  }
  if(bt.gettext().equals("修改"))
  {
   if (alnametxt.gettext().equals("")||alpeopletxt.gettext().equals("")||alprincipaltxt.gettext().equals("")||altimestarttxt.gettext().equals("")||altimeendtxt.gettext().equals(""))
   {
    joptionpane.showmessagedialog(null, "輸入中不能有空值!!");
   }
   else
   {
    scienceproject s=new scienceproject();
    s.setnum(integer.parseint(allnumtxt.gettext()));
 
    s.setname(alnametxt.gettext());
    s.setpeople(alpeopletxt.gettext());
    s.setleader(alprincipaltxt.gettext());
    s.settimestart(altimestarttxt.gettext());
    s.settimefinish(altimeendtxt.gettext());
    dealalter deal=new dealalter();
    deal.alter(s);
   }
  }
 }
 
 private void initupdownpawhenadd()
 {
  //清空上下面板上的控件
  uppa.removeall();
  downpa.removeall();
  //動(dòng)態(tài)的加載上面板的控件
  uppa.setlayout(null);
 
  anumla=new jlabel();
  anumla.settext("請(qǐng)輸入要增加的項(xiàng)目編號(hào)");
  anumla.setlocation(30, 50);
  anumla.setsize(150, 40);
 
  anumtxt=new jtextfield();
  anumtxt.setlocation(200, 50);
  anumtxt.setsize(250, 30);
 
  anamela=new jlabel();
  anamela.settext("請(qǐng)輸入要增加的項(xiàng)目名稱");
  anamela.setlocation(30, 100);
  anamela.setsize(150, 40);
 
  anametxt=new jtextfield();
  anametxt.setlocation(200, 100);
  anametxt.setsize(250, 30);
 
  apeoplela=new jlabel();
  apeoplela.settext("請(qǐng)輸入項(xiàng)目參與人員");
  apeoplela.setlocation(30, 150);
  apeoplela.setsize(150, 40);
 
  apeopletxt=new jtextfield();
  apeopletxt.setlocation(200, 150);
  apeopletxt.setsize(250, 30);
 
  aprincipalla=new jlabel();
  aprincipalla.settext("請(qǐng)輸入項(xiàng)目負(fù)責(zé)人");
  aprincipalla.setlocation(30, 200);
  aprincipalla.setsize(150, 40);
 
  aprincipaltxt=new jtextfield();
  aprincipaltxt.setlocation(200, 200);
  aprincipaltxt.setsize(250, 30);
 
  atimestartla=new jlabel();
  atimestartla.settext("請(qǐng)輸入項(xiàng)目開始時(shí)間");
  atimestartla.setlocation(30, 250);
  atimestartla.setsize(150, 40);
 
  atimestarttxt=new jtextfield();
  atimestarttxt.setlocation(200, 250);
  atimestarttxt.setsize(250, 30);
 
  atimeendla=new jlabel();
  atimeendla.settext("請(qǐng)輸入項(xiàng)目結(jié)束時(shí)間");
  atimeendla.setlocation(30, 300);
  atimeendla.setsize(150, 40);
 
  atimeendtxt=new jtextfield();
  atimeendtxt.setlocation(200, 300);
  atimeendtxt.setsize(250, 30);
 
  addbt=new jbutton();
  addbt.settext("新增");
  addbt.addactionlistener(this);
  //addbt.addmouselistener(this);
  addbt.setlocation(250, 340);
  addbt.setsize(60, 30);
 
  uppa.add(addbt);
  uppa.add(anumla);
  uppa.add(anamela);
  uppa.add(apeoplela);
  uppa.add(aprincipalla);
  uppa.add(atimestartla);
  uppa.add(atimeendla);
  uppa.add(anametxt);
  uppa.add(anumtxt);
  uppa.add(apeopletxt);
  uppa.add(aprincipaltxt);
  uppa.add(atimestarttxt);
  uppa.add(atimeendtxt);
  uppa.validate();
  uppa.repaint();
 
  downpa.validate();
  downpa.repaint();
 }
 
 private void initupdownpawhendelete()
 {
  //清空上下面板上的控件
  uppa.removeall();
  downpa.removeall();
  //動(dòng)態(tài)的加載上面板的控件
  uppa.setlayout(null);
  numla=new jlabel();
  numla.settext("請(qǐng)輸入要?jiǎng)h除的項(xiàng)目編號(hào)");
  numla.setlocation(40, 60);
  numla.setsize(150, 40);
 
  dnumtxt=new jtextfield();
  dnumtxt.setlocation(200, 60);
  dnumtxt.setsize(250, 30);
 
  dnumbt=new jbutton();
  dnumbt.settext("刪除");
  dnumbt.addactionlistener(this);
  dnumbt.setlocation(270, 170);
  dnumbt.setsize(60, 30);
 
  uppa.add(numla);
  uppa.add(dnumtxt);
  uppa.add(dnumbt);
  uppa.validate();
  uppa.repaint();
 
  downpa.validate();
  downpa.repaint();
 }
 
 private void initupdownpawhenalert()
 {
  //清空上下面板上的控件
  uppa.removeall();
  downpa.removeall();
  //動(dòng)態(tài)的加載上面板的控件
  uppa.setlayout(null);
  alnumla=new jlabel();
  alnumla.settext("請(qǐng)輸入要修改的項(xiàng)目編號(hào)");
  alnumla.setlocation(40, 60);
  alnumla.setsize(150, 40);
 
  alsebt=new jbutton();
  alsebt.settext("提交");
  alsebt.addactionlistener(this);
  alsebt.setlocation(270, 170);
  alsebt.setsize(60, 30);
 
  allnumtxt=new jtextfield();
  allnumtxt.setlocation(200, 60);
  allnumtxt.setsize(200, 30);
 
  uppa.add(alnumla);
  uppa.add(alsebt);
  uppa.add(allnumtxt);
  uppa.validate();
  uppa.repaint();
 
  albt=new jbutton();
  albt.settext("修改");
  albt.addactionlistener(this);
  albt.setlocation(450, 170);
  albt.setsize(60, 30);
 
 /*  allnumla=new jlabel();
  allnumla.settext("請(qǐng)輸入修改后的項(xiàng)目編號(hào)");
  allnumla.setlocation(30, 00);
  allnumla.setsize(150, 40);
 
  alnumtxt=new jtextfield();
  alnumtxt.setlocation(180, 00);
  alnumtxt.setsize(250, 30);*/
 
  alnamela=new jlabel();
  alnamela.settext("請(qǐng)輸入修改后項(xiàng)目名稱");
  alnamela.setlocation(30, 50);
  alnamela.setsize(150, 40);
 
  alnametxt=new jtextfield();
  alnametxt.setlocation(180, 50);
  alnametxt.setsize(250, 30);
 
  alpeoplela=new jlabel();
  alpeoplela.settext("請(qǐng)重設(shè)參與人員");
  alpeoplela.setlocation(30, 100);
  alpeoplela.setsize(150, 40);
 
  alpeopletxt=new jtextfield();
  alpeopletxt.setlocation(180, 100);
  alpeopletxt.setsize(250, 30);
 
  alprincipalla=new jlabel();
  alprincipalla.settext("請(qǐng)重設(shè)項(xiàng)目負(fù)責(zé)人");
  alprincipalla.setlocation(30, 150);
  alprincipalla.setsize(150, 40);
 
  alprincipaltxt=new jtextfield();
  alprincipaltxt.setlocation(180, 150);
  alprincipaltxt.setsize(250, 30);
 
  altimestartla=new jlabel();
  altimestartla.settext("請(qǐng)重設(shè)項(xiàng)目開始時(shí)間");
  altimestartla.setlocation(30, 200);
  altimestartla.setsize(150, 40);
 
  altimestarttxt=new jtextfield();
  altimestarttxt.setlocation(180, 200);
  altimestarttxt.setsize(250, 30);
 
  altimeendla=new jlabel();
  altimeendla.settext("請(qǐng)重設(shè)項(xiàng)目結(jié)束時(shí)間");
  altimeendla.setlocation(30, 250);
  altimeendla.setsize(150, 40);
 
  altimeendtxt=new jtextfield();
  altimeendtxt.setlocation(180, 250);
  altimeendtxt.setsize(250, 30);
  downpa.add(albt);
  //downpa.add(allnumla);
  downpa.add(alnamela);
  downpa.add(alpeoplela);
  downpa.add(alprincipalla);
  downpa.add(altimestartla);
  downpa.add(altimeendla);
  downpa.add(alnametxt);
  //downpa.add(alnumtxt);
  downpa.add(alpeopletxt);
  downpa.add(alprincipaltxt);
  downpa.add(altimestarttxt);
  downpa.add(altimeendtxt);
  downpa.setlayout(null);
  downpa.validate();
  downpa.repaint();
 }
}

3.3 組織sql語句,鏈接數(shù)據(jù)庫部分

?
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
package 科研信息管理系統(tǒng);
import java.sql.*;
import java.util.scanner;
 
public class sql {
 public void addscienceproject(scienceproject scienceproject)
 {
  try
  {
   class.forname("oracle.jdbc.driver.oracledriver").newinstance();
   string constr="jdbc:oracle:thin:@localhost:1521:xe";
   connection con=drivermanager.getconnection(constr,"system","1");
   stringbuffer sql=new stringbuffer("insert into science values("+scienceproject.getnum()+",'"+scienceproject.getname()+"','"+scienceproject.getpeople()+"','"+scienceproject.getleader()+"','"+scienceproject.gettimestart()+"','"+scienceproject.gettimefinish()+"')");
 
   statement st=con.createstatement();
   st.execute(sql.tostring());
   st.close();
   con.close();
  }
  catch (exception e)
  {
  // todo: handle exception
 
  system.out.println(e.tostring());
  }
 }
 public void delscienceproject(scienceproject scienceproject)
 {
  try
  {
  class.forname("oracle.jdbc.driver.oracledriver").newinstance();
  string constr="jdbc:oracle:thin:@localhost:1521:xe";
  connection con=drivermanager.getconnection(constr,"system","1");
  stringbuffer sql=new stringbuffer("delete from science where num="+scienceproject.getnum()+"");
  statement st=con.createstatement();
  st.execute(sql.tostring());
  st.close();
  con.close();
  }
  catch (exception e)
  {
  // todo: handle exception
  system.out.println(e.tostring());
  }
 
 }
 public void updscienceproject(scienceproject scienceproject)
 {
  try
  {
  class.forname("oracle.jdbc.driver.oracledriver").newinstance();
  string constr="jdbc:oracle:thin:@localhost:1521:xe";
  connection con=drivermanager.getconnection(constr,"system","1");
  stringbuffer sql =new stringbuffer("update science set name='"+scienceproject.getname()+"',workpeople='"+scienceproject.getpeople()+"',manager='"+scienceproject.getleader()+"',timestart='"+scienceproject.gettimestart()+"',timeend='"+scienceproject.gettimefinish()+"' where num="+scienceproject.getnum()+"");
  statement st=con.createstatement();
  st.execute(sql.tostring());
  st.close();
  con.close();
  }
  catch (exception e)
  {
  // todo: handle exception
   system.out.println("修改異常");
  system.out.println(e.tostring());
  }
 }
 public scienceproject findbynum(int num)
 {
  scienceproject scienceproject=new scienceproject();
  try
  {
   class.forname("oracle.jdbc.driver.oracledriver").newinstance();
   string constr="jdbc:oracle:thin:@localhost:1521:xe";
   connection con=drivermanager.getconnection(constr,"system","1");
   stringbuffer sql=new stringbuffer("select * from science where num="+num+"");
   statement st=con.createstatement();
   resultset rs=st.executequery(sql.tostring());
   while(rs.next())
   {
    scienceproject.setnum(rs.getint(1));
    scienceproject.setname(rs.getstring(2));
    scienceproject.setpeople(rs.getstring(3));
    scienceproject.setleader(rs.getstring(4));
    scienceproject.settimestart(rs.getstring(5));
    scienceproject.settimefinish(rs.getstring(6));
   }
   st.close();
   con.close();
  }
  catch (exception e) {
  // todo: handle exception
  system.out.println(e.tostring());
  }
 return scienceproject;
 }
 public scienceproject look()
 {
  scienceproject scienceproject=new scienceproject();
  try
   {
   class.forname("oracle.jdbc.driver.oracledriver").newinstance();
   string constr="jdbc:oracle:thin:@localhost:1521:xe";
   connection con=drivermanager.getconnection(constr,"system","1");
   stringbuffer sql=new stringbuffer("select *from science");
   statement st=con.createstatement();
   resultset rs=st.executequery(sql.tostring());
   while(rs.next())
   {
    scienceproject.setnum(rs.getint(1));
    scienceproject.setname(rs.getstring(2));
    scienceproject.setpeople(rs.getstring(3));
    scienceproject.setleader(rs.getstring(4));
    scienceproject.settimestart(rs.getstring(5));
    scienceproject.settimefinish(rs.getstring(6));
   }
   st.close();
   con.close();
 }
  catch (exception ex)
  {
  // todo: handle exception
  system.out.println(ex.tostring());
  }
 return scienceproject;
 }
 public static void main(string args[])
 {
 
 }
}

3.4 增刪查改對(duì)應(yīng)處理的源碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//處理增加
package 科研信息管理系統(tǒng);
 
import javax.swing.joptionpane;
 
public class dealadd
{
 public dealadd()
 {}
 public void add(scienceproject s)
 {
  sql sql=new sql();
  if(sql.findbynum(s.getnum()).getnum()!=0)
  {
   joptionpane.showmessagedialog(null, "該項(xiàng)目已存在,請(qǐng)重新輸入!");
  }
  else
  {
 
   sql.addscienceproject(s);
   joptionpane.showmessagedialog(null,"增加成功");
  }
 }
}

由設(shè)計(jì)部分可以看到,刪除時(shí)需要先提交項(xiàng)目編號(hào),所以,需要處理提交事件

?
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
//處理提交
package 科研信息管理系統(tǒng);
 
import javax.swing.joptionpane;
 
public class dealsub
{
 dealsub()
 {}
 public void submit(int num)
 {
  sql sql =new sql();
  if(sql.findbynum(num).getnum()==0)
  {
   joptionpane.showmessagedialog(null, "不存在該項(xiàng)目");
  }
  else
  {
   joptionpane.showmessagedialog(null, "請(qǐng)?jiān)谙路教顚懶薷暮蟮捻?xiàng)目信息");
  }
 }
}
//處理刪除
package 科研信息管理系統(tǒng);
 
import javax.swing.joptionpane;
 
public class dealdelete
{
 public dealdelete()
 {}
 public void delete(int num)
 {
  scienceproject s=new scienceproject();
  sql sql=new sql();
  if(sql.findbynum(num).getnum()==0)
  {
   joptionpane.showmessagedialog(null, "不存在該項(xiàng)目~");
  }
  else
  {
   s=sql.findbynum(num);
   sql.delscienceproject(s);
   joptionpane.showmessagedialog(null, "刪除成功~");
  }
 }
}
//處理修改
package 科研信息管理系統(tǒng);
 
import javax.swing.joptionpane;
 
public class dealalter
{
 public dealalter()
 {}
 public void alter(scienceproject s)
 {
  sql sql=new sql();
  sql.updscienceproject(s);
  joptionpane.showmessagedialog(null,"修改成功");
 }
}
//處理查詢
package 科研信息管理系統(tǒng);
 
public class dealsearch //處理查詢事件
{
 public dealsearch()
 {}
 public string findprobynum(int num)//通過項(xiàng)目編號(hào)查詢
 {
  string result="";
  scienceproject s=new scienceproject();
  sql sql=new sql();
  s=sql.findbynum(num);
  result=s.getnum()+","+s.getname()+","+s.getpeople()+","+s.getleader()+","+s.gettimestart()+","+s.gettimefinish();
  return result;
 }
}

3.5 主函數(shù)調(diào)用登錄窗口

?
1
2
3
4
5
6
7
8
9
10
11
package 科研信息管理系統(tǒng);
 
public class test {
 
 public static void main(string[] args)
 {
  loginwindows v=new loginwindows();
 
 }
 
}

四、總結(jié)

還是有一些的缺陷存在的,由于對(duì)科研項(xiàng)目的不熟悉,有些屬性設(shè)計(jì)得不合理,還有很多沒有考慮到的地方,另外對(duì)gui的不熟悉也限制了我們?cè)诖翱谏系脑O(shè)計(jì)。還需要在項(xiàng)目屬性及窗口等方面進(jìn)行修改。

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

原文鏈接:http://blog.csdn.net/pointer_y/article/details/54381545

延伸 · 閱讀

精彩推薦
  • JAVA教程java中實(shí)體類和JSON對(duì)象之間相互轉(zhuǎn)化

    java中實(shí)體類和JSON對(duì)象之間相互轉(zhuǎn)化

    Java中關(guān)于Json格式轉(zhuǎn)化Object,Map,Collection類型和String類型之間的轉(zhuǎn)化在我們實(shí)際項(xiàng)目中應(yīng)用的很是普遍和廣泛。最近工作的過程中也是經(jīng)常有,因此,自己封裝...

    hebedich6692019-12-17
  • JAVA教程Java中synchronized實(shí)現(xiàn)原理詳解

    Java中synchronized實(shí)現(xiàn)原理詳解

    這篇文章主要介紹了Java中synchronized實(shí)現(xiàn)原理詳解,涉及synchronized實(shí)現(xiàn)同步的基礎(chǔ),Java對(duì)象頭,Monitor,Mark Word,鎖優(yōu)化,自旋鎖等相關(guān)內(nèi)容,具有一定借鑒...

    _eve3912021-02-23
  • JAVA教程Java不可變類機(jī)制淺析

    Java不可變類機(jī)制淺析

    所謂的不可變類是指這個(gè)類的實(shí)例一旦創(chuàng)建完成后,就不能改變其成員變量值。如JDK內(nèi)部自帶的很多不可變類:Interger、Long和String等。接下來通過本文給大...

    fuzhongmin053132020-08-03
  • JAVA教程Jersey框架的統(tǒng)一異常處理機(jī)制分析

    Jersey框架的統(tǒng)一異常處理機(jī)制分析

    初學(xué)者往往不清楚java的異常為什么會(huì)設(shè)計(jì)成這個(gè)樣子,他們通常會(huì)對(duì)異常只進(jìn)行簡單的處理 ...

    小白盤1512020-06-01
  • JAVA教程Spring如何基于注解顯式實(shí)現(xiàn)自動(dòng)裝配

    Spring如何基于注解顯式實(shí)現(xiàn)自動(dòng)裝配

    這篇文章主要介紹了Spring如何基于注解顯式實(shí)現(xiàn)自動(dòng)裝配,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友...

    Arno_vc4522020-08-01
  • JAVA教程詳談Enumeration接口和Iterator接口的區(qū)別

    詳談Enumeration接口和Iterator接口的區(qū)別

    下面小編就為大家?guī)硪黄斦凟numeration接口和Iterator接口的區(qū)別。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧...

    Java教程網(wǎng)3572020-12-10
  • JAVA教程淺談spring 常用注解

    淺談spring 常用注解

    這篇文章主要介紹了淺談spring 常用注解,具有一定參考價(jià)值,需要的朋友可以了解下。...

    Justnow_5062021-02-03
  • JAVA教程Java基礎(chǔ)教程之對(duì)象的方法與數(shù)據(jù)成員

    Java基礎(chǔ)教程之對(duì)象的方法與數(shù)據(jù)成員

    這篇文章主要介紹了Java基礎(chǔ)教程之對(duì)象的方法與數(shù)據(jù)成員,本文講解對(duì)象的方法與數(shù)據(jù)成員相關(guān)知識(shí),因?yàn)閖ava是面向?qū)ο笳Z言,本文的知識(shí)都是經(jīng)常要用到的...

    junjie3262019-11-27
主站蜘蛛池模板: 成年看片免费高清观看 | 高清欧美不卡一区二区三区 | 成人性生交小说免费看 | 亚洲国产成人精品无码区99 | 睡男神的这件小事小说在线阅读 | 欧美vpswindowssex 欧美va在线高清 | 欧美成人aa久久狼窝动画 | 日本成年片高清在线观看 | 大妹子最新视频在线观看 | 国产一级视频在线观看 | 久久99国产综合精品AV蜜桃 | 美女的隐私视频免费看软件 | 亚洲天堂2013| 91精品国产人成网站 | 亚洲29p| 嗯啊好大好粗 | 久久r视频| 日本视频免费在线播放 | 欧美一级一级做性视频 | 国产精品免费aⅴ片在线观看 | 国产欧美日韩精品在线 | 欧美男男gaygaysxxx | 国产欧美精品一区二区三区四区 | 精品久久免费视频 | 国产91素人搭讪系列天堂 | 午夜精品久视频在线观看 | 久久AV喷吹AV高潮欧美 | 国产精品欧美亚洲韩国日本 | 亚洲日本免费 | 国产男女性特黄录像 | 爽好舒服使劲添高h视频 | 国产成人综合久久 | 暖暖中国免费观看高清完整版 | 白发在线视频播放观看免费 | 兽皇日本| 欧美灰丝袜丝交nylons | bbwfreehd女厕所ved | 免费在线看片网站 | 国产新疆成人a一片在线观看 | 歪歪漫画a漫入口 | 火影忍者羞羞 |