《T 科技 酒店管理系统.docx》由会员分享,可在线阅读,更多相关《T 科技 酒店管理系统.docx(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、实 验 报 告面向对象程序设计上机实验20112012学年第 二 学期学院(部)管理学院班级代号031509230姓 名孙景武成 绩指导教师田书格T 酒店管理系统一、 功能概述为满足酒店日益复杂的需求,本系统开发的目的就是解决数据的整理,做到账单管理的智能化。通过本系统,酒店管理员可以方便准确的为客人提供需求,并能详细的归档。尤其是系统的当天统计、分月统计、和年终统计使得酒店的账目一目了然。二、 需求分析E_R 图m点菜package com.mwq.dao;import java.sql.*;public class JDBC private static final String DRIV
2、ERCLASS = com.microsoft.sqlserver.jdbc.SQLServerDriver;private static final String URL = jdbc:sqlserver:/localhost:1433;DatabaseName=db_DrinkeryManage;private static final String USERNAME = sa;private static final String PASSWORD = sa;private static final ThreadLocal threadLocal = new ThreadLocal();
3、static try Class.forName(DRIVERCLASS).newInstance(); System.out.println(驱动加载成功!); catch (Exception e) e.printStackTrace();public static Connection getConnection() Connection conn = threadLocal.get(); if (conn = null) try conn = DriverManager.getConnection(URL, USERNAME, PASSWORD); threadLocal.set(co
4、nn); catch (SQLException e) e.printStackTrace();return conn;public static boolean closeConnection() boolean isClosed = true;Connection conn = threadLocal.get(); threadLocal.set(null); if (conn != null) try conn.close(); catch (SQLException e) isClosed = false;e.printStackTrace();return isClosed;pack
5、age com.mwq;import java.awt.Dimension;import java.awt.Toolkit;import javax.swing.SwingUtilities;import javax.swing.UIManager;import com.mwq.frame.LandFrame;public class DrinkeryManage public DrinkeryManage() / Center the windowToolkit toolkit = Toolkit.getDefaultToolkit();Dimension screenSize = tool
6、kit.getScreenSize();LandFrame landFrame = new LandFrame();Dimension frameSize = landFrame.getSize();if (frameSize.width screenSize.width) frameSize.width = screenSize.width;if (frameSize.height screenSize.height) frameSize.height = screenSize.height;landFrame.setLocation(screenSize.width - frameSize
7、.width) / 2,(screenSize.height - frameSize.height) / 2);landFrame.setVisible(true);public static void main(String args) SwingUtilities.invokeLater(new Runnable() public void run() try UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName(); catch (Exception exception) exception.printStack
8、Trace();new DrinkeryManage(););数量消费n三、 功能实现管理员登陆后显示主界面,系统功能有:菜品管理、分类管理、台号管理;结账功能有:日结账、月结账和年结账;账号:修改密码、用户管理和退出。可以根据客人的要求开单,结束后进行签单,最后结账。菜品管理可以增删菜品等。四、 数据库设计表tb_desk表tb_menu表tb_order_form表tb_order_item表tb_sort表tb_user五、 功能展示登陆界面:系统主界面:用户管理:菜品管理:台号管理:每日结账:结账:六、 关键类package com.mwq.dao;import java.sql.*;
9、public class JDBC private static final String DRIVERCLASS = com.microsoft.sqlserver.jdbc.SQLServerDriver;private static final String URL = jdbc:sqlserver:/localhost:1433;DatabaseName=db_DrinkeryManage;private static final String USERNAME = sa;private static final String PASSWORD = sa;private static
10、final ThreadLocal threadLocal = new ThreadLocal();static try Class.forName(DRIVERCLASS).newInstance(); System.out.println(驱动加载成功!); catch (Exception e) e.printStackTrace();public static Connection getConnection() Connection conn = threadLocal.get(); if (conn = null) try conn = DriverManager.getConne
11、ction(URL, USERNAME, PASSWORD); threadLocal.set(conn); catch (SQLException e) e.printStackTrace();return conn;public static boolean closeConnection() boolean isClosed = true;Connection conn = threadLocal.get(); threadLocal.set(null); if (conn != null) try conn.close(); catch (SQLException e) isClose
12、d = false;e.printStackTrace();return isClosed;package com.mwq;import java.awt.Dimension;import java.awt.Toolkit;import javax.swing.SwingUtilities;import javax.swing.UIManager;import com.mwq.frame.LandFrame;public class DrinkeryManage public DrinkeryManage() / Center the windowToolkit toolkit = Toolk
13、it.getDefaultToolkit();Dimension screenSize = toolkit.getScreenSize();LandFrame landFrame = new LandFrame();Dimension frameSize = landFrame.getSize();if (frameSize.width screenSize.width) frameSize.width = screenSize.width;if (frameSize.height screenSize.height) frameSize.height = screenSize.height;
14、landFrame.setLocation(screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);landFrame.setVisible(true);public static void main(String args) SwingUtilities.invokeLater(new Runnable() public void run() try UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()
15、; catch (Exception exception) exception.printStackTrace();new DrinkeryManage(););七、 实验心得一个寒假一个实验项目,虽然时间挺多,但是项目仍然很粗糙。期间还出现了这样那样的问题:1、 常用类的方法不够熟悉比如:JList 设置选项时用Vector,无法刷新。JList在构造方法中生成,数据则在监听方法中改变,这样一来不知道怎么刷新。想过很多方法,网上查过好多资料。最后看到一个实例,JList有setData()方法。这样一来问题迎刃而解!2、 图形界面,布局掌握不够课上讲过不少的布局,后来经过查看资料发现Card布局更加常用。3、 数据库的链接不够熟练用SQL Server 作为系统的后台数据管理系统,竟然不知道怎么连接,想想相关的字符,用户名,密码都正确怎么还是不能连接呢?后来发现原来是驱动没有加载!到微软下载了Microsoft SQL Server JDBC Driver 3.0 系统还是不能正确运行。继续搜索原因,又花了很久,才只能是端口的问题,IPAll 的设置问题,改成1433 并启动TCP/IP 服务,到这里系统才得以正确运行!
限制150内