使用三層架構實現(xiàn)電影購票系統(tǒng),分用戶和管理員,用戶功能:展示電影,查找電影(模糊查詢),查看電影詳情,查找場次,購買影票,訂制座位,退訂影票等功能,界面美觀漂亮,邏輯嚴謹,附加電影評論功能,訂票超過五張打0.9折的打折功能。管理員功能:影院的增刪改查,場次的增刪改查,電影的增刪改查,影票管理等。
管理員賬號:admin 密碼:admin
效果展示圖:
登錄界面:
用戶主界面:
查看熱門電影:
點擊電影進入查看詳情,可以看到該電影的所有評論,可以進行評論。
點擊想看電影進入場次界面,可通過影院名查詢場次,支持模糊查詢。
選好場次進入訂座購票界面,購買票并扣取相應錢數(shù),顯示余額
返回主頁,查看我的影票,選擇影票并查看我的評論 ,如未評論可進行評論,評論過可進行修改評論,可退訂影票,退訂成功錢會返還給用戶。
再看查找電影功能,支持模糊查詢,也可點擊海報進入電影詳情
咱們來展示下basedao的代碼:
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
|
import java.lang.reflect.field; import java.sql.connection; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.resultsetmetadata; import java.sql.sqlexception; import java.util.arraylist; import java.util.list; public class basedao { public static final string driver = "com.mysql.jdbc.driver" ; public static final string url = "jdbc:mysql://localhost:3306/tickets" ; // 加載驅動,只需加載一次 static { try { class .forname(driver); } catch (classnotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } } // 獲得連接 public connection getconn() { connection conn = null ; try { conn = drivermanager.getconnection(url, "root" , "123456" ); } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } return conn; } // 關閉所有 public void releaseall(resultset rs, preparedstatement pstmt, connection conn) { try { if (rs != null ) { rs.close(); } if (pstmt != null ) { pstmt.close(); } if (conn != null ) { conn.close(); } } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } } // 增刪改 封裝 public boolean operupdate(string sql, list<object> params) { connection conn = null ; preparedstatement pstmt = null ; int res = 0 ; // 獲得與數(shù)據(jù)庫的連接對象 conn = getconn(); try { pstmt = conn.preparestatement(sql); if (params != null ) { for ( int i = 0 ; i < params.size(); i++) { pstmt.setobject(i + 1 , params.get(i)); } } // 增刪改的統(tǒng)一方法 res = pstmt.executeupdate(); //返回的是sql在數(shù)據(jù)庫中影響的行數(shù) } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } finally { releaseall( null , pstmt, conn); } return res > 0 ? true : false ; } public <t> list<t> operquery(string sql, list<object> params, class <t> cls) throws exception { connection conn = null ; preparedstatement pstmt = null ; resultset rs = null ; list<t> list = new arraylist<t>(); conn = getconn(); try { pstmt = conn.preparestatement(sql); if (params != null ) { for ( int i = 0 ; i < params.size(); i++) { pstmt.setobject(i + 1 , params.get(i)); } } // 增刪改的統(tǒng)一方法 rs = pstmt.executequery(); resultsetmetadata rsmd = rs.getmetadata(); while (rs.next()) { t m = cls.newinstance(); for ( int i = 0 ; i < rsmd.getcolumncount(); i++) { string col_name = rsmd.getcolumnname(i + 1 ); object value = rs.getobject(col_name); field field; field = cls.getdeclaredfield(col_name); field.setaccessible( true ); field.set(m, value); } list.add(m); } } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } finally { releaseall(rs, pstmt, conn); } return list; } } |
該項目界面美觀,代碼封裝性良好,邏輯嚴密,僅供參考。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/zouzong123/article/details/81534635