好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

java swing实现电影购票系统

本文实例为大家分享了java swing实现电影购票系统的具体代码,供大家参考,具体内容如下

首先系统分为前台用户登录注册和后台管理员进行管理

项目采用三层架构思想

系统首页

电影详情以及查看评论

查看所有电影场次

购买影票选择座位

查看影票以及点击进入评论

对购买的影票进行想评论

接下来看看管理员

管理员进行操作,几个按钮样式差不错,就不全贴了。感觉已经贴的挺详细的了。

代码的话就贴一些通用的访问数据库的具有通用的增删改查的代码。

?

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

/**

  * 执行增删改的操作

  * @param sql

  * @param param

  * @return

  */

  public static boolean operupdate(string sql, list<object> param) {

  int res = 0 ; // 获得影响的行数

  connection conn = null ; // 获取连接

  preparedstatement psts = null ; // 装载sql语句

  resultset rs = null ;

  conn = getconn();

  try {

  psts = conn.preparestatement(sql);

  if (param != null ) {

  for ( int i = 0 ; i < param.size(); i++) {

   psts.setobject(i + 1 , param.get(i));

  }

  }

  res = psts.executeupdate();

 

  } catch (sqlexception e) {

  e.printstacktrace();

  } finally {

  closeall(rs, psts, conn); //关闭相关的连接

  }

  return res > 0 ? true : false ;

 

  }

?

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

/**

  * 执行查找的操作

  * @param sql

  * @param param

  * @return

  */

  public static <t> list<t> operquery(string sql, list<object> param, class <t> cls) {

  connection conn = null ; // 获取连接

  preparedstatement psts = null ; // 装载sql语句

  resultset rs = null ;

  conn = getconn();

  list<t> list = new arraylist<t>();

  try {

  psts = conn.preparestatement(sql);

  if (param != null ) {

  for ( int i = 0 ; i < param.size(); i++) {

   psts.setobject(i + 1 , param.get(i));

  }

  }

  rs=psts.executequery();

 

  resultsetmetadata rsmd = rs.getmetadata();

  while (rs.next()){

  t entity = cls.newinstance();

  for ( int j = 0 ;j<rsmd.getcolumncount();j++){

   string columnname = rsmd.getcolumnname(j+ 1 );

   object value = rs.getobject(columnname);

   field fields = cls.getdeclaredfield(columnname);

   fields.setaccessible( true );

   fields.set(entity, value);

  }

  list.add(entity);

  }

  } catch (sqlexception e) {

  e.printstacktrace();

  } catch (instantiationexception e) {

  e.printstacktrace();

  } catch (illegalaccessexception e) {

  e.printstacktrace();

  } catch (nosuchfieldexception e) {

  e.printstacktrace();

  } catch (securityexception e) {

  e.printstacktrace();

  } finally {

  closeall(rs, psts, conn);

  }

  return list;

  }

上述两个方法还是蛮具有通用性的。如有错误,希望各位看到的大佬不吝赐教。

下载地址 下载

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

原文链接:https://blog.csdn.net/kzw11/article/details/81354777

查看更多关于java swing实现电影购票系统的详细内容...

  阅读:13次