java swing实现电影购票系统

java swing实现电影购票系统

首先系统分为前台用户登录注册和后台管理员进行管理
项目采用三层架构思想
系统首页

系统首页
用户登录成功浏览电影
电影详情以及查看评论
电影详情以及查看评论
查看所有电影场次
查看所有电影场次
购买影票选择座位
购买影票选择座位
查看影票以及点击进入评论
查看影票以及点击进入评论
对购买的影票进行想评论
对购买的影票进行想评论

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

代码的话就贴一些通用的访问数据库的具有通用的增删改查的代码吧,其余的就···

/**
     * 执行增删改的操作
     * @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;

    }
/**
     * 执行查找的操作
     * @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;
    }

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

下载地址下载

猜你喜欢

转载自blog.csdn.net/kzw11/article/details/81354777