數(shù)據(jù)庫(kù)課程設(shè)計(jì)-企業(yè)工資管理系統(tǒng)(java版+完整代碼)_第1頁(yè)
數(shù)據(jù)庫(kù)課程設(shè)計(jì)-企業(yè)工資管理系統(tǒng)(java版+完整代碼)_第2頁(yè)
數(shù)據(jù)庫(kù)課程設(shè)計(jì)-企業(yè)工資管理系統(tǒng)(java版+完整代碼)_第3頁(yè)
數(shù)據(jù)庫(kù)課程設(shè)計(jì)-企業(yè)工資管理系統(tǒng)(java版+完整代碼)_第4頁(yè)
數(shù)據(jù)庫(kù)課程設(shè)計(jì)-企業(yè)工資管理系統(tǒng)(java版+完整代碼)_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

課程設(shè)計(jì)報(bào)告年月日企業(yè)工資管理系統(tǒng)姓名班級(jí)學(xué)號(hào)課程名稱(chēng)

數(shù)據(jù)庫(kù)原理及應(yīng)用 指導(dǎo)教師目 錄一.

工資管理系統(tǒng)需求分析…………………1.

1

功能需求…………………1.

1

.

1

功能劃分………1.

1

.

2

功能描述……………1.

2

性能需求…………………1.

3

數(shù)據(jù)流圖………………二.

總體設(shè)計(jì)…………………2.

1

數(shù)據(jù)庫(kù)概念設(shè)計(jì)…………2.

2

功能模塊…………………三.

系統(tǒng)詳細(xì)設(shè)計(jì)……………3.

1

數(shù)據(jù)庫(kù)邏輯設(shè)計(jì)…………3.

2

各模塊功能………………3.

2

.

1

職工信息管理系統(tǒng)…………………3.

2

.

2

職工工資管理系統(tǒng)…………………3.

2

.

3

職工津貼管理系統(tǒng)…………………四.

系統(tǒng)實(shí)現(xiàn)…………………4.

1

界面截圖…………………4.

1

.

1

主界面及工資基本信息界面……4.

1

.

2

登錄界面…………4.

1

.

3

系統(tǒng)主界面………4.

1

.

4

信息錄入,

修改,

刪除,

查詢界面…………4.

2

設(shè)計(jì)代碼…………………五.

實(shí)驗(yàn)總結(jié)…………………11、

需求分析功能需求功能劃分、員工信息表;及時(shí)反映員工的基本信息(2)、員工津貼表,反映員工津貼(3)、員工基本工資表功能描述、基本工資的設(shè)定(2)、津貼的設(shè)定、計(jì)算出月工資、錄入員工工資信息(5)、添加員工工資信息(6)、更改員工工資信息性能需求此工資管理系統(tǒng)對(duì)工資數(shù)據(jù)精度的計(jì)算能在默認(rèn)情況之下精確到小數(shù)點(diǎn)后3

位小數(shù),即是精確到分的計(jì)算。但在用戶使用過(guò)程中,能自行根據(jù)實(shí)際情況進(jìn)行小數(shù)計(jì)算精度的設(shè)定,最大能允許保留小數(shù)點(diǎn)后

5

位的精度。在時(shí)間特性上,當(dāng)用戶發(fā)出命令請(qǐng)求時(shí)的服務(wù)器的響應(yīng)時(shí)間、對(duì)數(shù)據(jù)更新處理、工資數(shù)據(jù)的查詢檢索等上,同樣要求系統(tǒng)響應(yīng)時(shí)間不會(huì)超過(guò)

0.5

秒時(shí)間。系統(tǒng)支持多種操作系統(tǒng)的運(yùn)行環(huán)境,多不同操作系統(tǒng),不同文件格式的磁盤(pán)上的數(shù)據(jù)均能實(shí)現(xiàn)信息的互通,及共享。當(dāng)服務(wù)器移植到其他的系統(tǒng)平臺(tái),如:Linux

平臺(tái)下時(shí),同樣能和其他的系統(tǒng)進(jìn)行數(shù)據(jù)存取同步,不會(huì)出現(xiàn)系統(tǒng)之間互不兼容的情況,系統(tǒng)支持多系統(tǒng)之間的互連互通,系統(tǒng)有巨大的強(qiáng)健性。本課程設(shè)計(jì)是用

Java

語(yǔ)言編寫(xiě),mysql

數(shù)據(jù)庫(kù)。數(shù)據(jù)流圖根據(jù)工資管理要求及用戶需求調(diào)查分析,得到以下數(shù)據(jù)流圖圖

1.1

第一層數(shù)據(jù)流圖修改職工信息刪除職工記錄工資表添加操作輸入職工基本信息修改操作刪除操作用戶查詢操作職工號(hào)圖

1.

2

職工信息的載入津貼表添加操作修改操作刪除操作查詢操作用戶2圖

1.4

考勤的信息載入總體設(shè)計(jì)數(shù)據(jù)庫(kù)概念設(shè)計(jì)有了數(shù)據(jù)流圖,用

E-R

圖來(lái)說(shuō)明工資信息管理系統(tǒng)的數(shù)據(jù)庫(kù)概念模式,如圖1nm圖

2.1

實(shí)體之間關(guān)系

E-R

圖員工領(lǐng)取工資領(lǐng)取津貼影響職工號(hào)姓名基本工資職工號(hào)職工號(hào)津貼姓名密碼姓名32.2

功能模塊系統(tǒng)詳細(xì)設(shè)計(jì)數(shù)據(jù)庫(kù)邏輯設(shè)計(jì)將以上

E-R

轉(zhuǎn)換成如下關(guān)系模式員工(職工號(hào),姓名,密碼)工資(職工號(hào),姓名,基本工資,)津貼(職工號(hào),姓名,獎(jiǎng)金)其中,標(biāo)有下劃線的字段表示為該數(shù)據(jù)表的主碼,即主關(guān)鍵字。在上面的實(shí)體以及實(shí)體之間關(guān)系的基礎(chǔ)上,形成數(shù)據(jù)庫(kù)中的表格以及各個(gè)表格之間的關(guān)系。工資信息管理系統(tǒng)數(shù)據(jù)庫(kù)中各個(gè)表格的設(shè)計(jì)結(jié)果如下面的幾個(gè)表格所示。每個(gè)表格表示在數(shù)據(jù)庫(kù)中的一個(gè)表。表一:?jiǎn)T工信息表:列名數(shù)據(jù)類(lèi)型可否取空備注說(shuō)明noChar(8

)NOT

NULL職工號(hào)(主鍵)nameChar(10)NOT

NULL職工姓名miSmallintNOT

NULL登錄密碼工資管理系統(tǒng)系統(tǒng)模塊工資管理模塊職工登陸模塊員工管理模塊45表二:基本工資表:列名數(shù)據(jù)類(lèi)型可否取空備注說(shuō)明noChar(8

)NOT

NULL職工號(hào)(主鍵)nameChar(10)NOT

NULL職工姓名JbmoneyNOT

NULL基本工資表四:津貼信息表列名數(shù)據(jù)類(lèi)型可否為空備注說(shuō)明noChar(8

)NOT

NULL職工號(hào)(主鍵)nameChar(10)NOT

NULL職工姓名JtmoneyNOT

NULL津貼各模塊功能職工信息管理系統(tǒng)功能為:財(cái)務(wù)部門(mén)相關(guān)人員錄入、修改、刪除、查詢員工個(gè)人信息職工工資管理系統(tǒng)功能為:根據(jù)工資生成公式,按照員工的考勤情況及各種表現(xiàn)按月生成相應(yīng)的工資;財(cái)務(wù)部門(mén)相關(guān)人員能錄入、修改、刪除、查詢每個(gè)月每個(gè)員工的工資信息以及工資匯總;員工本人能查詢自己的工資信息以及工資匯總;職工登陸查詢系統(tǒng)功能為:?jiǎn)T工本人能通過(guò)用戶名和密碼查詢自己的信息以及修改自己的密碼;系統(tǒng)實(shí)現(xiàn)界面截圖主界面4.1.2

登錄界面4.1.3

管理員管理工資界面4.1.4

信息錄入,修改,刪除,查詢界面64.1.5

職工信息查詢界面4.1.6

職工密碼修改界面74.2

設(shè)計(jì)代碼DB.

javapackagewage_

management;8importimportjava.awt.*;java.

awt.

event.*;importjavax.

swing.*;classDBextendsJFrameimplementsActionListener{JFrame

frame

=

new

JFrame("

歡迎進(jìn)入企業(yè)工資管理系統(tǒng)");JLabellabel=newJLabel("",

JLabel.CENTER);JButton

button

1

=

new

JButton("

進(jìn)入系統(tǒng)");JButton

button

2

=

new

JButton("

退出系統(tǒng)");ImageIconim=newImageIcon("1.jpg");JLabela1=newJLabel(

im);voidCreate()

{JPanel

pcontent

Pane

=

(JPanel)

frame.

get

Content

Pane();pcontent

Pane.

add(

a

1

);pcontentPane.add(label);pcontent

Pane.

set

Layout(

new

Flow

Layout());pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.setVisible(true);button1.addActionListener(this);button

2

.

add

Action

Listener(

this);9frame.

set

Default

Close

Operation(

JFrame.

EXIT_

ON_

CLOSE);frame.

pack();frame.

set

Bounds(

200

,

100

,

550

,

180

);frame.

set

Visible(

true);}publicstaticvoidmain(String[]args){DBdome=new

DB();dome.

Create();}public

void

action

Performed(

Action

Event

e)

{if

(button

1

.

equals(

e.

get

Source()))

{DLdl=newDL();dl.create();frame.

dispose();{//

退出}if

(button

2

.

equals(

e.

get

Source()))System.

exit(

0

);}}}DL.

javapackagewage_

management;importimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportjava.awt.Color;java.awt.FlowLayout;java.

awt.

event.

Action

Event;java.

awt.

event.

Action

Listener;java.sql.Connection;java.sql.DriverManager;java.sql.ResultSet;java.sql.Statement;javax.swing.ImageIcon;javax.swing.JButton;javax.swing.JFrame;javax.swing.JLabel;javax.swing.JOptionPane;javax.swing.JPanel;javax.swing.JPasswordField;javax.

swing.

JText

Field;10import

com.

mysql.

jdbc.

Prepared

Statement;importQuery.

Querypad;classDLextendsJFrameimplements

ActionListener{Image

Icon

im

=

new

Image

Icon("

2

.

jpg");a2=newJLabel(

im);frame

=

new

JFrame("

職工/

管理員登陸");label

1

=

new

JLabel("

用戶名");label

2

=

new

JLabel("

密碼");JLabelJFrameJLabelJLabelJButtonJButtonJButtonlogon

Button

1logon

Button

2cancel

Button=

new

JButton("

管理員登錄");=

new

JButton("

職工登錄");=

new

JButton("

退出");JTextFieldusername=newJTextField(9);JPassword

Field

password

=

new

JPassword

Field(

9

);staticString

t1;staticString

t2;void

create(){JPanelp

=(JPanel)

frame.

get

Content

Pane();JPanelp1=newJPanel();p.

set

Layout(

new

Flow

Layout());p.

add(

a

2

);p.

add(

label

1

);p.

set

Size(

5

,

5);p.

set

Location(

4

,

8);p.add(username);p.

set

Size(

100

,

200

);p.

set

Location(

800

,

800

);p.add(label2);p.

set

Size(

50

,

20

);p.

set

Location(

40

,

80

);p.add(password);p.

set

Size(

100

,

20

);p.

set

Location(

80

,

120

);p.

add(

logon

Button

1

);11p.

add(

logon

Button

2

);p.

add(

cancel

Button);p.setBackground(Color.cyan);p.setVisible(true);logon

Button

1

.

add

Action

Listener(

this);logon

Button

2

.

add

Action

Listener(

this);cancel

Button.

add

Action

Listener(

this);frame.

set

Default

Close

Operation(

JFrame.

EXIT_

ON_

CLOSE);frame.

pack();frame.

set

Bounds(

200

,

100

,

500

,

220

);frame.

set

Visible(

true);}public

void

action

Performed(

Action

Event

e){t1

=

username.

get

Text();t2

=

password.

get

Text();if(

e.

get

Source()==

logon

Button

1

){if(

username.

get

Text().

equals("

admin")

==

true&& (password.

get

Text().

equals("

admin") ==true)){JOption

Pane.

show

Message

Dialog(

this,

"

登錄成功!");GZGLZJMgz=new

GZGLZJM();gz.create();frame.

dispose();}else

{JOption

Pane.

show

Message

Dialog(

null,"

輸入用戶名或密碼錯(cuò)誤!

");}}if

(e.

get

Source()==

logon

Button

2

){try

{Connectioncon;Statement

ps;12ResultSetrs;Stringsql=

null;Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver").

new

Instance();con

=

Driver

Manager.

get

Connection("jdbc:

mysql://

localhost:

3306

/

wagemanagement","

root","

jxb");sql="

select * from workerinfo wherename='"+

t

1

+"'

and

mi='"+

t

2

+"'";ps = (Prepared

Statement)con.

prepare

Statement(

sql);rs

=

ps.

execute

Query(

sql);&&if(

rs.

next()){if(

rs.

get

String("

name").

equals(

t

1

)rs.

get

String("

mi").

equals(

t

2

)){YGDLJMyg=new

YGDLJM();yg.create();frame.

dispose();JOption

Pane.

show

Message

Dialog(

this,

"

登錄成功!

");this.

dispose();}}else

{JOption

Pane.

show

Message

Dialog(

this,

"

用戶名或密碼錯(cuò)誤!

");}}catch(Exceptione1)

{//TODOAuto-generatedcatchblocke1

.

print

Stack

Trace();}}if

(cancel

Button.

equals(

e.

get

Source()))

//

退出{System.

exit(

0

);}}13}GZGLZJM.

javapackagewage_

management;importimportimportimportimportimportimportimportimportjava.awt.Color;java.awt.FlowLayout;java.

awt.

event.

Action

Event;java.

awt.

event.

Action

Listener;javax.swing.ImageIcon;javax.swing.JButton;javax.swing.JFrame;javax.swing.JLabel;javax.

swing.

JPanel;class

GZGLZJMextendsJFrameimplements

ActionListener{JFramef

=new

JFrame("

工資管理系統(tǒng)");JButtonb1=newJButton("

工資管理");JButtonb2=newJButton("

員工信息管理");JButtonb3=newJButton("

返回");Image

Icon

im

=

new

Image

Icon("

3

.

jpg");JLabela1=newJLabel(

im);voidcreate()

{JPanel

p

=

(JPanel)

f.

get

Content

Pane();p.setLayout(newFlowLayout());p.

add(

a

1

);p.

add(

b

1

);p.

add(

b

2

);p.

add(

b

3

);p.setBackground(Color.cyan);p.setVisible(true);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);f.

set

Bounds(

200

,

100

,

500

,

200

);f.

set

Visible(

true);}public

void

action

Performed(

Action

Event

e)

{if

(b

3

.

equals(

e.

get

Source()))

{//

返回14DLd=newDL();d.

create();f.

dispose();}{//

員工信息管理if

(b

2

.

equals(

e.

get

Source()))YGGLyg=new

YGGL();yg.

create();f.

dispose();}if

(b

1

.

equals(

e.

get

Source()))

{//

工資管理GZGLgz=new

GZGL();gz.

create();f.

dispose();}}}GZGL.

javapackagewage_

management;importimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportjava.awt.Color;java.awt.FlowLayout;java.

awt.

event.

Action

Event;java.

awt.

event.

Action

Listener;java.sql.Connection;java.sql.DriverManager;java.sql.ResultSet;java.sql.SQLException;java.sql.Statement;javax.swing.JButton;javax.swing.JFrame;javax.swing.JLabel;javax.swing.JOptionPane;javax.swing.JPanel;javax.swing.JScrollPane;javax.swing.JSplitPane;javax.swing.JTable;javax.

swing.

JText

Field;publicclassGZGLextendsJFrameimplementsAction

Listener{JFrame

f

=

new

JFrame("

工資管理");JButton

b1

=

new

JButton("

錄入");15JButton

b2JButtonb3JButton

b4=

ne=

ne=

newwwJButJButJButton("

修改");ton("

刪除");ton("

查詢所有");JButton

b5=

newJButton("

返回");JText

Fieldtf

1=newJText

Field(

4

);JText

Fieldtf

2=newJText

Field(

4

);JText

Fieldtf

3=newJText

Field(

4

);JText

Fieldtf

4=newJText

Field(

4

);JText

Fieldtf

5=newJText

Field(

6

);JText

Fieldtf

6=newJText

Field(

7

);=

{

"

職工號(hào)",

"

姓名",

"

津貼",

"

月基本工資String[]cloum","

月薪"};Object[][]rowJTabletable

==newObject[50][5];newJTable(row,

cloum);JScroll

Pane

scrollpane

=

new

JScroll

Pane(

table);newJSplit

Pane splitpane =JSplit

Pane(

JSplit

Pane.

VERTICAL_

SPLIT);voidcreate()

{JPanel

p

=

(JPanel)

f.

get

Content

Pane();p.setLayout(newFlowLayout());p.

add(

scrollpane);p.

add(

splitpane);JPanelp1=newJPanel();p1

.

add(

b

1

);p1

.

add(

b

2

);p1

.

add(

b

3

);p1

.

add(

b

4

);p1

.

add(

b

5

);JPanelp2=newJPanel();p2

.

set

Background(

Color.

cyan);p2

.

add(

scrollpane);JPanelp3=newJPanel();p.

set

Layout(

new

Flow

Layout());p.

add(

new

JLabel(""));p.

add(

new

JLabel("

職工號(hào)"));p.

add(

tf

1

);p.

add(

new

JLabel("

姓名"));p.

add(

tf

2

);p.

add(

new

JLabel("

津貼"));p.

add(

tf

3

);p.

add(

new

JLabel("

月基本工資"));p.

add(

tf

4

);p.

add(

new

JLabel("

月薪"));p.

add(

tf

5

);16在此處輸入職工號(hào)點(diǎn)擊查詢p.

add(

new

JLabel("刪除"));p.

add(

tf

6

);splitpane.add(p1,splitpane.TOP);splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);f.setBounds(200,100,500,600);f.

set

Resizable(

true);//

可以調(diào)整界面大小f.

set

Visible(

true);}public

void

action

Performed(

Action

Event

e)

{if

(b

1

.

equals(

e.

get

Source()))

{

//

錄入Connectioncon;Statementsql;try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{System.

out.

println(""

+

e1

);}try{con=Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");sql

=

con.

create

Statement();StringinsertStr="INSERTINTOwelfare(no,

name,

jt)

VALUES('"+

tf

1

.

get

Text()+"','"+

tf

2

.

get

Text()+"','"+

tf

3

.

get

Text()+"');";sql.

execute

Update(

insert

Str);StringinsertStr1="INSERTINTOwageinfo(no,

name,

jb)

VALUES('"+

tf

1

.

get

Text()+"','"+

tf

2

.

get

Text()+"','"+

tf

4

.

get

Text()+"');";sql.

execute

Update(

insert

Str

1

);con.

close();JOption

Pane.

show

Message

Dialog(

this,

"

入錄成功!");}catch(SQLExceptione1){JOption

Pane.

show

Message

Dialog(

this,

"

入錄失?。?7");}}if

(b

2

.

equals(

e.

get

Source()))

{//

修改Connection

con;Statementsql;try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{System.

out.

println(""

+

e1

);}try{con=Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");sql

=

con.

create

Statement();SETString update

Str = "UPDATE welfarejt='"+

tf

3

.

get

Text()+"',

name='"+

tf

2

.

get

Text()+"'

whereno='"+

tf

1

.

get

Text()+"';";sql.

execute

Update(

update

Str);String update

Str

1 = "UPDATE wageinfoSETjb='"+

tf

4

.

get

Text()+"',

name='"+

tf

2

.

get

Text()+"'

whereno='"+

tf

1

.

get

Text()+"';";sql.

execute

Update(

update

Str

1

);JOption

Pane.

show

Message

Dialog(

this,

"

修改成功!");con.

close();}catch(SQLExceptione1)

{JOption

Pane.

show

Message

Dialog(

this, "

存在!

");}}if

(b

3

.

equals(

e.

get

Source()))

{//

刪除Connection

con;Statementsql;ResultSetrs;try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{System.

out.

println(""

+

e1

);}try{con=18Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");=wherewheresqlcon.

create

Statement(

Result

Set.

TYPE_

SCROLL_

SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.

execute

Update("

DELETE

FROM

wageinfono='"+

tf

6

.

get

Text()+"';");sql.

execute

Update("

DELETE FROM welfareno='"+

tf

6

.

get

Text()+"';");JOption

Pane.

show

Message

Dialog(

this,

"

刪除成功!");con.

close();}catch(SQLExceptione1)

{JOption

Pane.

show

Message

Dialog(

this,

"

刪除失??!");}}if

(b

4

.

equals(

e.

get

Source()))

{//

查詢?nèi)緾onnection

con;Statementsql;Result

Setrs;//Vectorvector=newVector();try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{JOption

Pane.

show

Message

Dialog(

this,"

連接數(shù)據(jù)庫(kù)失??!

");}try{con=Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");=sqlcon.

create

Statement(

Result

Set.

TYPE_

SCROLL_

SENSITIVE,Result

Set.

CONCUR_

READ_

ONLY);if

(b

4

.

equals(

e.

get

Source()))

{for(inti=0;i<50;i++)for(intj=0;j<

4;j++)table.

set

Value

At("",

i,

j);rs

=

sql.

execute

Query("

select

distinct

*

fromwageinfo

,welfare where wageinfo.

name=

welfare.

name");19intk=

-1;while(rs.next())

{++

k;StringStringStringStringint sum=no

=

rs.

get

String(

1

);name

=

rs.

get

String(

2

);jb

=

rs.

get

String(

3

);jt

=

rs.

get

String(

6

);rs.

get

Int(

3

)+

rs.

get

Int(

6

);table.

set

Value

At(

no,

k,

0);table.

set

Value

At(

name,

k,

1);table.

set

Value

At(

jb,

k,

3);table.

set

Value

At(

jt,

k,

2);table.

set

Value

At(

sum,

k,

4

);}}}catch(SQLExceptione1){JOption

Pane.

show

Message

Dialog(

this,"

查詢失敗!");}}{//

返回if

(b

5

.

equals(

e.

get

Source()))GZGLZJMgl=new

GZGLZJM();gl.

create();f.

dispose();}}}YGGLZJM.

javapackagewage_

management;importimportimportimportimportimportimportjava.awt.Color;java.awt.FlowLayout;java.

awt.

event.

Action

Event;java.

awt.

event.

Action

Listener;java.sql.Connection;java.sql.DriverManager;java.

sql.

Result

Set;20importimportimportimportimportimportimportimportimportpublicjava.sql.SQLException;java.sql.Statement;javax.swing.JButton;javax.swing.JFrame;javax.

swing.

JOption

Pane;javax.swing.JPanel;javax.

swing.

JScroll

Pane;javax.

swing.

JSplit

Pane;javax.

swing.

JTable;classYGDLJMextendsDLimplementsActionListener

{JFrame

f

=

new

JFrame("

工資管理");JButtonJButtonb1b2==newnewJButton("

查詢個(gè)人工資");JButton("

修改密碼");JButtonb3=newJButton("

返回");=

{

"

職工號(hào)",

"

姓名",

"

津貼",

"

月基本工資String[]cloum","

月薪"};Object[][]rowJTabletable

==newObject[50][5];newJTable(row,

cloum);JScroll

Pane

scrollpane

=

new

JScroll

Pane(

table);newJSplit

Pane splitpane =JSplit

Pane(

JSplit

Pane.

VERTICAL_

SPLIT);voidcreate()

{JPanel

p

=

(JPanel)

f.

get

Content

Pane();p.setLayout(newFlowLayout());p.

add(

scrollpane);p.

add(

splitpane);JPanelp1=new

JPanel();p1

.

add(

b

1

);p1

.

add(

b

2

);p1

.

add(

b

3

);JPanelp2=newJPanel();p2

.

set

Background(

Color.

cyan);p2

.

add(

scrollpane);JPanelp3=newJPanel();p.

set

Layout(

new

Flow

Layout());splitpane.

add(

p

1

,

splitpane.

TOP);splitpane.

add(

p

2

,

splitpane.

BOTTOM);splitpane.

set

Divider

Location(

50

);21p.

set

Background(

Color.

CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);f.setBounds(200,100,500,550);f.

set

Resizable(

true);//

可以調(diào)整界面大小f.

set

Visible(

true);}public

void

action

Performed(

Action

Event

e)

{if

(b

1

.

equals(

e.

get

Source()))

{//

查詢個(gè)人工資Connection

con;Statementsql;ResultSetrs;try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{System.

out.

println(""

+

e1

);}try{con=Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");=sqlcon.

create

Statement(

Result

Set.

TYPE_

SCROLL_

SENSITIVE,Result

Set.

CONCUR_

READ_

ONLY);if

(b

1

.

equals(

e.

get

Source()))

{for(inti=0;i<50;i++)for(intj=0;j<

4;j++)table.

set

Value

At("",

i,

j);//

System.

out.

println(

t

1

);rs

=

sql.

execute

Query("

select

distinct

*

fromwageinfo ,welfare,

workerinfo wherewageinfo.

no=

welfare.

no

and

wageinfo.

no=

workerinfo.

no

andworkerinfo.

name='"+

t

1

+"'

and

workerinfo.

mi='"+

t

2

+"'");intk=

-1;while(rs.next())

{++

k;Stringno

=rs.

get

String(

1

);Stringname=

rs.

get

String(

2

);Stringjb

=rs.

get

String(

3

);22String

jt

=

rs.

get

String(

6

);int sum= rs.

get

Int(

3

)+

rs.

get

Int(

6

);table.

set

Value

At(

no,

k,

0);table.

set

Value

At(

name,

k,

1);table.

set

Value

At(

jb,

k,

3);table.

set

Value

At(

jt,

k,

2);table.

set

Value

At(

sum,

k,

4

);}}}catch(SQLExceptione1){JOption

Pane.

show

Message

Dialog(

this,"

查詢失??!");}}if

(b

2

.

equals(

e.

get

Source())){//

修改密碼XGMMxgmm=new

XGMM();xgmm.

create();{//

返回}if

(b

3

.

equals(

e.

get

Source()))DLdl=newDL();dl.

create();f.

dispose();}}}YGGL.

javapackagewage_

management;importimportimportimportimportimportimportimportjava.awt.Color;java.awt.FlowLayout;java.

awt.

event.

Action

Event;java.

awt.

event.

Action

Listener;java.sql.Connection;java.sql.DriverManager;java.sql.ResultSet;java.

sql.

SQLException;23importimportimportimportimportimportimportimportimportimportjava.sql.Statement;javax.swing.JButton;javax.swing.JFrame;javax.swing.JLabel;javax.

swing.

JOption

Pane;javax.swing.JPanel;javax.

swing.

JScroll

Pane;javax.

swing.

JSplit

Pane;javax.swing.JTable;javax.

swing.

JText

Field;publicclassYGGLextendsJFrameimplementsAction

Listener{JFrame

f

=

new

JFrame("

員工信息管理");JButton

b1JButtonb2JButtonb3JButton

b4=

ne=

ne=

ne=

newwwwJButJButJButJButton("

添加新員工信息");ton("

修改員工信息");ton("

刪除員工信息");ton("

查詢所有員工信息");JButton

b5=

newJButton("

返回");JText

Fieldtf

1=newJText

Field(

4

);JText

Fieldtf

2=newJText

Field(

4

);JText

Fieldtf

3=newJText

Field(

4

);JText

Fieldtf

4=newJText

Field(

4

);JText

Fieldtf

5=newJText

Field(

6

);JText

Fieldtf

6=newJText

Field(

7

);String[]

cloum

=

{

"

職工號(hào)",

"

姓名",

"

津貼",

"

月基本工資","

月薪","

登陸密碼"};Object[][]row=newObject[50][6];JTabletable=newJTable(row,

cloum);JScroll

Pane

scrollpane

=

new

JScroll

Pane(

table);newJSplit

Pane splitpane =JSplit

Pane(

JSplit

Pane.

VERTICAL_

SPLIT);voidcreate()

{JPanel

p

=

(JPanel)

f.

get

Content

Pane();p.setLayout(newFlowLayout());p.

add(

scrollpane);p.

add(

splitpane);JPanelp1=newJPanel();p1

.

add(

b

1

);p1

.

add(

b

2

);p1

.

add(

b

3

);p1

.

add(

b

4

);p1

.

add(

b

5

);JPanelp2=newJPanel();p2

.

set

Background(

Color.

cyan);24p2.add(scrollpane);p.

set

Layout(

new

Flow

Layout());p.

add(

new

JLabel(""));p.

add(

new

JLabel("

職工號(hào)"));p.

add(

tf

1

);p.

add(

new

JLabel("

姓名"));p.

add(

tf

2

);p.

add(

new

JLabel("

津貼"));p.

add(

tf

3

);p.

add(

new

JLabel("

月基本工資"));p.

add(

tf

4

);p.

add(

new

JLabel("

登陸密碼"));p.

add(

tf

5

);在此處輸入職工號(hào)點(diǎn)擊查p.

add(

new

JLabel("詢刪除"));p.

add(

tf

6

);splitpane.add(p1,splitpane.TOP);splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);f.setBounds(200,100,600,600);f.

set

Resizable(

true);//

可以調(diào)整界面大小f.

set

Visible(

true);}public

void

action

Performed(

Action

Event

e)

{if

(b

1

.

equals(

e.

get

Source()))

{

//

添加新員工信息Connection

con;Statementsql;try

{Class.

for

Name("

org.

gjt.

mm.

mysql.

Driver");}

catch

(Class

Not

Found

Exception

e1

)

{JOption

Pane.

show

Message

Dialog(

this,"

連接數(shù)據(jù)庫(kù)失敗!

");}try

{con =Driver

Manager.

get

Connection("

jdbc:

mysql://

localhost:

3306

/

wage

management","

root","

jxb");sql

=

con.

create

Statement();25StringinsertStr="INSERTINTOwelfare(no,

name,

jt)

VALUES('"+

tf

1

.

get

Text()

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論