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

📄 registerframe.java

📁 酒店管理系统后台数据库存储过程
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            rs = dbo.returnQuery(sql2);
            if (rs.next()) {
                //重新设置折扣价文本框的值
                standPri = rs.getInt(1);
            }
        } catch (SQLException ex1) {
            ex1.printStackTrace();
        }

        int depatePri = 0;
        //计算并设置折扣价
        if (cboDepate.getSelectedItem().toString().equals("全价")) {
            this.txtDebatePri.setText("" + (int) (standPri * 1.0));
        }
        if (cboDepate.getSelectedItem().toString().equals("九折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.9));
        }
        if (cboDepate.getSelectedItem().toString().equals("八折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.8));
        }
        if (cboDepate.getSelectedItem().toString().equals("七折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.7));
        }
        if (cboDepate.getSelectedItem().toString().equals("六折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.6));
        }
        if (cboDepate.getSelectedItem().toString().equals("五折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.5));
        }
        if (cboDepate.getSelectedItem().toString().equals("四折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.4));
        }
        if (cboDepate.getSelectedItem().toString().equals("三折")) {
            this.txtDebatePri.setText("" + (int) (standPri * 0.3));
        }
    }
    //显示时间的方法
    public void showTime() {
        ActionListener al = new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Calendar cal = Calendar.getInstance();
                String showTime = "";
                showTime = "当前时间:" + cal.get(Calendar.YEAR) + "-" +
                           (cal.get(Calendar.MONTH) + 1) + "-" +
                           cal.get(Calendar.DATE);
                showTime += " " + cal.get(Calendar.HOUR) + ":" +
                        cal.get(Calendar.MINUTE) + ":" +
                        cal.get(Calendar.SECOND);
                lblTime.setText(showTime);

//            Date d  = new Date();
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH小时mm分钟ss秒");
//            lblTime.setText(sdf.format(d));
            }
        };
        timer = new Timer(1000, al);
        timer.start();
    }
      //格式化抵店时间
    public String getCheckInTime() {
        Calendar cal = Calendar.getInstance();
        String showTime = "";
        if ((1 + cal.get(Calendar.MONTH)) < 10 && cal.get(Calendar.DATE) > 10) {
            showTime = cal.get(Calendar.YEAR) + "-0" +
                       (1 + cal.get(Calendar.MONTH)) + "-" +
                       cal.get(Calendar.DATE);
        } else if (cal.get(Calendar.DATE) < 10 &&
                   (1 + cal.get(Calendar.MONTH)) > 10) {
            showTime = cal.get(Calendar.YEAR) + "-" +
                       (1 + cal.get(Calendar.MONTH)) + "-0" +
                       cal.get(Calendar.DATE);
        } else if (cal.get(Calendar.DATE) < 10 &&
                   (1 + cal.get(Calendar.MONTH)) < 10) {
            showTime = cal.get(Calendar.YEAR) + "-0" +
                       (1 + cal.get(Calendar.MONTH)) + "-0" +
                       cal.get(Calendar.DATE);
        } else {
            showTime = cal.get(Calendar.YEAR) + "-" +
                       (1 + cal.get(Calendar.MONTH)) + "-" +
                       cal.get(Calendar.DATE);

        }

        return showTime;
    }
     //格式化离店时间
    public String getCheckOutTime() {
        Calendar cal = Calendar.getInstance();
        String showTime = "";

        if ((1 + cal.get(Calendar.MONTH)) < 10 && cal.get(Calendar.DATE) > 10) {
            showTime = cal.get(Calendar.YEAR) + "-0" +
                       (1 + cal.get(Calendar.MONTH)) + "-" +
                       (1 + cal.get(Calendar.DATE));
        } else if (cal.get(Calendar.DATE) < 10 &&
                   (1 + cal.get(Calendar.MONTH)) > 10) {
            showTime = cal.get(Calendar.YEAR) + "-" +
                       (1 + cal.get(Calendar.MONTH)) + "-0" +
                       (1 + cal.get(Calendar.DATE));
        } else if (cal.get(Calendar.DATE) < 10 &&
                   (1 + cal.get(Calendar.MONTH)) < 10) {
            showTime = cal.get(Calendar.YEAR) + "-0" +
                       (1 + cal.get(Calendar.MONTH)) + "-0" +
                       (1 + cal.get(Calendar.DATE));
        } else {
            showTime = cal.get(Calendar.YEAR) + "-" +
                       (1 + cal.get(Calendar.MONTH)) + "-" +
                       (cal.get(Calendar.DATE) + 1);
        }
        return showTime;
    }
    //计算住店天数,和费用
    public void btnComput_actionPerformed(ActionEvent e) {

        if( this.txtName.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this,"姓名不能为空!!请重新输入!","提示",JOptionPane.INFORMATION_MESSAGE);
            return;
         }
        if(this.txtIDNo.getText().equals(""))
        {JOptionPane.showMessageDialog(this,"证件号不能为空!!请重新输入!","提示",JOptionPane.INFORMATION_MESSAGE);
            return;
        }

     //   this.txtAccountNo.setText("" + accountNo);
        String inTime = this.txtCheckIn.getText();
        String outTime = this.txtCheckOut.getText();

       // System.out.println(outTime.charAt(4) + "\n" + outTime.charAt(7));
        if ((outTime.indexOf('-',0)!=4)||(outTime.indexOf('-',5)!=7)) {
            JOptionPane.showMessageDialog(this, "日期格式错误!请重新输入!!\n格式<yyyy-mm-dd>", "提示",
                                          JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        if (outTime.length()!=10)
        {
           JOptionPane.showMessageDialog(this, "日期格式错误!请重新输入!!", "提示",
                                         JOptionPane.INFORMATION_MESSAGE);
           return;
       }


        int total = 0;
        int livdays = 0;
        int price = Integer.parseInt(txtDebatePri.getText());
        livdays = getDays(inTime,outTime);
        if(livdays==0)
        {
            return;
        }
        //计算总的金额
        total = livdays * price + Integer.parseInt(this.txtDeposit.getText());

        String info = "入住天数:"+livdays+"天\n"+"总额为(包括押金)"+total;
        JOptionPane.showMessageDialog(this,info,"提示",JOptionPane.INFORMATION_MESSAGE);
        //计算费用
        this.txtTotal.setText("" + total);
        this.btnConfri.setEnabled(true);
    }

     //计算入住天数的方法
    public int getDays(String inTime,String outTime)
    {
        //从字符串形式的日期获取年,月,日,小时,分
        int beginYear = Integer.parseInt(inTime.substring(0, 4));
        int beginMonth = Integer.parseInt(inTime.substring(5, 7));
        int beginDay = Integer.parseInt(inTime.substring(8, 10));

        int endYear = Integer.parseInt(outTime.substring(0, 4));
        int endMonth = Integer.parseInt(outTime.substring(5, 7));
        int endDay = Integer.parseInt(outTime.substring(8, 10));
        // 当前时间大于离店时间的情况
        if ((endYear == beginYear) &&
            (endMonth < beginMonth )) {
            JOptionPane.showMessageDialog(this, "离店时间不能小于当前时间!\n请重新输入!!", "提示",
                                          JOptionPane.INFORMATION_MESSAGE);
            return 0;
        }

        //如果年份离店年份小于当前年份的情况
        if (endYear < beginYear) {
            JOptionPane.showMessageDialog(this, "离店时间不能小于当前时间!\n请重新输入!!", "提示",
                                          JOptionPane.INFORMATION_MESSAGE);
            return 0;
        }
        //日期的格式不正确
        if (endMonth <= 0 || endMonth > 12 || endDay < 0 || endDay > 31) {
            JOptionPane.showMessageDialog(this, "离点店日期输入有误!\n请重新输入!!", "提示",
                                          JOptionPane.INFORMATION_MESSAGE);
            return 0;
        }
        //计算入住时间 ,以天为单位
        int livdays = 0;

        livdays = ((beginYear - endYear) * 365 * 30 +
                   (endMonth - beginMonth) * 30 +
                   (endDay - beginDay));

        if(livdays<0)
        {
//         JOptionPane.showMessageDialog(this, "离点店日期输入有误!\n请重新输入!!", "提示",
//                                          JOptionPane.INFORMATION_MESSAGE);
            return 0;
        }
      return livdays;
    }



}




class RegisterFrame_btnComput_actionAdapter implements ActionListener {
    private RegisterFrame adaptee;
    RegisterFrame_btnComput_actionAdapter(RegisterFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class RegisterFrame_cboDepate_itemAdapter implements ItemListener {
    private RegisterFrame adaptee;
    RegisterFrame_cboDepate_itemAdapter(RegisterFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void itemStateChanged(ItemEvent e) {
        adaptee.cboDepate_itemStateChanged(e);
    }
}


class RegisterFrame_cboRoomType_itemAdapter implements ItemListener {
    private RegisterFrame adaptee;
    RegisterFrame_cboRoomType_itemAdapter(RegisterFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void itemStateChanged(ItemEvent e) {
        adaptee.cboRoomType_itemStateChanged(e);
    }
}


class RegisterFrame_btnBack_actionAdapter implements ActionListener {
    private RegisterFrame adaptee;
    RegisterFrame_btnBack_actionAdapter(RegisterFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class RegisterFrame_btnConfri_actionAdapter implements ActionListener {
    private RegisterFrame adaptee;
    RegisterFrame_btnConfri_actionAdapter(RegisterFrame adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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