📄 roomtypesettingjdialog.java
字号:
package view.SystemSetting;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JButton;
import vo.RoomType;
import vo.WaiterInfo;
import common.centerwindow.CenterWindow;
import common.checkinputvalue.Check;
import dao.consumeddao.WaiterConsumedDao;
import dao.roomtypesetting.RoomTypeSettingDao;
public class RoomTypeSettingJDialog {
private JDialog jDialog = null; // @jve:decl-index=0:visual-constraint="143,64"
private JPanel jContentPane = null;
private JLabel RoomTypejLabel = null;
private JLabel CapacityjLabel = null;
private JLabel MinConsumejLabel = null;
private JTextField MinConsumejTextField = null;
private JTextField CapacityjTextField = null;
private JButton SavejButton = null;
private JButton ClosejButton = null;
private JComboBox RoomTypejComboBox = null;
/**
* This method initializes jDialog
*
* @return javax.swing.JDialog
*/
public JDialog getJDialog() {
if (jDialog == null) {
jDialog = new JDialog();
CenterWindow cw = new CenterWindow();
cw.centerWindow(jDialog);
jDialog.setSize(new java.awt.Dimension(235,247));
jDialog.setContentPane(getJContentPane());
}
return jDialog;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
MinConsumejLabel = new JLabel();
MinConsumejLabel.setBounds(new java.awt.Rectangle(15,45,60,16));
MinConsumejLabel.setText("最低消费");
CapacityjLabel = new JLabel();
CapacityjLabel.setBounds(new java.awt.Rectangle(15,75,61,16));
CapacityjLabel.setText("容纳人数");
RoomTypejLabel = new JLabel();
RoomTypejLabel.setBounds(new java.awt.Rectangle(16,15,61,16));
RoomTypejLabel.setText("包房类型");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(RoomTypejLabel, null);
jContentPane.add(CapacityjLabel, null);
jContentPane.add(MinConsumejLabel, null);
jContentPane.add(getMinConsumejTextField(), null);
jContentPane.add(getCapacityjTextField(), null);
jContentPane.add(getSavejButton(), null);
jContentPane.add(getClosejButton(), null);
jContentPane.add(getRoomTypejComboBox(), null);
}
return jContentPane;
}
public RoomType getInputValue() {
RoomType value = null;
String roomType = RoomTypejComboBox.getSelectedItem().toString().trim();
String roomPrice = MinConsumejTextField.getText().trim();
String roomCapacity = CapacityjTextField.getText();
value = new RoomType(roomType,roomPrice,roomCapacity);
return value;
}
/**
* This method initializes MinConsumejTextField
*
* @return javax.swing.JTextField
*/
public JTextField getMinConsumejTextField() {
if (MinConsumejTextField == null) {
MinConsumejTextField = new JTextField();
MinConsumejTextField.setBounds(new java.awt.Rectangle(91,44,120,18));
}
return MinConsumejTextField;
}
/**
* This method initializes CapacityjTextField
*
* @return javax.swing.JTextField
*/
public JTextField getCapacityjTextField() {
if (CapacityjTextField == null) {
CapacityjTextField = new JTextField();
CapacityjTextField.setBounds(new java.awt.Rectangle(90,75,122,17));
}
return CapacityjTextField;
}
/**
* This method initializes SavejButton
*
* @return javax.swing.JButton
*/
private JButton getSavejButton() {
if (SavejButton == null) {
SavejButton = new JButton();
SavejButton.setBounds(new java.awt.Rectangle(14,167,75,30));
SavejButton.setText("保存");
SavejButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
RoomType value = getInputValue();
RoomTypeSettingDao dao = new RoomTypeSettingDao();
if (checkInput()) {
if (getJDialog().getTitle().equals("添加服务员")) {
System.out.println("***********************************************");
if (dao.insertRoomType(value)) {
JOptionPane.showMessageDialog(null, "数据追加成功", "提示信息",
JOptionPane.YES_OPTION);
getJDialog().dispose();
}
} else {
JOptionPane.showMessageDialog(null, "数据追加失败", "提示信息",
JOptionPane.YES_OPTION);
}
}
}
});
}
return SavejButton;
}
/**
* This method initializes ClosejButton
*
* @return javax.swing.JButton
*/
private JButton getClosejButton() {
if (ClosejButton == null) {
ClosejButton = new JButton();
ClosejButton.setBounds(new java.awt.Rectangle(135,167,76,31));
ClosejButton.setText("关闭");
ClosejButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
getJDialog().dispose();
}
});
}
return ClosejButton;
}
/**
* This method initializes RoomTypejComboBox
*
* @return javax.swing.JComboBox
*/
public JComboBox getRoomTypejComboBox() {
if (RoomTypejComboBox == null) {
RoomTypejComboBox = new JComboBox();
RoomTypejComboBox.setBounds(new java.awt.Rectangle(91,15,121,16));
}
return RoomTypejComboBox;
}
public boolean checkInput() {
boolean flag = false;
Check check = new Check();
if (check.checkInputIsNull(MinConsumejTextField.getText())){
JOptionPane.showMessageDialog(null, "最低消费不能为空且必须为数字", "提示信息",JOptionPane.YES_OPTION);
MinConsumejTextField.requestFocus();
return false;
}
else
if (check.checkInputIsNull(CapacityjTextField.getText())) {
JOptionPane.showMessageDialog(null, "房间容纳人数不能为空且必须为数字", "提示信息",JOptionPane.YES_OPTION);
CapacityjTextField.requestFocus();
return false;
}
// } else if (check.checkinputLength(12,WaiterTeljTextField.getText())) {
// JOptionPane.showMessageDialog(null, "服务员电话必须是12位,且不能为空", "提示信息",JOptionPane.YES_OPTION);
// WaiterTeljTextField.requestFocus();
// return false;
// } else
// if (check.checkInputIsNull(WaiterAreajTextField.getText())) {
// JOptionPane.showMessageDialog(null, "服务员服务区域不能为空", "提示信息",JOptionPane.YES_OPTION);
// WaiterAreajTextField.requestFocus();
// return false;
//
//
// }
return true;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -