前言:
隨著小超市規模的發展不斷擴大, 商品數量急劇增加, 有關商品的各種信息量也成倍增長。 超市時時刻刻都需要對商品各種信息進行統計分析。 而大型的超市管理系統功能過于強大而造成操作繁瑣降低了小超市的工作效率。 超市管理系統是市場上最流行的超市上常用的系統之一, 由于剛學java知識、所有功能設計的比較簡單、只有商品信息的增刪改查。實現對商品信息全面、 動態、及時的管理。本文系統的分析了軟件開發的背景以過程;首先介紹了軟件的開發環境, 其次介紹了本軟件的詳細設計過程: 數據庫的設計、各個模塊的設計和實現,以及具體界面的設計和功能。超市庫存管理系統是基于 java eclipse 作為開發工具 , mysql 作為后臺數據庫支持。超市庫存管理系統開發主要是界面程序的開發、數據庫的建立、數據庫的維護。應用程序功能完善,界面人機交互要好,而且操作簡單。同時 javaswing語言簡單,在較短的時間內能夠開發出使用性強、 功能完善, 易于操作的程序, 也能實現與數據庫的連接。
主要模塊:
商品列表數據展示、商品信息添加、商品信息修改、商品信息刪除、按照商品名稱查詢商品信息
1、功能介紹
功能截圖:
查詢商品列表信息:
添加商品信息:
修改商品信息:
刪除商品信息:
刪除之后需要刷新一下列表數據
?編號查詢商品信息:
2、關鍵代碼
2.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
|
public class goodsmanage extends jframe { private jtextfield textfield; select select = new select(); updata updata = new updata(); object[] header= { "商品編號" , "商品名稱" , "數量" , "單價" }; string sql = "select goodsid,goodsname,num,price from goods" ; object[][] data= select.getgoods(sql); defaulttablemodel df = new defaulttablemodel(data, header); int v=scrollpaneconstants.vertical_scrollbar_as_needed; int h=scrollpaneconstants.horizontal_scrollbar_as_needed; public goodsmanage() { super ( "商品管理系統" ); this .setbounds( 0 , 0 , 700 , 450 ); this .setlocationrelativeto( null ); //讓窗口在屏幕中間顯示 this .setresizable( false ); //讓窗口大小不可改變 getcontentpane().setlayout( null ); jtable jtable = new jtable(df); jscrollpane jsp= new jscrollpane(jtable,v,h); jsp.setbounds( 10 , 10 , 515 , 320 ); getcontentpane().add(jsp); jbutton button_1 = new jbutton( "顯示所有商品" ); button_1.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { string sql = "select goodsid,goodsname,num,price from goods" ; object[][] data = select.getgoods(sql); df.setdatavector(data, header); } }); button_1.setbounds( 535 , 80 , 127 , 30 ); getcontentpane().add(button_1); jbutton button_2 = new jbutton( "修改商品" ); button_2.setbounds( 535 , 140 , 127 , 30 ); getcontentpane().add(button_2); button_2.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { if (jtable.getselectedcolumn()< 0 ) { joptionpane.showmessagedialog( null , "請選擇要修改的數據!" ); } else { int goodsid = integer.parseint(jtable.getvalueat(jtable.getselectedrow(), 0 ).tostring()); string name = jtable.getvalueat(jtable.getselectedrow(), 1 ).tostring(); int num = integer.parseint(jtable.getvalueat(jtable.getselectedrow(), 2 ).tostring()); string price = jtable.getvalueat(jtable.getselectedrow(), 3 ).tostring(); goods goods = new goods(goodsid,name,num,price); goodsxg goodsxg = new goodsxg(goods); goodsxg.setvisible( true ); } } }); jbutton button_3 = new jbutton( "刪除商品" ); button_3.setbounds( 535 , 200 , 127 , 30 ); getcontentpane().add(button_3); button_3.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { if (jtable.getselectedcolumn()< 0 ) { joptionpane.showmessagedialog( null , "請選中要刪除的數據!" ); } else { int goodsid = integer.parseint(jtable.getvalueat(jtable.getselectedrow(), 0 ).tostring()); string sql= "delete from goods where goodsid=" +goodsid; int result = updata.adddata(sql); if (result> 0 ) { joptionpane.showmessagedialog( null , "刪除成功!" ); joptionpane.showmessagedialog( null , "記得刷新一下哦!" ); } else { joptionpane.showmessagedialog( null , "刪除失敗!" ); } } } }); jbutton button_4 = new jbutton( "添加商品" ); button_4.setbounds( 535 , 258 , 127 , 30 ); getcontentpane().add(button_4); button_4.addactionlistener( new actionlistener() { public void actionperformed(actionevent arg0) { goodsadd goodsadd = new goodsadd(); goodsadd.setvisible( true ); } }); jlabel label = new jlabel( "商品編號:" ); label.setbounds( 40 , 354 , 112 , 32 ); getcontentpane().add(label); textfield = new jtextfield(); textfield.setbounds( 154 , 358 , 127 , 26 ); getcontentpane().add(textfield); textfield.setcolumns( 10 ); jbutton button = new jbutton( "按編號查詢" ); button.addactionlistener( new actionlistener() { public void actionperformed(actionevent arg0) { string sql = "select goodsid,goodsname,num,price from goods where goodsid like '%" +textfield.gettext()+ "%'" ; object[][] data = select.getgoods(sql); df.setdatavector(data, header); } }); button.setbounds( 305 , 355 , 112 , 30 ); getcontentpane().add(button); this .addwindowlistener( new windowadapter() { public void windowclosing(windowevent e) { super .windowclosing(e); //加入動作 goodsmanagement m = new goodsmanagement(); m.setvisible( true ); } }); } public static void main(string[] args) { goodsmanage t = new goodsmanage(); t.setvisible( true ); } } |
2.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
|
public class goodsadd extends jframe { private jtextfield id,name,num,price; private jbutton button; private jbutton button_1; public goodsadd() { super ( "商品管理系統" ); this .setbounds( 0 , 0 , 400 , 450 ); this .setlocationrelativeto( null ); //讓窗口在屏幕中間顯示 this .setresizable( false ); //讓窗口大小不可改變 getcontentpane().setlayout( null ); jlabel label = new jlabel( "商品編號:" ); label.setbounds( 85 , 89 , 87 , 22 ); getcontentpane().add(label); id = new jtextfield(); id.setbounds( 147 , 90 , 142 , 21 ); getcontentpane().add(id); id.setcolumns( 10 ); jlabel label_1 = new jlabel( "商品名稱" ); label_1.setbounds( 85 , 139 , 87 , 22 ); getcontentpane().add(label_1); name = new jtextfield(); name.setcolumns( 10 ); name.setbounds( 147 , 140 , 142 , 21 ); getcontentpane().add(name); jlabel label_2 = new jlabel( "數量:" ); label_2.setbounds( 85 , 193 , 87 , 22 ); getcontentpane().add(label_2); num = new jtextfield(); num.setcolumns( 10 ); num.setbounds( 147 , 194 , 142 , 21 ); getcontentpane().add(num); jlabel label_3 = new jlabel( "單價:" ); label_3.setbounds( 85 , 241 , 87 , 22 ); getcontentpane().add(label_3); price = new jtextfield(); price.setcolumns( 10 ); price.setbounds( 147 , 242 , 142 , 21 ); getcontentpane().add(price); button = new jbutton( "確定" ); button.setbounds( 78 , 317 , 93 , 23 ); getcontentpane().add(button); button.addactionlistener( new actionlistener() { public void actionperformed(actionevent arg0) { string addid = id.gettext(); string addname = name.gettext(); string addnum = num.gettext(); string addprice = num.gettext(); if (addname.equals( "" )||addname.equals( "" )||addnum.equals( "" )||addprice.equals( "" )) { joptionpane.showmessagedialog( null , "請完整輸入要添加的數據" ); } else { string sql= "insert into goods values(" +addid+ ",'" +addname+ "','" +addnum+ "','" +addprice+ "')" ; int result = updata.adddata(sql); if (result> 0 ) { joptionpane.showmessagedialog( null , "添加成功!" ); joptionpane.showmessagedialog( null , "記得刷新一下哦!" ); dispose(); // goodsmanage i = new goodsmanage(); // i.setvisible(true); } else { joptionpane.showmessagedialog( null , "添加失敗!" ); } } } }); button_1 = new jbutton( "取消" ); button_1.setbounds( 208 , 317 , 93 , 23 ); getcontentpane().add(button_1); button_1.addactionlistener( new actionlistener() { public void actionperformed(actionevent arg0) { dispose(); } }); } } |
2.3 數據庫設計
商品表
1
2
3
4
5
6
7
8
9
10
11
|
create table `newtable` ( `goodsid` int ( 11 ) not null , `goodsname` varchar( 10 ) character set utf8 collate utf8_general_ci not null , `num` int ( 11 ) not null , `price` decimal( 10 , 4 ) not null , primary key (`goodsid`) ) engine=innodb default character set=utf8 collate=utf8_general_ci row_format=compact ; |
到此這篇關于基于mysql+javaswing
的超市商品管理系統設計與實現的文章就介紹到這了,更多相關mysql+javaswing
的超市商品管理系統設計與實現內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://juejin.cn/post/7012021268597702664