📄 registerframe.java
字号:
buttonGroup.add(rdoFemale);
RoomPanelNoInit();
showTime();
}
JLabel lblTitle = new JLabel();
JPanel registPanel = new JPanel();
JLabel lblName = new JLabel();
JTextField txtName = new JTextField();
JLabel lblSex = new JLabel();
JPanel roomPanel = new JPanel();
JTextField txtIDNo = new JTextField();
JLabel lblIDType = new JLabel();
JRadioButton rdoMale = new JRadioButton();
JRadioButton rdoFemale = new JRadioButton();
JLabel lblIDNo = new JLabel();
JComboBox cboIDType = new JComboBox();
JTextField txtReason = new JTextField();
JLabel lblReason = new JLabel();
JPanel sexPanel = new JPanel();
GridLayout gridLayout1 = new GridLayout();
JTextField txtAccountNo = new JTextField();
JLabel lblTime = new JLabel();
JTextField txtOperater = new JTextField();
JLabel lblAccuont = new JLabel();
JLabel lblOperater = new JLabel();
JComboBox cboRoomType = new JComboBox();
JTextField txtCheckIn = new JTextField();
JLabel lblRoomNo = new JLabel();
JLabel lblRoomType = new JLabel();
JLabel lblCheckInDate = new JLabel();
JLabel lblStanPri = new JLabel();
JTextField txtCheckOut = new JTextField();
JTextField txtStanPri = new JTextField();
JLabel lblCheckOutDate = new JLabel();
JLabel lbldebatePri = new JLabel();
JTextField txtDebatePri = new JTextField();
ButtonGroup buttonGroup = new ButtonGroup();
JComboBox cboDepate = new JComboBox();
JLabel lblDebate = new JLabel();
TitledBorder titledBorder1 = new TitledBorder("");
TitledBorder titledBorder2 = new TitledBorder("");
JTextField txtTotal = new JTextField();
JLabel lblTotal = new JLabel();
JLabel lnlDeposit = new JLabel();
JTextField txtDeposit = new JTextField();
JButton btnConfri = new JButton();
JButton btnBack = new JButton();
JLabel jLabel1 = new JLabel();
static Timer timer;
int accountNo = 100000;
boolean tip = false;
private String managerName = LoginFrame.manager;
DBOperatorBean dbo = new DBOperatorBean();
ResultSet rs = null;
JComboBox cboRoomNo = new JComboBox();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JButton btnComput = new JButton();
public void btnConfri_actionPerformed(ActionEvent e) {
if(this.txtIDNo.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"证件号不能为空!\n请输入客人完整信息!","提示",JOptionPane.INFORMATION_MESSAGE);
return;
}
if(this.txtName.getText().equals(""))
{
JOptionPane.showMessageDialog(this,"客人姓名不能为空!\n请输入客人完整信息!","提示",JOptionPane.INFORMATION_MESSAGE);
return;
}
//客人帐号自动增加
++accountNo;
//构建客人registerBeans对象
GuestRegistBean guest = new GuestRegistBean();
guest.setCheckInDate(this.txtCheckIn.getText()); //抵店日期
guest.setCheckOutDate(this.txtCheckOut.getText()); //离店日期
String depate = this.txtDeposit.getText(); //判断押金是否为数字格式
for (int i = 0; i < depate.trim().length(); i++) {
if (!Character.isDigit(depate.charAt(i))) {
JOptionPane.showMessageDialog(this, "押金输入格式不正确!请输入数字格式!", "提示",
JOptionPane.INFORMATION_MESSAGE);
return;
}
}
guest.setDeposit(Integer.parseInt(txtDeposit.getText())); //押金
guest.setIdYype(this.cboIDType.getSelectedItem().toString()); //证件类型
guest.setIdNo(this.txtIDNo.getText()); //证件号
guest.setName(this.txtName.getText()); //客人姓名
guest.setOperator(LoginFrame.manager); //当前操作员
guest.setDebatePri(Integer.parseInt(this.txtDebatePri.getText())); //打折价
guest.setReson(this.txtReason.getText()); //入住理由
guest.setRoomNo(this.cboRoomNo.getSelectedItem().toString()); //用户选择房间号
if (rdoMale.isSelected()) { //客人性别
guest.setSex("男");
} else {
guest.setSex("女");
}
guest.setRoomType(this.cboRoomType.getSelectedItem().toString()); //客人选择的房间类型
guest.setStandrdPri(Integer.parseInt(txtStanPri.getText())); //该房间的标准价
guest.setTotal(Integer.parseInt(this.txtTotal.getText())); //总共的费用
guest.setAccontNo(Integer.parseInt(txtAccountNo.getText())); //客人帐单号
//构建客人入住确认信息
String info = "确认入住登记信息如下:\n";
info += "姓名:"+guest.getName()+"\n性别:"+guest.getSex()+"\n";
info += "证件类型:"+guest.getIdType()+"\n证件号:"+guest.getIdNo()+"\n";
info += "抵店日期:"+guest.getCheckInDate()+"\n离店日期:"+guest.getCheckOutDate()+"\n";
info += "房间类型:"+guest.getRoomType()+"\n房间编号:"+guest.getRoomNo()+"\n";
info += "折扣价:"+guest.getDebatePri()+"\n押金:"+guest.getDeposit()+"\n";
info += "帐单号:"+guest.getAccontNo()+"\n总费用:"+guest.getTotal()+"\n";
Object[] option = {"是","否"};
int ok=JOptionPane.showOptionDialog(this,info,"信息确认",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,option,"是");
if(ok==1)
{
return;
}
//向数据库里插入客人的数据信息
String insert = "";
insert = "insert into register values('" + guest.getRoomNo() + "','" +
guest.getRoomType()
+ "','" + guest.getCheckInDate() + "','" +
guest.getCheckOutDate() + "','" + guest.getStandrdPri() +
"','" + guest.getDebatePri()
+ "','" + guest.getDeposit() + "','" + guest.getTotal() +
"','" + guest.getName() + "','" + guest.getSex() + "','" +
guest.getIdType()
+ "','" + guest.getIdNo() + "','" + guest.getReson() + "'," +
guest.getAccontNo() + ",'" + 0 + "')";
//向客人帐单表中插入数据
int Reckoning = guest.getTotal() - guest.getDeposit();
String update1 = "insert into account values ( +" + guest.getAccontNo() +
",'" + guest.getName() + "','" + guest.getRoomNo() +
"','"
+ guest.getRoomType() + "','" + guest.getStandrdPri() +
"','" + guest.getDebatePri() + "','" +
guest.getDeposit() + "','" + Reckoning + "',0,'" +
guest.getOperator() + "')";
//改变课房状态!
String update2 = "update roomStatus set onuse = 1 where roomNo='" +
guest.getRoomNo() + "'";
if (dbo.updateNoReturn(insert)&&dbo.updateNoReturn(update1)&&dbo.updateNoReturn(update2)) {
JOptionPane.showMessageDialog(this, "入住登记成功!!");
tip = true;
}
//刷新页面
RegisterFrame re = new RegisterFrame();
re.setBounds(200,200,700,550);
re.show();
this.dispose();
// if (dbo.updateNoReturn(update1)) {
// JOptionPane.showMessageDialog(this, "帐单表更新成功!!");
// }
// if (dbo.updateNoReturn(update2)) {
// JOptionPane.showMessageDialog(this, "客房状态更新成功!!");
// }
}
//返回按钮事件
public void btnBack_actionPerformed(ActionEvent e) {
this.dispose();
}
//当客房类型改变时,相应的该类型的可用房间的房间号显示在cboRoomNo下拉框中;
public void cboRoomType_itemStateChanged(ItemEvent e) {
//清除列表项中的数据
cboRoomNo.removeAllItems();
String roomtype = this.cboRoomType.getSelectedItem().toString();
String sql1 = "select roomNo from roomStatus where class = '" +
roomtype + "' and onuse = '0' ";
try {
rs = dbo.returnQuery(sql1);
while (rs.next()) {
//重新添加列表项
cboRoomNo.addItem(rs.getString(1));
}
// rs.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
//再次从房间号下拉框得到用户选择的房间号;得到用户选择的房间号;
String romNo = this.cboRoomNo.getSelectedItem().toString();
String sql2 = " select standardpri from roomStatus where roomNo = '" +
romNo + "'";
try {
rs = dbo.returnQuery(sql2);
if (rs.next()) {
//重新设置折扣价文本框的值
int pri = rs.getInt(1);
this.txtStanPri.setText("" + pri);
this.txtDebatePri.setText("" + pri);
}
} catch (SQLException ex1) {
ex1.printStackTrace();
}
cboDepate.setSelectedItem("全价");
}
//初始化客房状态面板
public void RoomPanelNoInit() {
//初始化房间号列表框
String roomtype = this.cboRoomType.getSelectedItem().toString();
String sql = "select roomNo from roomStatus where class = '" + roomtype +
"' and onuse = '0'";
try {
rs = dbo.returnQuery(sql);
while (rs.next()) {
//添加列表项
cboRoomNo.addItem(rs.getString(1));
}
} catch (SQLException ex) {
ex.printStackTrace();
}
//从房间号下拉框得到用户选择的房间号;
String romNo = this.cboRoomNo.getSelectedItem().toString();
String sql2 = " select standardpri from roomStatus where roomNo = '" +
romNo + "'";
try {
rs = dbo.returnQuery(sql2);
if (rs.next()) {
//设置折扣价文本框的值
int pri = rs.getInt(1);
this.txtStanPri.setText("" + pri);
this.txtDebatePri.setText("" + pri);
}
} catch (SQLException ex1) {
ex1.printStackTrace();
}
//设置客人帐号!!
if(tip==false)
{
String sqlAccNO = "select * from register ";
rs = dbo.returnQuery(sqlAccNO);
try {
while (rs.next()) {
++accountNo;
}
} catch (SQLException ex2) {
ex2.printStackTrace();
}
tip=true;
}
++accountNo;//设置帐单号
this.txtAccountNo.setText("" + accountNo);
--accountNo;
}
//打折下拉框选项状态改变事件
public void cboDepate_itemStateChanged(ItemEvent e) {
//再次从房间号下拉框得到用户选择的房间号;得到用户选择的房间号;
String romNo = this.cboRoomNo.getSelectedItem().toString();
String sql2 = " select standardpri from roomStatus where roomNo = '" +
romNo + "'";
int standPri = 0;
try {
// 得到用户选择的客房的标准价
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -