📄 guestquery.java
字号:
package GuestManagement;
import java.awt.*;
import ShowTable.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import hotelinformationmanagesystem.SetFormCenter;
import javax.swing.BorderFactory;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import hotelinformationmanagesystem.JudgeValidity;
import java.util.Calendar;
import java.text.SimpleDateFormat;
/**
* <p>Title: 酒店信息管理系统</p>
*
* <p>Description: The Management Information System of Hotel</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: JSP</p>
*
* @author 江世澎
* @version 1.0
*/
public class GuestQuery extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JTable jTable1;
TableExample table = new TableExample();
JScrollPane jScrollPane1 = new JScrollPane();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JPanel jPGuestStateShow = new JPanel();
XYLayout xYLayout2 = new XYLayout();
JRadioButton jRBGuestDestine = new JRadioButton();
JRadioButton jRBGuestRegist = new JRadioButton();
JRadioButton jRBGroupDestine = new JRadioButton();
JRadioButton jRBGroupRegist = new JRadioButton();
JPanel jPTimeShow = new JPanel();
XYLayout xYLayout3 = new XYLayout();
JRadioButton jRBChickOnTime = new JRadioButton();
JTextField jTFChickOnTime = new JTextField();
JRadioButton jRBWillGoHereTime = new JRadioButton();
JTextField jTFWillGoHereTime = new JTextField();
JPanel jPGuestInfo = new JPanel();
XYLayout xYLayout4 = new XYLayout();
JRadioButton jRBName = new JRadioButton();
JTextField jTFName = new JTextField();
JRadioButton jRBCompany = new JRadioButton();
JTextField jTFCompany = new JTextField();
ButtonGroup buttonGroup1 = new ButtonGroup();
ButtonGroup buttonGroup2 = new ButtonGroup();
hotelinformationmanagesystem.JudgeValidity judgeval = new JudgeValidity();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout5 = new XYLayout();
JRadioButton jRBTodayArrive = new JRadioButton();
JRadioButton jRBTodaySettleAccounts = new JRadioButton();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String strStartDate = format.format(date); //得到系统时间
JPanel jPRoomGuestQuery = new JPanel();
XYLayout xYLayout6 = new XYLayout();
JRadioButton jRBRoomGuestQuery = new JRadioButton();
JTextField jTFRoomGuestQuery = new JTextField();
public GuestQuery() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(xYLayout1);
jTable1 = table.createTable();
this.setResizable(false);
this.setTitle("客人信息查询");
this.setSize(453, 365); //宽,高
SetFormCenter wcenter = new SetFormCenter();
wcenter.setcenter(this);
xYLayout1.setWidth(445);
xYLayout1.setHeight(332);
jButton1.setText("查找");
jButton1.addActionListener(new GuestQuery_jButton1_actionAdapter(this));
jButton2.setText("退出");
jButton2.addActionListener(new GuestQuery_jButton2_actionAdapter(this));
jRBGuestDestine.setEnabled(false);
jRBGuestRegist.setEnabled(false);
jRBGroupDestine.setEnabled(false);
jRBGroupRegist.setEnabled(false);
jPGuestStateShow.setBorder(BorderFactory.createEtchedBorder());
jPGuestStateShow.setLayout(xYLayout2);
jRBGuestDestine.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBGuestDestine.setText("客户预定");
jRBGuestRegist.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBGuestRegist.setText("客户已住");
jRBGroupDestine.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBGroupDestine.setText("团体预定");
jRBGroupRegist.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBGroupRegist.setText("团体已住");
jPTimeShow.setBorder(BorderFactory.createEtchedBorder());
jPTimeShow.setLayout(xYLayout3);
jRBChickOnTime.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBChickOnTime.setText("入住时间");
jRBChickOnTime.addActionListener(new
GuestQuery_jRadioButton6_actionAdapter(this));
jRBWillGoHereTime.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBWillGoHereTime.setText("抵店日期");
jRBWillGoHereTime.addActionListener(new
GuestQuery_jRadioButton7_actionAdapter(this));
jPGuestInfo.setBorder(BorderFactory.createEtchedBorder());
jPGuestInfo.setLayout(xYLayout4);
jRBName.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBName.setText("姓名");
jRBName.addActionListener(new
GuestQuery_jRadioButton8_actionAdapter(this));
jRBCompany.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBCompany.setText("单位");
jRBCompany.addActionListener(new
GuestQuery_jRadioButton9_actionAdapter(this));
jTFChickOnTime.setEnabled(false);
jTFWillGoHereTime.setEnabled(false);
jTFName.setEnabled(false);
jTFCompany.setEnabled(false);
jTable1.addMouseListener(new GuestQuery_jTable1_mouseAdapter(this));
jPanel1.setLayout(xYLayout5);
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jRBTodayArrive.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBTodayArrive.setText("今日要入住的客人信息");
jRBTodayArrive.addActionListener(new
GuestQuery_jRBTodayArrive_actionAdapter(this));
jRBTodaySettleAccounts.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBTodaySettleAccounts.setText("今日要结账的客人信息");
jRBTodaySettleAccounts.addActionListener(new
GuestQuery_jRBTodaySettleAccounts_actionAdapter(this));
jPRoomGuestQuery.setBorder(BorderFactory.createEtchedBorder());
jPRoomGuestQuery.setLayout(xYLayout6);
jRBRoomGuestQuery.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jRBRoomGuestQuery.setText("根据客房查找客人信息");
jRBRoomGuestQuery.addActionListener(new
GuestQuery_jRBRoomGuestQuery_actionAdapter(this));
jTFRoomGuestQuery.setEnabled(false);
jScrollPane1.getViewport().add(jTable1);
jPGuestStateShow.add(jRBGuestDestine, new XYConstraints(6, 6, -1, -1));
jPGuestStateShow.add(jRBGroupRegist, new XYConstraints(6, 116, -1, -1));
jPGuestStateShow.add(jRBGuestRegist, new XYConstraints(6, 46, -1, -1));
this.getContentPane().add(jPGuestStateShow,
new XYConstraints(1, 1, 89, 149));
jPTimeShow.add(jRBChickOnTime, new XYConstraints(6, 3, -1, -1));
jPTimeShow.add(jTFChickOnTime, new XYConstraints(93, 3, 115, 25));
jPTimeShow.add(jRBWillGoHereTime, new XYConstraints(6, 39, -1, -1));
jPTimeShow.add(jTFWillGoHereTime, new XYConstraints(93, 38, 115, 25));
this.getContentPane().add(jPGuestInfo,
new XYConstraints(1, 152, 221, 69));
jPGuestInfo.add(jRBName, new XYConstraints(10, 3, -1, -1));
jPGuestInfo.add(jTFName, new XYConstraints(74, 3, 140, 25));
jPGuestInfo.add(jRBCompany, new XYConstraints(10, 39, -1, -1));
jPGuestInfo.add(jTFCompany, new XYConstraints(74, 38, 140, 25));
jPGuestStateShow.add(jRBGroupDestine, new XYConstraints(6, 81, -1, -1));
this.getContentPane().add(jScrollPane1,
new XYConstraints(91, 1, 350, 149));
this.getContentPane().add(jPTimeShow,
new XYConstraints(222, 152, 219, 69));
buttonGroup1.add(jRBChickOnTime); //入住时间
buttonGroup1.add(jRBWillGoHereTime); //抵店日期
buttonGroup1.add(jRBName); //姓名
buttonGroup1.add(jRBCompany); //单位
buttonGroup1.add(jRBTodayArrive); //今日要入住的客人信息
buttonGroup1.add(jRBTodaySettleAccounts); //今日要结账的客人信息
buttonGroup1.add(jRBRoomGuestQuery); //根据客人入住房间查找
buttonGroup2.add(jRBGroupDestine);
buttonGroup2.add(jRBGroupRegist);
buttonGroup2.add(jRBGuestDestine);
buttonGroup2.add(jRBGuestRegist);
jPanel1.add(jRBTodayArrive, new XYConstraints(10, 2, -1, -1));
jPanel1.add(jRBTodaySettleAccounts, new XYConstraints(227, 0, -1, -1));
this.getContentPane().add(jButton1, new XYConstraints(306, 295, 63, 30));
this.getContentPane().add(jButton2, new XYConstraints(378, 295, 63, 30));
jPRoomGuestQuery.add(jRBRoomGuestQuery, new XYConstraints(10, 4, -1, -1));
this.getContentPane().add(jPanel1, new XYConstraints(1, 257, 440, 33));
this.getContentPane().add(jPRoomGuestQuery,
new XYConstraints(1, 222, 440, 33));
jPRoomGuestQuery.add(jTFRoomGuestQuery,
new XYConstraints(179, 2, 136, 25));
}
public void jButton2_actionPerformed(ActionEvent e) { //退出
this.setVisible(false);
}
public void jButton1_actionPerformed(ActionEvent e) { //查找
String strRegiType = "";
String strCheckInType = "";
if (buttonGroup1.getSelection() == jRBChickOnTime.getModel()) { //入住时间
String strLiveTime = jTFChickOnTime.getText();
if (judgeval.DateValidity(strLiveTime) != 2) {
JOptionPane.showMessageDialog(null,
"抵店日期出错,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFChickOnTime.setText("");
return;
}
table.fetch("Select RegisterID as 客人登记号, Name as 姓名, Company as 单位, County as 国家,RegPhone as 联系电话 ,PaperType as 证件类型, PaperNo as 证件号码,RegiType,CheckInType,Deposit as 押金,WillCheckDate as 抵店日期, CheckInDate as 入住日期, CheckInDay as 入住天数,QuitDate as 离店日期,PersonMon as 人数,RoomMon as 订房数,Reason as 入住原因 , RoomName01 as 房间号1,RoomName02 as 房间号2,RoomName03 as 房间号3 ,RoomName04 as 房间号4 ,RoomName05 as 房间号5,RoomName06 as 房间号6,RoomName07 as 房间号7,RoomName08 as 房间号8 from HIMS_Register,HIMS_Register_CheckInRoom Where HIMS_Register.RegisterID = HIMS_Register_CheckInRoom.RegRoomID AND HIMS_Register.CheckInDate = '" +
strLiveTime + "' AND CheckInType != 'Q'");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "没有找到你所要查的信息!",
"酒店信息管理系统提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
return;
}
if (buttonGroup1.getSelection() == jRBWillGoHereTime.getModel()) { //抵店日期
String strWillGo = jTFWillGoHereTime.getText();
if (judgeval.DateValidity(strWillGo) != 2) {
JOptionPane.showMessageDialog(null,
"抵店日期出错,请重新输入!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
jTFWillGoHereTime.setText("");
return;
}
table.fetch("Select RegisterID as 客人登记号, Name as 姓名, Company as 单位, County as 国家,RegPhone as 联系电话 ,PaperType as 证件类型, PaperNo as 证件号码,RegiType,CheckInType,Deposit as 押金,WillCheckDate as 抵店日期, CheckInDate as 入住日期, CheckInDay as 入住天数,QuitDate as 离店日期,PersonMon as 人数,RoomMon as 订房数,Reason as 入住原因 , RoomName01 as 房间号1,RoomName02 as 房间号2,RoomName03 as 房间号3 ,RoomName04 as 房间号4 ,RoomName05 as 房间号5,RoomName06 as 房间号6,RoomName07 as 房间号7,RoomName08 as 房间号8 from HIMS_Register,HIMS_Register_CheckInRoom Where HIMS_Register.RegisterID = HIMS_Register_CheckInRoom.RegRoomID AND HIMS_Register.CheckInDate = '" +
strWillGo + "' AND CheckInType != 'Q'");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "没有找到你所要查的信息!",
"酒店信息管理系统提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
return;
}
if (buttonGroup1.getSelection() == jRBName.getModel()) { //姓名
String strName = jTFName.getText();
table.fetch("Select RegisterID as 客人登记号, Name as 姓名, Company as 单位, County as 国家,RegPhone as 联系电话 ,PaperType as 证件类型, PaperNo as 证件号码,RegiType,CheckInType,Deposit as 押金,WillCheckDate as 抵店日期, CheckInDate as 入住日期, CheckInDay as 入住天数,QuitDate as 离店日期,PersonMon as 人数,RoomMon as 订房数,Reason as 入住原因 , RoomName01 as 房间号1,RoomName02 as 房间号2,RoomName03 as 房间号3 ,RoomName04 as 房间号4 ,RoomName05 as 房间号5,RoomName06 as 房间号6,RoomName07 as 房间号7,RoomName08 as 房间号8 from HIMS_Register,HIMS_Register_CheckInRoom Where HIMS_Register.RegisterID = HIMS_Register_CheckInRoom.RegRoomID AND HIMS_Register.Name like '%" +
strName +
"%' AND HIMS_Register.Company = '' AND CheckInType != 'Q'");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "没有找到你所要查的信息!",
"酒店信息管理系统提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
return;
}
if (buttonGroup1.getSelection() == jRBCompany.getModel()) { //单位
String strCompany = jTFCompany.getText();
table.fetch("Select RegisterID as 客人登记号, Name as 姓名, Company as 单位, County as 国家,RegPhone as 联系电话 ,PaperType as 证件类型, PaperNo as 证件号码,RegiType,CheckInType,Deposit as 押金,WillCheckDate as 抵店日期, CheckInDate as 入住日期, CheckInDay as 入住天数,QuitDate as 离店日期,PersonMon as 人数,RoomMon as 订房数,Reason as 入住原因 , RoomName01 as 房间号1,RoomName02 as 房间号2,RoomName03 as 房间号3 ,RoomName04 as 房间号4 ,RoomName05 as 房间号5,RoomName06 as 房间号6,RoomName07 as 房间号7,RoomName08 as 房间号8 from HIMS_Register,HIMS_Register_CheckInRoom Where HIMS_Register.RegisterID = HIMS_Register_CheckInRoom.RegRoomID AND HIMS_Register.Company like '%" +
strCompany +
"%' AND HIMS_Register.Name = '' AND CheckInType != 'Q'");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "没有找到你所要查的信息!",
"酒店信息管理系统提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
return;
}
if (buttonGroup1.getSelection() == jRBTodayArrive.getModel()) { //今日要入住的客人信息
table.fetch("Select RegisterID as 客人登记号, Name as 姓名, Company as 单位, County as 国家,RegPhone as 联系电话 ,PaperType as 证件类型, PaperNo as 证件号码,RegiType,CheckInType,Deposit as 押金,WillCheckDate as 抵店日期, CheckInDate as 入住日期, CheckInDay as 入住天数,QuitDate as 离店日期,PersonMon as 人数,RoomMon as 订房数,Reason as 入住原因 , RoomName01 as 房间号1,RoomName02 as 房间号2,RoomName03 as 房间号3 ,RoomName04 as 房间号4 ,RoomName05 as 房间号5,RoomName06 as 房间号6,RoomName07 as 房间号7,RoomName08 as 房间号8 from HIMS_Register,HIMS_Register_CheckInRoom Where HIMS_Register.RegisterID = HIMS_Register_CheckInRoom.RegRoomID AND HIMS_Register.WillCheckDate = '" +
strStartDate + "' AND CheckInType = 'F' ");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(this, "预约的客人今日没有到到达的!",
"酒店信息管理系统提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -