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

📄 updatereservationframe.java

📁 这个一个餐厅预定系统,可实现查询目前餐厅预订情况,实现餐桌预订以及就餐时为顾客调节餐桌的情况.
💻 JAVA
字号:
package bookingsystem;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import java.text.SimpleDateFormat;
import java.sql.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class UpdatereservationFrame extends myFrame {

    private ReservationFrame resFrame;
    JLabel jLabel1 = new JLabel();
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField5 = new JTextField();
    JComboBox jComboBox1 = new JComboBox();
    JComboBox jComboBox2 = new JComboBox();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JTextField jTextField3 = new JTextField();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JButton jButton3 = new JButton();
    Checkbox checkbox1 = new Checkbox();


    public UpdatereservationFrame(ReservationFrame resFrame) {
        super();
        try {
            this.resFrame = resFrame;
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        String arrivalTime[] = {"10:00-12:00", "18:00-20:00", "20:00-22:00"};
        for (int i = 0; i < 3; i++) {
          jComboBox2.addItem(arrivalTime[i]);
       }
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        getContentPane().setLayout(xYLayout1);
        jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel1.setText("修改预约");
        jLabel3.setToolTipText("");
        jButton2.setText("取消");
        jButton2.addActionListener(new
                UpdatereservationFrame_jButton2_actionAdapter(this));
        jButton1.setText("修改");
        jButton1.addActionListener(new
                UpdatereservationFrame_jButton1_actionAdapter(this));
        jLabel7.setText("预约时间");
        jLabel8.setText("客户到达");
        xYLayout1.setWidth(391);
        xYLayout1.setHeight(376);
        jButton3.setText("查询");
        jButton3.addActionListener(new
                UpdatereservationFrame_jButton3_actionAdapter(this));
        checkbox1.setLabel("(选中即到达)");
        jTextField1.setEditable(false);
        jTextField5.setEditable(false);
        jComboBox2.setEditable(true);
        jComboBox1.setEditable(true);
        this.getContentPane().add(jLabel1, new XYConstraints(144, 26, 98, 31));
        jLabel6.setText("顾客姓名");
        jLabel5.setText("餐桌号 ");
        jLabel4.setText("预约日期");
        jLabel3.setText("人数");
        this.getContentPane().add(jLabel2, new XYConstraints(48, 83, -1, -1));
        this.getContentPane().add(jLabel3, new XYConstraints(48, 123, -1, -1));
        this.getContentPane().add(jLabel4, new XYConstraints(48, 164, -1, -1));
        this.getContentPane().add(jLabel5, new XYConstraints(48, 203, -1, -1));
        this.getContentPane().add(jButton2, new XYConstraints(227, 305, 66, -1));
        this.getContentPane().add(jButton1, new XYConstraints(52, 308, 67, 25));

        this.getContentPane().add(jComboBox1,
                                  new XYConstraints(134, 199, 94, -1));
        this.getContentPane().add(jTextField2,
                                  new XYConstraints(134, 119, 94, -1));
        this.getContentPane().add(jTextField1,
                                  new XYConstraints(134, 80, 94, -1));
        this.getContentPane().add(jTextField3,
                                  new XYConstraints(134, 159, 94, -1));
        this.getContentPane().add(jLabel7, new XYConstraints(234, 161, 61, -1));
        this.getContentPane().add(jComboBox2,
                                  new XYConstraints(285, 157, 94, -1));
        this.getContentPane().add(jLabel6, new XYConstraints(48, 248, -1, -1));
        this.getContentPane().add(jLabel8, new XYConstraints(48, 284, 63, -1));
        this.getContentPane().add(jTextField5,
                                  new XYConstraints(134, 243, 94, -1));
        this.getContentPane().add(jButton3, new XYConstraints(251, 200, 67, -1));
        this.getContentPane().add(checkbox1, new XYConstraints(136, 279, -1, -1));

        jLabel2.setText("预约编号");

        displaySelectedR();
    }

    public void displaySelectedR()
    {
        int selecedRow = this.resFrame.jdbTable1.getSelectedRow();
        jTextField1.setText(this.resFrame.jdbTable1.getValueAt(selecedRow,0).toString());
        jTextField2.setText(this.resFrame.jdbTable1.getValueAt(selecedRow,1).toString());
        jTextField3.setText(this.resFrame.jdbTable1.getValueAt(selecedRow,3).toString());
        jTextField5.setText(this.resFrame.jdbTable1.getValueAt(selecedRow,6).toString());
        jComboBox2.setSelectedItem(this.resFrame.jdbTable1.getValueAt(selecedRow,4));
        jComboBox1.setSelectedItem(this.resFrame.jdbTable1.getValueAt(selecedRow,5));


    }

    public void jButton1_actionPerformed(ActionEvent e) {
      Restaurant rs = new Restaurant();
      int tempID = Integer.parseInt(jTextField1.getText().trim());
      int tempCovers = Integer.parseInt(jTextField2.getText().trim());
      String tempArrivalDate = jTextField3.getText().trim();
      String tempArrivalTime = jComboBox2.getSelectedItem().toString();
      String tempTalno = jComboBox1.getSelectedItem().toString();
      boolean isarrival = checkbox1.getState();

     try {
         rs.modifyReservation(tempID, tempCovers, tempArrivalDate,
                             tempArrivalTime, tempTalno, isarrival);
         JOptionPane.showMessageDialog(null,"修改成功!");
     } catch (SQLException ex) {
     }

      this.resFrame.jButton5_actionPerformed(e);
      this.resFrame.setEnabled(true);
      this.dispose();
    }

    public void fillFreeTables() {
       Reservation tempRes = new Reservation();

       String tempArrivalTime = jComboBox2.getSelectedItem().toString();
       String tempArrivalDate = jTextField3.getText().trim();

       Vector freeTables = tempRes.getfreetables(tempArrivalDate,tempArrivalTime);
       for (int i = 0; i < freeTables.size(); i++) {
           Table tempTable = (Table) freeTables.get(i);
           jComboBox1.addItem(tempTable.gettalno());
       }

   }

    public void jButton3_actionPerformed(ActionEvent e) {
         fillFreeTables();
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        this.resFrame.setEnabled(true);
        this.dispose();
    }

}


class UpdatereservationFrame_jButton2_actionAdapter implements ActionListener {
    private UpdatereservationFrame adaptee;
    UpdatereservationFrame_jButton2_actionAdapter(UpdatereservationFrame
                                                  adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class UpdatereservationFrame_jButton3_actionAdapter implements ActionListener {
    private UpdatereservationFrame adaptee;
    UpdatereservationFrame_jButton3_actionAdapter(UpdatereservationFrame
                                                  adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class UpdatereservationFrame_jButton1_actionAdapter implements ActionListener {
    private UpdatereservationFrame adaptee;
    UpdatereservationFrame_jButton1_actionAdapter(UpdatereservationFrame
                                                  adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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