📄 systemsetting.java
字号:
jButtonModifyOperator = new JButton();
jButtonModifyOperator.setBounds(new java.awt.Rectangle(210,195,100,30));
jButtonModifyOperator.setText("修改管理员");
jButtonModifyOperator.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (checkOperatorInputValue()) {
if (jLabelgetOperatorId.getText().trim().equals(
jTextFieldgetOperatorId.getText().trim())) {
OperatorSettingControl control = new OperatorSettingControl();
int operatorId = Integer
.parseInt(getJTextFieldgetOperatorId()
.getText().trim());
String operatorName = getJTextFieldgetOperatorName()
.getText();
String operatorLevel = getJComboBoxOperatorLevel()
.getSelectedItem().toString().trim();
Operator value = new Operator(operatorId,
operatorName, operatorLevel, "123");
if (control.updateOperatorInfo(value)) {
JOptionPane.showMessageDialog(null, "数据更改成功",
"更改提示", JOptionPane.YES_OPTION);
}
} else {
JOptionPane.showMessageDialog(null, "管理员编号不能修改",
"更改提示", JOptionPane.YES_OPTION);
jTextFieldgetOperatorId.setText(jLabelgetOperatorId
.getText().trim());
}
}
}
});
}
return jButtonModifyOperator;
}
//构造删除管理员信息的方法,且当管理员是超级管理员是,不可删除.
private JButton getJButtonDeleteOperator() {
if (jButtonDeleteOperator == null) {
jButtonDeleteOperator = new JButton();
jButtonDeleteOperator.setBounds(new java.awt.Rectangle(389,197,100,30));
jButtonDeleteOperator.setText("删除管理员");
jButtonDeleteOperator.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
if (!jLabelgetOperatorId.getText().equals("")) {
if (!getJComboBoxOperatorLevel().getSelectedItem()
.toString().equals("超级管理员")) {
DefaultTableModel model = (DefaultTableModel) getJTableOperatorSetting()
.getModel();
int row = getJTableOperatorSetting()
.getSelectedRow();
OperatorSettingControl control = new OperatorSettingControl();
String operatorId = getJTableOperatorSetting()
.getValueAt(row, 0).toString();
if (control.deleteOperatorInfo(operatorId)) {
JOptionPane.showMessageDialog(null,
"数据删除成功", "删除提示",
JOptionPane.YES_OPTION);
model.removeRow(row);
}
} else {
JOptionPane.showMessageDialog(null,
"超级管理员不能删除", "更改提示",
JOptionPane.YES_OPTION);
jTextFieldgetOperatorId
.setText(jLabelgetOperatorId.getText()
.trim());
}
} else {
JOptionPane.showMessageDialog(null, "请先选中您要删除的管理员",
"删除提示", JOptionPane.YES_OPTION);
}
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, "管理员删除失败", "删除提示",
JOptionPane.YES_OPTION);
}
}
});
}
return jButtonDeleteOperator;
}
//构造管理员信息重置的方法
private JButton getJButtonResetOperator() {
if (jButtonResetOperator == null) {
jButtonResetOperator = new JButton();
jButtonResetOperator.setBounds(new java.awt.Rectangle(333,145,90,30));
jButtonResetOperator.setText("重置");
jButtonResetOperator
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
getJTextFieldgetOperatorId().setText("");
getJTextFieldgetOperatorName().setText("");
getJComboBoxOperatorLevel()
.setSelectedItem("前台收银员");
}
});
}
return jButtonResetOperator;
}
private JComboBox getJComboBoxgetRoomType() {
if (jComboBoxgetRoomType == null) {
jComboBoxgetRoomType = new JComboBox();
jComboBoxgetRoomType.addItem("小型包间");
jComboBoxgetRoomType.addItem("中型包间");
jComboBoxgetRoomType.addItem("大型包间");
jComboBoxgetRoomType.addItem("豪华包间");
jComboBoxgetRoomType.setSelectedItem("小型包间");
jComboBoxgetRoomType.setBounds(new java.awt.Rectangle(410, 30, 100,
20));
}
return jComboBoxgetRoomType;
}
/**
* 构建刷新的方法
*/
//构建刷新房间信息的方法
private JButton getJButtonRoomFlush() {
if (jButtonRoomFlush == null) {
jButtonRoomFlush = new JButton();
jButtonRoomFlush
.setBounds(new java.awt.Rectangle(330,246,100,18));
jButtonRoomFlush.setText("刷新");
jButtonRoomFlush.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DefaultTableModel model = (DefaultTableModel) getJTableRoomSetting()
.getModel();
int rows = model.getRowCount();
for (int i = rows - 1; i >= 0; i--) {
model.removeRow(i);
}
RoomSettingControl control = new RoomSettingControl();
Vector v = control.getRoomInfo();
Iterator iter = v.iterator();
while (iter.hasNext()) {
Room value = (Room) iter.next();
Object[] data = { value.getRoomNumber(),
value.getRoomType(),
String.valueOf(value.getRoomPrice()),
value.getRoomName(), value.getRoomStatement(),
String.valueOf(value.getRoomCapacity()),
String.valueOf(value.getConsumedId()) };
model.addRow(data);
}
}
});
}
return jButtonRoomFlush;
}
// 构建消费类型刷新的方法
private JButton getJButtonMofifyConsumedFlush() {
if (jButtonMofifyConsumedFlush == null) {
jButtonMofifyConsumedFlush = new JButton();
jButtonMofifyConsumedFlush.setBounds(new java.awt.Rectangle(333,206,103,21));
jButtonMofifyConsumedFlush.setText("刷新");
jButtonMofifyConsumedFlush.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DefaultTableModel model = (DefaultTableModel) getJTableConsumedType()
.getModel();
int rows = model.getRowCount();
for (int i = rows - 1; i >= 0; i--) {
model.removeRow(i);
}
ConsumedTypeSettingControl control = new ConsumedTypeSettingControl();
Vector v = control.getConsumedTypeInfo();
Iterator iter = v.iterator();
while (iter.hasNext()) {
ConsumedTypeInfo value = (ConsumedTypeInfo) iter.next();
Object[] data = { value.getConsumedTypeName(),
String.valueOf(value.getRebate()), };
model.addRow(data);
}
}
});
}
return jButtonMofifyConsumedFlush;
}
//构建管理员信息刷新的方法
private JButton getJButtonOperatorSettingFlush() {
if (jButtonOperatorSettingFlush == null) {
jButtonOperatorSettingFlush = new JButton();
jButtonOperatorSettingFlush.setBounds(new java.awt.Rectangle(419,246,110,22));
jButtonOperatorSettingFlush.setText("刷新");
jButtonOperatorSettingFlush.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DefaultTableModel model = (DefaultTableModel) getJTableOperatorSetting()
.getModel();
int rows = model.getRowCount();
for (int i = rows - 1; i >= 0; i--) {
model.removeRow(i);
}
OperatorSettingControl control = new OperatorSettingControl();
Vector v = control.getOperatorInfo();
Iterator iter = v.iterator();
while (iter.hasNext()) {
Operator value = (Operator) iter.next();
Object[] data = {
String.valueOf(value.getOperatorId()),
value.getOperatorName(),
value.getOperatorLevel(), value.getPassword() };
model.addRow(data);
}
}
});
}
return jButtonOperatorSettingFlush;
}
//构建商品信息刷新的方法
private JButton getJButtonGoodsSettingFlush() {
if (jButtonGoodsSettingFlush == null) {
jButtonGoodsSettingFlush = new JButton();
jButtonGoodsSettingFlush.setBounds(new java.awt.Rectangle(324,282,103,17));
jButtonGoodsSettingFlush.setText("刷新");
jButtonGoodsSettingFlush.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DefaultTableModel model = (DefaultTableModel) getJTableGoodsSetting()
.getModel();
int rows = model.getRowCount();
for (int i = rows - 1; i >= 0; i--) {
model.removeRow(i);
}
GoodsSettingControl control = new GoodsSettingControl();
Vector v = control.getGoodsInfo();
Iterator iter = v.iterator();
while (iter.hasNext()) {
Goods value = (Goods) iter.next();
Object[] data = { value.getGoodsName(),
value.getGoodsUnit(),
String.valueOf(value.getGoodsCostPrice()),
String.valueOf(value.getGoodsSellPrice()),
String.valueOf(value.getGoodsStock()),
String.valueOf(value.getGoodsAlert()),
String.valueOf(value.getGoodsAbbreviation()) };
model.addRow(data);
}
}
});
}
return jButtonGoodsSettingFlush;
}
private JComboBox getJComboBoxgetRoomStatement() {
if (jComboBoxgetRoomStatement == null) {
jComboBoxgetRoomStatement = new JComboBox();
jComboBoxgetRoomStatement.addItem("可用");
jComboBoxgetRoomStatement.addItem("预订");
jComboBoxgetRoomStatement.addItem("占用");
jComboBoxgetRoomStatement.addItem("停用");
jComboBoxgetRoomStatement.setSelectedItem("可用");
jComboBoxgetRoomStatement.setBounds(new java.awt.Rectangle(160,
150, 100, 20));
}
return jComboBoxgetRoomStatement;
}
/**
* 构建约束输入值的方法
*/
private boolean checkRoomInputValue() {
// boolean flag = false;
Check check = new Check();
if (check.checkInputIsNull(getJTextFieldgetRoomNumber().getText())) {
JOptionPane.showMessageDialog(null, "包间号码不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomNumber().requestFocus();
return false;
}
if (check.checkinputLength(5, getJTextFieldgetRoomNumber().getText())) {
JOptionPane.showMessageDialog(null, "包间号码不能超过5个字符", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomNumber().requestFocus();
return false;
}
if (check.checkInputIsNull(getJTextFieldgetRoomPrice().getText())) {
JOptionPane.showMessageDialog(null, "包间单价不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomPrice().requestFocus();
return false;
}
if (check.checkinputLength(4, getJTextFieldgetRoomPrice().getText())) {
JOptionPane.showMessageDialog(null, "包间单价只能为整数,且不超过四位", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomPrice().requestFocus();
return false;
}
if (!check.checkIsContainNumber(getJTextFieldgetRoomPrice().getText())) {
JOptionPane.showMessageDialog(null, "包间单价只能为整数,且不超过四位", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomPrice().requestFocus();
return false;
}
if (check.checkInputIsNull(getJTextFieldgetRoomName().getText())) {
JOptionPane.showMessageDialog(null, "包间名称不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomName().requestFocus();
return false;
}
if (check.checkinputLength(10, getJTextFieldgetRoomName().getText())) {
JOptionPane.showMessageDialog(null, "包间名称不能超过五个汉字(即十个英文字母)",
"提示信息", JOptionPane.YES_OPTION);
getJTextFieldgetRoomName().requestFocus();
return false;
}
if (check.checkInputIsNull(getJTextFieldgetRoomCapacity().getText())) {
JOptionPane.showMessageDialog(null, "可容纳人数不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomCapacity().requestFocus();
return false;
}
if (check.checkinputLength(3, getJTextFieldgetRoomCapacity().getText())) {
JOptionPane.showMessageDialog(null, "可容纳人数最多三位数", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomCapacity().requestFocus();
return false;
}
if (!check.checkIsContainNumber(getJTextFieldgetRoomCapacity()
.getText())) {
JOptionPane.showMessageDialog(null, "可容纳人数只能为整数,且不超过三位", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetRoomCapacity().requestFocus();
return false;
}
return true;
}
private boolean checkGoodsInputValue() {
Check check = new Check();
if (check.checkInputIsNull(getJTextFieldgetGoodsName().getText())) {
JOptionPane.showMessageDialog(null, "商品名称不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetGoodsName().requestFocus();
return false;
}
if (check.checkinputLength(20, getJTextFieldgetGoodsName().getText())) {
JOptionPane.showMessageDialog(null, "商品名称不能超过20个字符(即10个汉字)",
"提示信息", JOptionPane.YES_OPTION);
getJTextFieldgetGoodsName().requestFocus();
return false;
}
if (check.checkInputIsNull(getJTextFieldgetGoodsUnit().getText())) {
JOptionPane.showMessageDialog(null, "商品单位不能为空", "提示信息",
JOptionPane.YES_OPTION);
getJTextFieldgetGoodsUnit().requestFocus();
return false;
}
if (check.checkinputLength(2, getJTextFieldgetGoodsUnit().getText())) {
JOptionPane.showMessageDialog(null, "商品单位不能超过2个字
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -