📄 freeroomquery.java~18~
字号:
package RoomManagement;
import java.awt.BorderLayout;
import hotelinformationmanagesystem.*;
import javax.swing.JFrame;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTable;
import ShowTable.TableExample;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;
/**
* <p>Title: 酒店信息管理系统</p>
*
* <p>Description: HotelInformationManageSystem</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: JSP</p>
*
* @author 江世澎
* @version 1.0
*/
public class FreeRoomQuery extends JFrame {
JTable jTable1;
TableExample table = new TableExample();
XYLayout xYLayout1 = new XYLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JPanel jPanel1 = new JPanel();
JRadioButton jRadioButton1 = new JRadioButton();
JComboBox jComboBox1 = new JComboBox();
XYLayout xYLayout2 = new XYLayout();
JPanel jPanel2 = new JPanel();
JRadioButton jRadioButton2 = new JRadioButton();
JTextField jTextField1 = new JTextField();
XYLayout xYLayout3 = new XYLayout();
ButtonGroup buttonGroup1 = new ButtonGroup();
JPanel jPanel3 = new JPanel();
JRadioButton jRadioButton3 = new JRadioButton();
JTextField jTextField2 = new JTextField();
XYLayout xYLayout4 = new XYLayout();
public FreeRoomQuery() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
jTable1 = table.createTable();
getContentPane().setLayout(xYLayout1);
this.setSize(450, 280);
SetFormCenter wcenter = new SetFormCenter();
wcenter.setcenter(this);
this.setResizable(false);
this.setTitle("空闲客房住信息查询");
jButton1.addActionListener(new FreeRoomQuery_jButton1_actionAdapter(this));
jButton2.setFont(new java.awt.Font("宋体", Font.BOLD, 25));
jButton2.setText("退出");
jButton2.addActionListener(new FreeRoomQuery_jButton2_actionAdapter(this));
jButton1.setFont(new java.awt.Font("宋体", Font.BOLD, 25));
xYLayout1.setWidth(446);
xYLayout1.setHeight(248);
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setLayout(xYLayout2);
jRadioButton1.setText("按客房类型查询");
jRadioButton1.addActionListener(new
FreeRoomQuery_jRadioButton1_actionAdapter(this));
jComboBox1.setEnabled(false);
jPanel2.setBorder(BorderFactory.createEtchedBorder());
jPanel2.setLayout(xYLayout3);
jRadioButton2.setText("按客房ID查询");
jRadioButton2.addActionListener(new
FreeRoomQuery_jRadioButton2_actionAdapter(this));
jTextField1.setEnabled(false);
jPanel3.setBorder(BorderFactory.createEtchedBorder());
jPanel3.setLayout(xYLayout4);
jRadioButton3.setText("按客房床位数查询");
jRadioButton3.addActionListener(new
FreeRoomQuery_jRadioButton3_actionAdapter(this));
jTextField2.setEnabled(false);
jScrollPane1.getViewport().add(jTable1);
this.getContentPane().add(jPanel1, new XYConstraints(5, 174, 217, 34));
jPanel1.add(jRadioButton1, new XYConstraints(5, 3, -1, -1));
jPanel1.add(jComboBox1, new XYConstraints(124, 3, 84, -1));
jPanel2.add(jRadioButton2, new XYConstraints(5, 5, -1, -1));
jPanel2.add(jTextField1, new XYConstraints(125, 3, 84, 24));
this.getContentPane().add(jPanel2, new XYConstraints(5, 210, 217, 35));
jPanel3.add(jRadioButton3, new XYConstraints(2, 3, -1, -1));
jPanel3.add(jTextField2, new XYConstraints(132, 3, 79, 23));
this.getContentPane().add(jScrollPane1,
new XYConstraints(5, 3, 437, 166));
this.getContentPane().add(jPanel3, new XYConstraints(225, 174, 217, 34));
jButton1.setText("查询");
table.fetch("select distinct HIMS_RoomInfo.RoomID as 客房ID,Class as 客房类型,RoomArea as 客房面积,BedNo as 床位数,StandardPri as 标准价,RebatePri as 折扣价,place as 客房位置,RoomIntro as 客房简介,Remark as 备注 from HIMS_RoomInfo,HIMS_RoomState WHERE HIMS_RoomInfo.RoomID = HIMS_RoomState.RoomID AND HIMS_RoomState.OnUser in ('2' , '4' , '6')");
buttonGroup1.add(jRadioButton1); //按客房类型查询
buttonGroup1.add(jRadioButton2); //按客房ID查询
buttonGroup1.add(jRadioButton3); //按客房床位数查询
this.getContentPane().add(jButton1, new XYConstraints(227, 210, 105, 35));
this.getContentPane().add(jButton2, new XYConstraints(346, 210, 96, 35));
jComboBox1.setEnabled(false); //按客房类型
jComboBox1.addItem(" ");
jComboBox1.addItem("标准单人间");
jComboBox1.addItem("标准双人间");
jComboBox1.addItem("标准四人间");
jComboBox1.addItem("家庭间");
jComboBox1.addItem("商务间");
jComboBox1.addItem("经济间");
jComboBox1.addItem("豪华套房");
jTextField1.setEnabled(false); //按客房ID
jTextField2.setEnabled(false); //按床位
}
public void jButton1_actionPerformed(ActionEvent e) { //查询
if (buttonGroup1.getSelection() == jRadioButton1.getModel()) { //按客房类型查询
String strClass = null;
try {
strClass = jComboBox1.getSelectedItem().toString();
} catch (Exception ex) {
strClass = "";
}
table.fetch("Select HIMS_RoomInfo.RoomID as 客房ID,Class as 客房类型,RoomArea as 房间面积,BedNo as 床位数,StandardPri as 标准价,RebatePri as 折扣价,Place as 客房位置,RoomIntro as 客房信息,Remark as 备注 From HIMS_RoomState, HIMS_RoomInfo where HIMS_RoomState.RoomID = HIMS_RoomInfo.RoomID AND HIMS_RoomInfo.Class = '" +
strClass +
"' AND HIMS_RoomState.OnUser in ('2' , '4' , '6');");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(null,
"您所要查找的客房都已用!!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
}
return;
}
if (buttonGroup1.getSelection() == jRadioButton2.getModel()) { //按客房ID查询
String strRoomID = jTextField1.getText();
table.fetch("Select HIMS_RoomInfo.RoomID as 客房ID,Class as 客房类型,RoomArea as 房间面积,BedNo as 床位数,StandardPri as 标准价,RebatePri as 折扣价,Place as 客房位置,RoomIntro as 客房信息,Remark as 备注 From HIMS_RoomState, HIMS_RoomInfo where HIMS_RoomState.RoomID = HIMS_RoomInfo.RoomID AND HIMS_RoomInfo.RoomID like '%" +
strRoomID +
"%' AND HIMS_RoomState.OnUser in ('2' , '4' , '6'); ");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(null,
"您所要查找的客房都已用或者您输入的信息错误!!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
}
return;
}
if (buttonGroup1.getSelection() == jRadioButton3.getModel()) { //按客房床位数查询
String strBedNo = jTextField2.getText();
table.fetch("Select HIMS_RoomInfo.RoomID as 客房ID,Class as 客房类型,RoomArea as 房间面积,BedNo as 床位数,StandardPri as 标准价,RebatePri as 折扣价,Place as 客房位置,RoomIntro as 客房信息,Remark as 备注 From HIMS_RoomState, HIMS_RoomInfo where HIMS_RoomState.RoomID = HIMS_RoomInfo.RoomID AND HIMS_RoomInfo.BedNo = '" +
strBedNo +
"' AND HIMS_RoomState.OnUser in ('2' , '4' , '6'); ");
if (jTable1.getRowCount() == 0) {
JOptionPane.showMessageDialog(null,
"您所要查找的客房都已用或者您输入的信息错误!!",
"酒店信息管理系统警告",
JOptionPane.WARNING_MESSAGE);
}
return;
}
}
public void jButton2_actionPerformed(ActionEvent e) {
this.setVisible(false);
}
public void jRadioButton1_actionPerformed(ActionEvent e) { //按客房类型查询
jTextField1.setText(""); //ID
jTextField1.setEnabled(false);
jTextField2.setText("");
jTextField2.setEnabled(false); //Bed
jComboBox1.removeAllItems();
jComboBox1.setEnabled(true); //class
jComboBox1.addItem(" ");
jComboBox1.addItem("标准单人间");
jComboBox1.addItem("标准双人间");
jComboBox1.addItem("标准四人间");
jComboBox1.addItem("家庭间");
jComboBox1.addItem("商务间");
jComboBox1.addItem("经济间");
jComboBox1.addItem("豪华套房");
}
public void jRadioButton2_actionPerformed(ActionEvent e) {
jTextField1.setText(""); //ID
jTextField1.setEnabled(true);
jTextField2.setText("");
jTextField2.setEnabled(false); //Bed
jComboBox1.removeAllItems();
jComboBox1.setEnabled(false); //class
}
public void jRadioButton3_actionPerformed(ActionEvent e) {
jTextField1.setText(""); //ID
jTextField1.setEnabled(false);
jTextField2.setText("");
jTextField2.setEnabled(true); //Bed
jComboBox1.removeAllItems();
jComboBox1.setEnabled(false); //class
}
}
class FreeRoomQuery_jRadioButton3_actionAdapter implements ActionListener {
private FreeRoomQuery adaptee;
FreeRoomQuery_jRadioButton3_actionAdapter(FreeRoomQuery adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jRadioButton3_actionPerformed(e);
}
}
class FreeRoomQuery_jRadioButton2_actionAdapter implements ActionListener {
private FreeRoomQuery adaptee;
FreeRoomQuery_jRadioButton2_actionAdapter(FreeRoomQuery adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jRadioButton2_actionPerformed(e);
}
}
class FreeRoomQuery_jRadioButton1_actionAdapter implements ActionListener {
private FreeRoomQuery adaptee;
FreeRoomQuery_jRadioButton1_actionAdapter(FreeRoomQuery adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jRadioButton1_actionPerformed(e);
}
}
class FreeRoomQuery_jButton2_actionAdapter implements ActionListener {
private FreeRoomQuery adaptee;
FreeRoomQuery_jButton2_actionAdapter(FreeRoomQuery adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class FreeRoomQuery_jButton1_actionAdapter implements ActionListener {
private FreeRoomQuery adaptee;
FreeRoomQuery_jButton1_actionAdapter(FreeRoomQuery adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -