⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roomstatementframe.java

📁 一个KTV管理系统
💻 JAVA
字号:
package view.mainframe.guestregister;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import view.mainframe.MainFrame;
import view.mainframe.guestregister.reservationmanageframe.registReservation;

import common.centerwindow.CenterWindow;

import control.roomsetting.RoomSettingControl;
//更改包间状态类
public class RoomStatementFrame {
	private static RoomStatementFrame instance;

	private static JFrame jFrameRoomStatement = null; // @jve:decl-index=0:visual-constraint="140,109"

	private JPanel jContentPaneRoomStatement = null;//包间状态面板

	private JLabel jLabelChooseRoom = null;//所选包间

	private JLabel jLabelCurrentStatement = null;//当前状态

	private JLabel jLabelgetChooseRoom = null;//

	private JLabel jLabelgetCurrentStatement = null;

	private JButton jButtonChangetoAvailable = null;//变为可用

	private JButton jButtonChangetoReservation = null;//变为预定

	private JButton jButtonChangertoStop = null;//变为停止
//通过房间号跟房间状态来初始化该面板
	public static RoomStatementFrame getRoomInfo(String roomNumber,
			String roomStatement) {
		if (instance == null) {
			instance = new RoomStatementFrame();
		}
		instance.jFrameRoomStatement.setVisible(true);
		instance.jLabelgetChooseRoom.setText(roomNumber);
		instance.jLabelgetCurrentStatement.setText(roomStatement);
		return instance;
	}
//默认构造函数
	public RoomStatementFrame() {

		jFrameRoomStatement = getJFrameRoomStatement();
	}

	//初始化主面板
	public JFrame getJFrameRoomStatement() {
		if (jFrameRoomStatement == null) {
			jFrameRoomStatement = new JFrame();
			jFrameRoomStatement.setSize(new java.awt.Dimension(329, 247));
			jFrameRoomStatement
					.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
			jFrameRoomStatement.setResizable(false);
			jFrameRoomStatement.setTitle("更改包间状态");
			new CenterWindow().centerWindow(jFrameRoomStatement);
			jFrameRoomStatement.setContentPane(getJContentPaneRoomStatement());
			jFrameRoomStatement.setVisible(true);
			jFrameRoomStatement
					.addWindowListener(new java.awt.event.WindowAdapter() {
						public void windowClosing(java.awt.event.WindowEvent e) {
							jFrameRoomStatement.setVisible(false);
							jFrameRoomStatement.dispose();
						}
					});
		}
		return jFrameRoomStatement;
	}

//初始化面板
	private JPanel getJContentPaneRoomStatement() {
		if (jContentPaneRoomStatement == null) {
			jLabelgetCurrentStatement = new JLabel();
			jLabelgetCurrentStatement.setBounds(new java.awt.Rectangle(150, 75,
					80, 20));
			jLabelgetCurrentStatement.setText("");
			jLabelgetChooseRoom = new JLabel();
			jLabelgetChooseRoom.setBounds(new java.awt.Rectangle(150, 40, 80,
					20));
			jLabelgetChooseRoom.setText("");
			jLabelCurrentStatement = new JLabel();
			jLabelCurrentStatement.setBounds(new java.awt.Rectangle(85, 75, 60,
					20));
			jLabelCurrentStatement.setText("当前状态:");
			jLabelChooseRoom = new JLabel();
			jLabelChooseRoom.setBounds(new java.awt.Rectangle(85, 40, 60, 20));
			jLabelChooseRoom.setText("所选包间:");
			jContentPaneRoomStatement = new JPanel();
			jContentPaneRoomStatement.setLayout(null);
			jContentPaneRoomStatement.add(jLabelChooseRoom, null);
			jContentPaneRoomStatement.add(jLabelCurrentStatement, null);
			jContentPaneRoomStatement.add(jLabelgetChooseRoom, null);
			jContentPaneRoomStatement.add(jLabelgetCurrentStatement, null);
			jContentPaneRoomStatement.add(getJButtonChangetoAvailable(), null);
			jContentPaneRoomStatement
					.add(getJButtonChangetoReservation(), null);
			jContentPaneRoomStatement.add(getJButtonChangertoStop(), null);
		}
		return jContentPaneRoomStatement;
	}

	//获得可用包间
	private JButton getJButtonChangetoAvailable() {
		if (jButtonChangetoAvailable == null) {
			jButtonChangetoAvailable = new JButton();
			jButtonChangetoAvailable.setBounds(new java.awt.Rectangle(20, 140,
					90, 60));
			jButtonChangetoAvailable.setText("变为可用");
			jButtonChangetoAvailable
					.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
			jButtonChangetoAvailable
					.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
			jButtonChangetoAvailable.setIcon(new ImageIcon(
					"icon/mainframe/UltraMix35_002.jpg"));
			jButtonChangetoAvailable
					.addActionListener(new updateRoomStatementAvailable());
		}
		return jButtonChangetoAvailable;
	}
//获得预定包间按纽
	private JButton getJButtonChangetoReservation() {
		if (jButtonChangetoReservation == null) {
			jButtonChangetoReservation = new JButton();
			jButtonChangetoReservation.setBounds(new java.awt.Rectangle(120,
					140, 90, 60));
			jButtonChangetoReservation
					.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
			jButtonChangetoReservation
					.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
			jButtonChangetoReservation.setIcon(new ImageIcon(
					"icon/mainframe/UltraMix08_002.jpg"));
			jButtonChangetoReservation.setText("变为预定");
			jButtonChangetoReservation
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							if (jLabelgetCurrentStatement.getText().trim()
									.equals("可用")) {
								registReservation
										.getInstance(jLabelgetChooseRoom
												.getText().trim());
							} else {
								JOptionPane.showMessageDialog(null, "停用房间不可预定",
										"更改提示", JOptionPane.YES_OPTION);
							}
						}
					});
		}
		return jButtonChangetoReservation;
	}
//变为停用
	private JButton getJButtonChangertoStop() {
		if (jButtonChangertoStop == null) {
			jButtonChangertoStop = new JButton();
			jButtonChangertoStop.setBounds(new java.awt.Rectangle(220, 140, 90,
					60));
			jButtonChangertoStop
					.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
			jButtonChangertoStop
					.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
			jButtonChangertoStop.setIcon(new ImageIcon(
					"icon/mainframe/UltraMix29_002.jpg"));
			jButtonChangertoStop.setText("变为停用");
			jButtonChangertoStop
					.addActionListener(new updateRoomStatementStop());
		}
		return jButtonChangertoStop;
	}
//更新包间状态停用类,事件用来更新包间信息
	private class updateRoomStatementStop implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			String roomNumber = jLabelgetChooseRoom.getText().trim();

			RoomSettingControl control = new RoomSettingControl();
			if (control.updateRoomStatement(roomNumber, "停用")) {
				MainFrame.getInstance().refresh();
				JOptionPane.showMessageDialog(null, "状态更改成功", "更改提示",
						JOptionPane.YES_OPTION);
			}

		}

	}
//	更新包间状态可用类,事件用来更新包间信息
	private class updateRoomStatementAvailable implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			String roomNumber = jLabelgetChooseRoom.getText().trim();

			RoomSettingControl control = new RoomSettingControl();
			if (control.updateRoomStatement(roomNumber, "可用")) {
				MainFrame.getInstance().refresh();
				JOptionPane.showMessageDialog(null, "状态更改成功", "更改提示",
						JOptionPane.YES_OPTION);
			}

		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -