阳光酒店管理系统 完整源码公布 [清华IT](1)_叛逆年少_新浪博客

 

                        阳光酒店管理系统完整源码

                                 ------清华IT

 

 

------------

网上很流行的一个系统。特此公布其完整源码。以飨博友。

设计测试过程中没有实现,其数据库的链接和操作。日后自会加强这点。也望高人指点。

作者:   董丰。测试:July

---------------------------------------------------------------------------------


//package com.sunshine.about;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

 

public class About extends JDialog

implements ActionListener {
 
 JLabel top, li, fee, tit, ver, user, co, boss, temp;
 JPanel pm, info, i1, i2, bott, bp;
 JButton bt1;
 
 
 
 public About (JFrame frame) {
  super (frame, "关于我们", true);
  
  top = new JLabel (new ImageIcon("pic/about.gif"));
  li = new JLabel (new ImageIcon("pic/line1.gif"));
  fee = new JLabel ("<html>技术支持: >版权所有  (C) 2006   SunshineSOFT Corporation.</html>");
  tit = new JLabel ("        欢 迎 使 用 阳 光 酒 店 管 理 系 统");
  ver = new JLabel ("版本:  2006 Bate1        ");
  user= new JLabel ("软件用户:  " + sunini.getIniKey("UserName"));
  co = new JLabel ("                         所属公司:  " + sunini.getIniKey("CompName"));
  boss= new JLabel ("       阳光设计组    组长: 顾俊     小组成员:  董丰、杨芳、齐帅、彭宏伟、刘楠楠     ");
  temp= new JLabel ("       ");
  bt1 = new TJButton ("pic/choose.gif", "确  定", "");
  
  pm = new JPanel (new BorderLayout ());
  info = new JPanel (new GridLayout (4, 1, 0, 0));
  bott = new JPanel (new BorderLayout ());
  i1  = new JPanel ();
  i2  = new JPanel (new FlowLayout (FlowLayout.RIGHT));
  bp  = new JPanel (new FlowLayout (FlowLayout.RIGHT, 10 ,8));
  
  //制作信息面板
  i1.add (user);
  i1.add (co);
  i2.add (ver);
  info.add (tit);
  info.add (i2);
  info.add (i1);
  info.add (boss);
  
  //制作下边组件
  bp.add (bt1);
  bott.add ("North", li);
  bott.add ("West", temp);
  bott.add ("East", bp);
  bott.add ("Center", fee);
  
  //制作主面板
  pm.add ("North", top);
  pm.add ("South", bott);
  pm.add ("Center", info);
  
  bt1.addActionListener (this);
  
  this.setContentPane (pm);
  this.setResizable (false);
  pack();
  sunswing.setWindowCenter(this);
 }
 
 
 public void actionPerformed (ActionEvent ae) {
  this.setVisible (false);
 }
}

 

 

----------------------------------------------------


//package com.sunshine.setup;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

 


public class AddCustomerType
extends JDialog
implements ActionListener {
 
 private JTextField tf1, tf2, tf3;
 private JButton bt1, bt2;
 
 
 public AddCustomerType(JDialog dialog) {
  super(dialog, "客户类型", true);
  
  JLabel lb, lb1, lb2, lb4;
  JPanel panelMain, panelInfo, p1, p2, p3, p4, p5;  //定义各组件面板
  
  p1 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
  p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
  p3 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
  p5 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
  p4 = new JPanel(new FlowLayout(FlowLayout.CENTER, 30, 6));
  panelInfo = new JPanel(new GridLayout(4, 1, 0, 0));
  panelMain = new JPanel(new BorderLayout());
  
  lb1 = new JLabel("客户类型:");
  lb2 = new JLabel("打折比例:");
  lb4 = new JLabel("类型编号:");
  lb  = new JLabel("<html>注:此打折比例仅适用于商品项目!<br>  8为八折,10为不打折<html>");
  lb.setForeground(new Color(255, 138, 0));
  
  tf1 = new TJTextField(7);
  tf2 = new TJTextField(7);
  tf3 = new TJTextField("10", 7);
  
  bt1 = new TJButton ("pic/save.gif", "确定", "确定添加客户类型");
  bt2 = new TJButton ("pic/cancel.gif", "取消", "取消操作");
  
  //加入组件
  p1.add(lb1);
  p1.add(tf2);
  p2.add(lb2);
  p2.add(tf3);
  p3.add(lb);
  p4.add(bt1);
  p4.add(bt2);
  p5.add(lb4);
  p5.add(tf1);
  
  panelInfo.add(p5);
  panelInfo.add(p1);
  panelInfo.add(p2);
  panelInfo.add(p3);
  panelMain.add("Center", panelInfo);
  panelMain.add("South", p4);
  
  //加事件监听
  addListener();
  
  panelInfo.setBorder (BorderFactory.createTitledBorder("新客户类型信息"));
  
  this.setContentPane(panelMain);
  this.setPreferredSize (new Dimension (250,255));
  this.setMinimumSize (new Dimension (250,255));
  this.setResizable(false);   //不允许改变窗口大小
  pack();
  sunswing.setWindowCenter(this);  //窗口屏幕居中
 }
 
 
 private void addListener() {
  bt1.addActionListener(this);
  bt2.addActionListener(this);
  tf1.addActionListener(this);
  tf2.addActionListener(this);
  tf3.addActionListener(this);
 }
 
 
 private boolean isValidity() {
  if(tf1.getText().length() == 0) {
   JOptionPane.showMessageDialog(null, "客户 [ 类型编号 ] 不能为空", "提示",
   JOptionPane.INFORMATION_MESSAGE);
   tf1.requestFocus(true);
   return false;
  }else if(tf2.getText().length() == 0) {
   JOptionPane.showMessageDialog(null, "客户 [ 类型名称 ] 不能为空", "提示",
   JOptionPane.INFORMATION_MESSAGE);
   tf2.requestFocus(true);
   return false;
  }else if(!suntools.isNum(tf3.getText(), 2, 1, 10)) {
   JOptionPane.showMessageDialog(null, "[ 折扣比例 ] 只能是数字,且范围在 1-10 之间",
   "提示", JOptionPane.INFORMATION_MESSAGE);
   tf3.requestFocus(true);
   return false;
  }//Endif
  return true;
 }
 
 
 private void saveAddCustomerType() {
  if(isValidity()) {     //栓测用户输入的数据是否合法
   try {
    ResultSet rs = sunsql.executeQuery("select c_type from customertype " +
    "where delmark=0 and id='" + tf1.getText() + "'");
    if(rs.next()) {   //检测新的类型编号是否存在
     JOptionPane.showMessageDialog(null, "新的客户类型编号 [ " + tf1.getText() +
     " ] 已存在,不能执行添加操作,请重新核对 ...", "提示", JOptionPane.INFORMATION_MESSAGE);
     tf1.requestFocus(true);
     return;
    }//Endif
    rs = sunsql.executeQuery("select id from customertype " +
    "where delmark=0 and c_type='" + tf2.getText() + "'");
    if(rs.next()) {   //检测新的类型名称是否存在
     JOptionPane.showMessageDialog(null, "新的客户类型名称 [ " + tf2.getText() +
     " ] 已存在,不能执行添加操作,请重新核对 ...", "提示", JOptionPane.INFORMATION_MESSAGE);
     tf2.requestFocus(true);
     return;
    }//Endif
    //获得房间类型名称
    long pk = sunsql.getPrimaryKey();   //获得主键
    rs = sunsql.executeQuery("select id,price from roomtype where delmark=0");
    int type = sunsql.recCount(rs);    //获得房间类型总数
    String sqlCode[] = new String[type+1];
    for (int i = 0; i < type; i++) {
     rs.next();
     //生成SQL语句
     sqlCode[i] = "insert into customertype(pk,id,c_type,dis_attr,discount,price) " +
     "values(" + pk + ",'" + tf1.getText() + "','" + tf2.getText() + "','" +
     rs.getString(1) + "'," + tf3.getText() + "," + rs.getFloat(2) + ")";
       }//Endfor
       //加购物折扣设置
       sqlCode[type] = "insert into customertype(pk,id,c_type,dis_attr,discount,price) " +
     "values(" + pk + ",'" + tf1.getText() + "','" + tf2.getText() + "','购物折扣'," +
     tf3.getText() + ",0)";
    
    int rec = sunsql.runTransaction(sqlCode);   //将数据保存到数据库
    if(rec < sqlCode.length) {
     JOptionPane.showMessageDialog(null, "保存新的客户类型失败," +
     "请检查网络连接或联系管理员", "错误", JOptionPane.ERROR_MESSAGE);
    }else {
     String journal = "添加了新的客户类型-- [ " + tf2.getText() + " ]";
     Journal.writeJournalInfo(HotelFrame.userid, journal, Journal.TYPE_US);//记录操作日志
     tf1.setText("");  //保存成功,则将所有控件清零
     tf2.setText("");
     tf3.setText("10");
     tf1.requestFocus(true);
    }//Endif
      }
      catch (Exception ex) {
       System.out.println ("AddRoomType false");
      }//End try
  }//Endif
 }//End saveAddCustomerType()
 
 
 
 public void actionPerformed(ActionEvent ae) {
  Object o = ae.getSource();
  if(o == bt1) {     //确定
   saveAddCustomerType();  //保存数据
  }else if(o == bt2) {   //取消
   this.setVisible(false);
  }else if(o == tf1) {   //客户类型
   tf2.requestFocus(true);
  }else if(o == tf2) {   //客户类型
   tf3.requestFocus(true);
  }else if(o == tf3) {   //折扣
   saveAddCustomerType();  //保存数据
  }//Endif
 }
}

 

-----------------------------------------------------

 

//package com.sunshine.customer;

import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;


public class AddHuiYuan
extends JDialog
implements ActionListener,MouseListener {
 
 public static JTextField tf1,tf2,tf3,tf4,tf5;
 public static JComboBox cb1;
 private JTextField tf;
 private JButton bt1,bt2;
 private JPanel panelMain;
 
 public AddHuiYuan (JDialog dialog) {
  super(dialog, "添加会员",true);
  
  panelMain = new JPanel(new BorderLayout(0,0));
  buildPanel();
  addListener();
  this.setContentPane(panelMain);
  this.setPreferredSize (new Dimension (300,300));
  this.setMinimumSize (new Dimension (300,300));
  this.setResizable(false);  //不允许改变窗口大小
  pack();
  sunswing.setWindowCenter(this); //窗口屏幕居中
 }
 
 //加事件监听
 private void addListener(){
  bt1.addMouseListener(this);
  bt2.addMouseListener(this);
  bt1.addActionListener(this);
  bt2.addActionListener(this);
  tf1.addActionListener(this);
  tf3.addActionListener(this);
  tf4.addActionListener(this);
 }
 
 //构造面板
 private void buildPanel() {
  tf1 = new TJTextField(12);
  tf2 = new TJTextField(12);
  tf3 = new TJTextField(10);
  tf4 = new TJTextField(10);
  tf5 = new TJTextField(10);
  tf  = new JTextField("会员信息");
  tf.setHorizontalAlignment (JTextField.CENTER);
  tf.setBackground(new Color(199,183,143));
  tf.setBorder(new LineBorder(new Color(87,87,47)));
  tf.setEditable(false);
  
  cb1 = new JComboBox();
  cb1.addItem("男");
  cb1.addItem("女");
    
  bt1 = new TJButton ("pic/save.gif", "保存", "保存会员信息");
  bt2 = new TJButton ("pic/cancel.gif", "取消", "取消添加");
  
  JLabel lb1,lb2,lb3,lb5,lb6,lb7,lb8;
  lb1 = new JLabel("会员编号:");
  lb2 = new JLabel("会员姓名:");
  lb3 = new JLabel("会员性别:");
  lb5 = new JLabel("身份证号:");
  lb6 = new JLabel("联系电话:");
  lb7 = new JLabel("详细地址:");
  lb8 = new JLabel();
  
  JPanel ps,ps1,pc,pcc,pcc1,pcc2;
  ps = new JPanel();
  ps1 = new JPanel(new FlowLayout(FlowLayout.CENTER,35,0));
  pc  = new JPanel(new BorderLayout(0,5));
  pcc = new JPanel(new FlowLayout(FlowLayout.CENTER,10,0));
  pcc1 = new JPanel(new GridLayout(6,1,0,14));
  pcc2 = new JPanel(new GridLayout(6,1,0,5));
  
  pcc1.add(lb1);
  pcc1.add(lb2);
  pcc1.add(lb3);
  pcc1.add(lb5);
  pcc1.add(lb6);
  pcc1.add(lb7);
  
  pcc2.add(tf1);
  pcc2.add(tf2);
  pcc2.add(cb1);
  pcc2.add(tf3);
  pcc2.add(tf4);
  pcc2.add(tf5);
  
  pcc.add(pcc1);
  pcc.add(pcc2);
  
  pc.add("North",tf);
  pc.add(pcc);
  pc.setBorder(BorderFactory.createTitledBorder(""));
  
  ps1.add(bt1);
  ps1.add(bt2);
  ps.add(ps1);
  
  panelMain.add("North",lb8);
  panelMain.add(pc);
  panelMain.add("South",ps);
 }
 
 
 public void actionPerformed(ActionEvent ae) {
  Object o = ae.getSource();
  if(o==bt1) {//=====================================保存
   long pk = sunsql.getPrimaryKey();//得到主键
   String m_id,m_name,sex,zj_no,m_tel,address;
   m_id = tf1.getText();
   m_name = tf2.getText();
   sex = cb1.getSelectedItem()+"";
   zj_no = tf3.getText();
   m_tel = tf4.getText();
   address = tf5.getText();
   if(m_id.equals("")||m_name.equals("")||zj_no.equals("")||m_tel.equals("")||address.equals("")) {
    //若添加项有空值
    JOptionPane.showMessageDialog(null,"会员信息有空值,请重新输入!");
    return;
   }else {
    try {
     ResultSet rs = sunsql.executeQuery("select m_id from member where m_id = '"+m_id+"' and delmark = 0");
     if(rs.next()) {
      JOptionPane.showMessageDialog(null,"该会员编号已存在,请重新输入!");
      tf1.requestFocus();
      tf1.setText("");
     }else if(!suntools.isNum(tf4.getText())) {//判断电话是否由数字组成
      JOptionPane.showMessageDialog(null,"联系电话必须由数字组成,请重新输入!");
      tf4.setText("");
     }else {//将添加的信息插入会员表
      String sqlCode = "insert into member (pk,m_id,m_name,sex,zj_no,m_tel,address)" +
           "values ("+pk+",'"+m_id+"','"+m_name+"','"+sex+"','"+zj_no+"','"+m_tel+"','"+address+"')";
      sunsql.executeUpdate(sqlCode);
      this.setVisible(false);
     }
       }
       catch (Exception ex) {
       
   }
  }else if(o==bt2) {//===============================取消
   this.setVisible(false);
  }else if(o==tf1) {
   tf2.requestFocus();
  }else if(o==tf3) {
   tf4.requestFocus();
  }else if(o==tf4) {
   //判断必须全部为数字
   if(!suntools.isNum(tf4.getText())) {//判断电话是否由数字组成
    JOptionPane.showMessageDialog(null,"联系电话必须由数字组成,请重新输入!");
    tf4.setText("");
   }else {
    tf5.requestFocus();
   }
  }
 }
 
 
 public void mouseClicked (MouseEvent me) {
 }

 public void mousePressed (MouseEvent me) {
 }

 public void mouseReleased(MouseEvent me) {
 }

 public void mouseEntered (MouseEvent me) {  //鼠标移进提示
  Object o = me.getSource ();
  if(o == bt1) {
   HotelFrame.lbA.setText (HotelFrame.clue +
   "保存会员信息                           ");
  }else if(o == bt2) {
   HotelFrame.lbA.setText (HotelFrame.clue +
   "取消会员信息添加                         ");
  }
 }

 public void mouseExited (MouseEvent me) {
  HotelFrame.lbA.setText (HotelFrame.clue + "请选择功能项 ...                       ");
 }
 

 

----------------------------------------------------------------

 

 


//package com.sunshine.setup;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

 

public class AddRoomInfo
extends JDialog
implements ActionListener {
 
 public static JComboBox cb1;
 private JTextField tf1,tf2,tf3;
 private JButton bt1,bt2;
 private JPanel panelMain,pc,ps;
 
 
 public AddRoomInfo(JDialog dialog) {
  super(dialog,"房间信息",true);
  
  JLabel lb = new JLabel();
  panelMain = new JPanel(new BorderLayout(0,5));
  pc     = new JPanel(new FlowLayout(FlowLayout.CENTER,10,5));
  ps     = new JPanel(new FlowLayout(FlowLayout.CENTER,30,10));
  
  buildPC();   //制作房间信息面板
  buildPS();   //制作按键面板
  
  //加入组件
  panelMain.add("North", lb);
  panelMain.add("Center",pc);
  panelMain.add("South", ps);
  
  //加事件监听
  addListener();
  
  this.setContentPane(panelMain);
  this.setPreferredSize(new Dimension(300, 235));
  this.setMinimumSize(new Dimension(300, 235));
  this.setResizable(false);   //不允许改变窗口大小
  pack();
  sunswing.setWindowCenter(this);  //窗口屏幕居中
 }
 
 
 private void addListener() {
  bt1.addActionListener(this);
  bt2.addActionListener(this);
  tf1.addActionListener(this);
  tf2.addActionListener(this);
  tf3.addActionListener(this);
  cb1.addActionListener(this);
 }
 
 
 private void buildPC() {
  JPanel pc1,pc2;
  JLabel lb1,lb2,lb3,lb4;
  
  pc1 = new JPanel(new GridLayout(4, 1, 0, 16));
  pc2 = new JPanel(new GridLayout(4, 1, 0,  8));
  
  lb1 = new JLabel("房间类型:");
  lb2 = new JLabel("房间编号:");
  lb3 = new JLabel("所在区域:");
  lb4 = new JLabel("房间电话:");
  
  cb1 = new JComboBox();    //客房类型
  cb1.setMaximumRowCount(5);   //设置JComboBox的下拉框显示的行数
  String sql = "select r_type from roomtype where delmark = 0";
  sunsql.initJComboBox(cb1, sql);
  tf1 = new TJTextField(10);   //房间编号
  tf2 = new TJTextField(10);   //所在区域
  tf3 = new TJTextField(10);   //房间电话
  
  pc1.add(lb1);
  pc1.add(lb2);
  pc1.add(lb3);
  pc1.add(lb4);
  
  pc2.add(cb1);
  pc2.add(tf1);
  pc2.add(tf2);
  pc2.add(tf3);
  
  pc.add(pc1);
  pc.add(pc2);
 }
 
 
 private void buildPS() {
  bt1 = new TJButton ("pic/save.gif", " 保  存 ", "保存房间");
  bt2 = new TJButton ("pic/cancel.gif", " 取  消 ", "取消操作");
  ps.add(bt1);
  ps.add(bt2);
 }
 
 
 private boolean isValidity() {
  if(tf1.getText().length() == 0) {
   JOptionPane.showMessageDialog(null, " [ 房间编号 ] 不能为空", "提示",
   JOptionPane.INFORMATION_MESSAGE);
   tf1.requestFocus(true);
   return false;
  }else if(tf2.getText().length() == 0) {
   JOptionPane.showMessageDialog(null, "房间 [ 所在区域 ] 不能为空", "提示",
   JOptionPane.INFORMATION_MESSAGE);
   tf2.requestFocus(true);
   return false;
  }else if(!suntools.isNum(tf3.getText(), 4, 1000, 9999)) {
   JOptionPane.showMessageDialog(null, "[ 房间电话 ] 只能是数字,最长为4位," +
   "范围 1000-9999 之间", "提示", JOptionPane.INFORMATION_MESSAGE);
   tf3.requestFocus(true);
   return false;
  }//Endif
  return true;
 }
 
 
 private void saveRoomInfo() {
  if(isValidity()) {
   try {
    ResultSet rs = sunsql.executeQuery("select r_type_id from roominfo " +
    "where delmark=0 and id='" + tf1.getText() + "'");
    if(rs.next()) {   //检测新的房间编号是否存在
     JOptionPane.showMessageDialog(null, "新指定的房间编号 [ " + tf1.getText() +
     " ] 已存在,不能执行添加操作,请重新核对 ...", "提示", JOptionPane.INFORMATION_MESSAGE);
     tf1.requestFocus(true);
     return;
    }//Endif
    rs = sunsql.executeQuery("select id from roominfo " +
    "where delmark=0 and r_tel='" + tf3.getText() + "'");
    if(rs.next()) {   //检测新的房间电话号是否重复
     JOptionPane.showMessageDialog(null, "分配给新房间的电话号 [ " + tf3.getText() +
     " ] 已存在,不能执行添加操作,请重新核对 ...", "提示", JOptionPane.INFORMATION_MESSAGE);
     tf3.requestFocus(true);
     return;
    }//Endif
    rs = sunsql.executeQuery("select id from roomtype " +
    "where delmark=0 and r_type='" + cb1.getSelectedItem() + "'");
    rs.next();
    String r_ty_id = rs.getString(1);
    long pk = sunsql.getPrimaryKey();
    String sqlCode = "insert into roominfo(pk,id,r_type_id,state,location," +
         "r_tel) values(" + pk + ",'" + tf1.getText() + "','" +
         r_ty_id + "','可供','" + tf2.getText() + "','" + tf3.getText() + "')";
    
    int rec = sunsql.executeUpdate(sqlCode);   //将数据保存到数据库
    if(rec == 0) {
     JOptionPane.showMessageDialog(null, "保存新的房间基本信息失败," +
     "请检查网络连接或联系管理员", "错误", JOptionPane.ERROR_MESSAGE);
    }else {
     String journal = "添加了新的" + cb1.getSelectedItem() + "-- 房间号:[ " + tf1.getText() + " ]";
     Journal.writeJournalInfo(HotelFrame.userid, journal, Journal.TYPE_RI);//记录操作日志
     cb1.setSelectedIndex(0);  //保存成功,则将所有控件清零
     tf1.setText("");
     tf2.setText("");
     tf3.setText("");
     tf1.requestFocus(true);
    }//Endif
      }
      catch (Exception ex) {
       ex.printStackTrace();
       System.out.println ("AddRoomInfo false");
      }//End try
  }//Endif
   
 }
 
 
 
 public void actionPerformed(ActionEvent ae) {
  Object o = ae.getSource();
  if(o == bt1) {
   saveRoomInfo();       //保存
  }else if(o == bt2) {
   this.setVisible(false);     //取消
  }else if(o == cb1) {
   tf1.requestFocus(true);     //房间类型
  }else if(o == tf1) {
   tf2.requestFocus(true);     //房间号码
  }else if(o == tf2) {
   tf3.requestFocus(true);     //所在区域
  }else if(o == tf3) {      //房间电话
   saveRoomInfo();
  }//Endif
 }
}

 

 

--------------------------------------------------------------------------

 

//后续代码日后自会公布。July、0616。

已投稿到:
郑重声明:资讯 【阳光酒店管理系统 完整源码公布 [清华IT](1)_叛逆年少_新浪博客】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——