📄 resetstatusframe.java
字号:
package operation;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import entity.RoomStatusBean;
import entity.DBOperatorBean;
import java.sql.ResultSet;
import java.sql.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import rummery.MainFrame;
/**
* <p>Title: Hawaii rummery manage</p>
*
* <p>Description: minityperummery manage</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: Yue.</p>
*
* @author not attributable
* @version 1.0
*/
public class ResetStatusFrame extends JFrame {
public ResetStatusFrame() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
this.getContentPane().setBackground(new Color(212, 255, 255));
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setResizable(false);
this.setTitle("更改客房信息");
lblTitle.setFont(new java.awt.Font("Dialog", Font.PLAIN, 35));
lblTitle.setForeground(Color.magenta);
lblTitle.setToolTipText("");
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setText("更改客房信息");
lblTitle.setVerticalAlignment(SwingConstants.BOTTOM);
lblTitle.setBounds(new Rectangle(220, 4, 261, 46));
txtDebatePri.setBackground(new Color(236, 232, 232));
txtDebatePri.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtDebatePri.setText("");
txtRoomType.setBackground(new Color(250, 230, 255));
txtRoomType.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtRoomType.setEditable(false);
txtRoomType.setText("");
txtPlace.setBackground(new Color(250, 230, 255));
txtPlace.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtPlace.setEditable(false);
txtPlace.setText("");
txtStandpri.setBackground(new Color(236, 232, 232));
txtStandpri.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtStandpri.setText("");
panelInfo.setBackground(new Color(210, 230, 255));
panelInfo.setBorder(BorderFactory.createEtchedBorder());
panelInfo.setBounds(new Rectangle(81, 120, 545, 319));
panelInfo.setLayout(gridLayout);
txtOnUse.setBackground(new Color(236, 232, 232));
txtOnUse.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtOnUse.setText("");
txtRoomNo.setBackground(new Color(250, 230, 255));
txtRoomNo.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtRoomNo.setEditable(false);
txtRoomNo.setText("");
txtIntro.setBackground(new Color(236, 232, 232));
txtIntro.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtIntro.setText("");
txtRemark.setBackground(new Color(236, 232, 232));
txtRemark.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
txtRemark.setText("");
lblRoomNo.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblRoomNo.setBorder(null);
lblRoomNo.setHorizontalAlignment(SwingConstants.CENTER);
lblRoomNo.setText("* 房间编号:");
lblRoomType.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblRoomType.setBorder(null);
lblRoomType.setHorizontalAlignment(SwingConstants.CENTER);
lblRoomType.setText("* 房间类别:");
lblStandPri.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblStandPri.setBorder(null);
lblStandPri.setHorizontalAlignment(SwingConstants.CENTER);
lblStandPri.setText("标 准 价:");
lblRemark.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblRemark.setBorder(null);
lblRemark.setHorizontalAlignment(SwingConstants.CENTER);
lblRemark.setText("备 注:");
lblDebatePri.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblDebatePri.setBorder(null);
lblDebatePri.setHorizontalAlignment(SwingConstants.CENTER);
lblDebatePri.setText("折 扣 价:");
lblIntro.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblIntro.setBorder(null);
lblIntro.setHorizontalAlignment(SwingConstants.CENTER);
lblIntro.setText("房间介绍:");
lblOnUse.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblOnUse.setBorder(null);
lblOnUse.setHorizontalAlignment(SwingConstants.CENTER);
lblOnUse.setText("房间状态:");
lblPlace.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
lblPlace.setBorder(null);
lblPlace.setHorizontalAlignment(SwingConstants.CENTER);
lblPlace.setText("* 房间位置:");
btnSave.setBackground(new Color(220, 255, 255));
btnSave.setBounds(new Rectangle(232, 461, 100, 30));
btnSave.setEnabled(false);
btnSave.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
btnSave.setForeground(Color.magenta);
btnSave.setText("");
btnSave.addActionListener(new ResetStatusFrame_btnSave_actionAdapter(this));
btnCancel.setBackground(new Color(220, 255, 255));
btnCancel.setBounds(new Rectangle(375, 461, 100, 30));
btnCancel.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
btnCancel.setForeground(Color.magenta);
btnCancel.setText("");
btnCancel.addActionListener(new
ResetStatusFrame_btnCancel_actionAdapter(this));
btnQuery.setBackground(new Color(220, 255, 255));
btnQuery.setBounds(new Rectangle(443, 13, 80, 30));
btnQuery.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
btnQuery.setForeground(Color.magenta);
btnQuery.setText("");
btnQuery.addActionListener(new ResetStatusFrame_btnQuery_actionAdapter(this));
lblInfo.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
lblInfo.setText("请选择查询房间号:");
lblInfo.setBounds(new Rectangle(3, 14, 194, 26));
panelSql.setBackground(new Color(210, 230, 255));
panelSql.setBorder(BorderFactory.createEtchedBorder());
panelSql.setBounds(new Rectangle(80, 60, 545, 50));
panelSql.setLayout(null);
cboRoomType.setBackground(new Color(255, 210, 255));
cboRoomType.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
cboRoomType.setForeground(Color.blue);
cboRoomType.setBounds(new Rectangle(208, 14, 100, 30));
cboRoomType.addItemListener(new
ResetStatusFrame_cboRoomType_itemAdapter(this));
cboRoomType.addItem("豪华间");
cboRoomType.addItem("标准间");
cboRoomType.addItem("普通间");
cboRoomNo.setBackground(new Color(255, 210, 255));
cboRoomNo.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
cboRoomNo.setForeground(Color.blue);
cboRoomNo.setBounds(new Rectangle(328, 14, 100, 29));
this.btnQuery.setIcon(new ImageIcon("image\\frame\\ResetRoomInfo\\query.jpg"));
this.btnCancel.setIcon(new ImageIcon("image\\frame\\ResetRoomInfo\\cancel.jpg"));
this.btnSave.setIcon(new ImageIcon("image\\frame\\ResetRoomInfo\\save.jpg"));
panelInfo.add(lblRoomNo);
panelInfo.add(txtRoomNo);
panelInfo.add(lblRoomType);
panelInfo.add(txtRoomType);
panelInfo.add(lblStandPri);
panelInfo.add(txtStandpri);
panelInfo.add(lblDebatePri);
panelInfo.add(txtDebatePri);
panelInfo.add(lblOnUse);
panelInfo.add(txtOnUse);
panelInfo.add(lblPlace);
panelInfo.add(txtPlace);
panelInfo.add(lblIntro);
panelInfo.add(txtIntro);
panelInfo.add(lblRemark);
panelInfo.add(txtRemark);
this.getContentPane().add(btnCancel);
this.getContentPane().add(btnSave);
this.getContentPane().add(panelSql);
this.getContentPane().add(lblTitle);
panelSql.add(lblInfo, null);
panelSql.add(cboRoomNo);
panelSql.add(cboRoomType);
panelSql.add(btnQuery, null);
this.getContentPane().add(panelInfo);
roomStatus = new RoomStatusBean();
}
JLabel lblTitle = new JLabel();
JLabel lblInfo = new JLabel();
JButton btnQuery = new JButton();
JTextField txtDebatePri = new JTextField();
JTextField txtRoomType = new JTextField();
JTextField txtPlace = new JTextField();
JTextField txtStandpri = new JTextField();
JPanel panelInfo = new JPanel();
GridLayout gridLayout = new GridLayout(8,4);
JTextField txtOnUse = new JTextField();
JTextField txtRoomNo = new JTextField();
JTextField txtIntro = new JTextField();
JTextField txtRemark = new JTextField();
JLabel lblRoomNo = new JLabel();
JLabel lblRoomType = new JLabel();
JLabel lblStandPri = new JLabel();
JLabel lblRemark = new JLabel();
JLabel lblDebatePri = new JLabel();
JLabel lblIntro = new JLabel();
JLabel lblOnUse = new JLabel();
JLabel lblPlace = new JLabel();
JButton btnSave = new JButton();
JButton btnCancel = new JButton();
JPanel panelSql = new JPanel();
RoomStatusBean roomStatus ;
DBOperatorBean dbo = new DBOperatorBean();
ResultSet rs;
JComboBox cboRoomType = new JComboBox();
JComboBox cboRoomNo = new JComboBox();
public void btnSave_actionPerformed(ActionEvent e) {
roomStatus = new RoomStatusBean();
//实例化
roomStatus.setRoomNo(this.txtRoomNo.getText());
roomStatus.setStandardPri( Integer.parseInt(this.txtStandpri.getText()));
roomStatus.setRebatePri( Integer.parseInt(this.txtDebatePri.getText()));
roomStatus.setOnUse(Integer.parseInt(this.txtOnUse.getText()));
roomStatus.setRoomIntro(this.txtIntro.getText());
roomStatus.setRemark(this.txtRemark.getText());
String update = "update roomStatus set StandardPri = '"+roomStatus.getStandardPri()
+"', RebatePri = '"+roomStatus.getRebatePri()+"', OnUse = '"+ roomStatus.getOnUse()
+"', RoomIntro ='"+roomStatus.getRoomIntro()+"',Remark ='"+roomStatus.getRemark()
+"' where roomNo = '" +roomStatus.getRoomNo()+"'";
boolean flag = dbo.updateNoReturn(update);
if(flag)
{
JOptionPane.showMessageDialog(this,"数据已更新,保存成功!!","提示",JOptionPane.INFORMATION_MESSAGE);
this.txtDebatePri.setText("");
this.txtIntro.setText("");
this.txtOnUse.setText("");
this.txtPlace.setText("");
this.txtRemark.setText("");
this.txtRoomNo.setText("");
this.txtRoomType.setText("");
this.txtStandpri.setText("");
}
else
{
JOptionPane.showMessageDialog(this,"更新失败!!","提示",JOptionPane.INFORMATION_MESSAGE);
}
}
//单击取消按钮返回主页面
public void btnCancel_actionPerformed(ActionEvent e) {
this.dispose();
}
public void btnQuery_actionPerformed(ActionEvent e) {
//得到房间类型
String romStype = cboRoomType.getSelectedItem().toString();
String romNo = cboRoomNo.getSelectedItem().toString();
String sql = "select * from roomstatus where roomNo = '"+romNo+"' and class = '"+romStype+"'";
rs = dbo.returnQuery(sql);
try {
if(rs.next()) {
this.txtRoomNo.setText(rs.getString(1));
this.txtRoomType.setText(rs.getString(2));
this.txtStandpri.setText(""+rs.getInt(3));
this.txtDebatePri.setText(""+rs.getInt(4));
this.txtOnUse.setText(""+rs.getInt(5));
this.txtPlace.setText(rs.getString(6));
this.txtIntro.setText(rs.getString(7));
this.txtRemark.setText(rs.getString(8));
//JOptionPane.showMessageDialog(this,"该房间已经查到!!");
}
} catch (SQLException ex) {
ex.printStackTrace();
}
btnSave.setEnabled(true);
}
public void cboRoomType_itemStateChanged(ItemEvent e) {
//删除该列表中的所有元素,重新赋值
cboRoomNo.removeAllItems();
String rType = cboRoomType.getSelectedItem().toString();
//查询该类房间的所有房间
String sql = "select roomNo from roomStatus where class = '"+rType+"'";
rs = dbo.returnQuery(sql);
try {
//添加客房编号下拉框的初始值
while (rs.next()) {
cboRoomNo.addItem(rs.getString(1));
}
} catch (SQLException ex) {
}
}
}
class ResetStatusFrame_cboRoomType_itemAdapter implements ItemListener {
private ResetStatusFrame adaptee;
ResetStatusFrame_cboRoomType_itemAdapter(ResetStatusFrame adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.cboRoomType_itemStateChanged(e);
}
}
class ResetStatusFrame_btnQuery_actionAdapter implements ActionListener {
private ResetStatusFrame adaptee;
ResetStatusFrame_btnQuery_actionAdapter(ResetStatusFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnQuery_actionPerformed(e);
}
}
class ResetStatusFrame_btnCancel_actionAdapter implements ActionListener {
private ResetStatusFrame adaptee;
ResetStatusFrame_btnCancel_actionAdapter(ResetStatusFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnCancel_actionPerformed(e);
}
}
class ResetStatusFrame_btnSave_actionAdapter implements ActionListener {
private ResetStatusFrame adaptee;
ResetStatusFrame_btnSave_actionAdapter(ResetStatusFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnSave_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -