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

📄 recorddome.java

📁 机房网吧刷卡计费
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            gen.add(Cha);
        DefaultMutableTreeNode Cha1 = new DefaultMutableTreeNode("查询全部消费信息");
            gen.add(Cha1);
        jPanel1.add(jPanel6, "jPanel6");
        jPanel6.add(txtKID);
        jPanel6.add(txtCID);
        jPanel6.add(txtETime);
        jPanel6.add(txtYu);
        jPanel6.add(txtSTime);
        jPanel6.add(jLabel14);
        jPanel6.add(jLabel15);
        jPanel6.add(jLabel16);
        jPanel6.add(jLabel17);
        jPanel6.add(jLabel18);
        jPanel6.add(jPanel7);
        jPanel6.add(btnRTui);
        jPanel7.add(jButton8);
        jPanel7.add(jButton7);
        jPanel7.add(jButton9);
        jPanel7.add(jButton4);
        jTree1.expandRow(0);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        this.setLocation((screenSize.width - frameSize.width) / 2,
                     (screenSize.height - frameSize.height) / 2);
    }

    public void btnTian_actionPerformed(ActionEvent e) {

        //接收用户输入新学员信息
        String CardID =(String) txtCardID.getText();
       String ComputerID = (String)txtJQID.getText() ;

        Date a=new Date();
         DateFormat df;
         df = DateFormat.getDateTimeInstance();
         String bs=df.format(a);
         int as =Integer.parseInt(txtTime.getText());
             Calendar cd =Calendar.getInstance();
             cd.add(Calendar.HOUR,as);
             Date td = cd.getTime();
             String xia=df.format(td);
             if (CardID.length() == 0 ||ComputerID.length()==0||as==0) {
                       javax.swing.JOptionPane.showMessageDialog(this,
                               "卡ID和机器ID不能为空,上机时间不能为0!");
                       return;
                }
           else  if(!CardID.startsWith("C"))
    {javax.swing.JOptionPane.showMessageDialog(this,
             "卡ID不符合约束!");
                 return;
                }
            else   if(!ComputerID.startsWith("G"))
            {javax.swing.JOptionPane.showMessageDialog(this,
                        "机器ID不符合约束!");
                return;
            }
else{
       Card stu1 = new Card();
       //接收用户输入要查找的学员姓名.
             stu1.setId(CardID);
       //调用业务类方法,返回集合类对象.
           ArrayList arr = CardBusiness.select(stu1);
           for (int i = 0; i < arr.size(); i++) {
                       stu1 = (Card) arr.get(i);
                }
        double tall =stu1.getBalance();





        //验证笔试和机试是否是0到100之间的一个数字
        //if (xHao!="Guest[0-9][0-9][0-9]")
           // throw new Exception();


        //如果验证通过,实例华一个学员对象,并设置学员对象的属性
       Record temp = new Record();
        temp.setCardId(CardID);
        temp.setComputerId(ComputerID);
        temp.setBeginTime(bs);
        temp.setEndTime(xia);
        temp.setBalance(tall);
        RecordBuiness.insert(temp);
                javax.swing.JOptionPane.showMessageDialog(this,
            "添加成功!");
    this.txtCardID.setText("");
this.txtJQID.setText("");
 this.txtTime.setText("");

  this.txtCardID.requestFocus();

}
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        String id =(String)txtCardId.getText();
    if(!id.startsWith("C"))
       {javax.swing.JOptionPane.showMessageDialog(this,
             "卡ID不符合约束!");
                 return;
                }
else{
                            //把学号封装到一个实体类对象中,用来在不同层传递数据
                           Record stu = new Record();
                            stu.setCardId(id);

                            //删除
                          RecordBuiness.delete(stu);
                                javax.swing.JOptionPane.showMessageDialog(this,
                        "删除成功!");}
    }

    public void jTree1_valueChanged(TreeSelectionEvent e) {
        DefaultMutableTreeNode temp = (DefaultMutableTreeNode) jTree1.
                                         getLastSelectedPathComponent();
           //得到选中的节点名称
           String name=temp.toString();

           //根据选择的不同显示卡式布局中的卡片
           if (name.equals("添加消费信息")){
               this.cardLayout1.show(this.jPanel1, "jPanel2");
           }else if(name.equals("删除消费信息")){
               this.cardLayout1.show(this.jPanel1, "jPanel3");
           }else if(name.equals("修改消费信息")){
               this.cardLayout1.show(this.jPanel1, "jPanel4");
           }else if(name.equals("条件查询消费信息")){
               this.cardLayout1.show(this.jPanel1, "jPanel5");
           }else if(name.equals("查询全部消费信息")){
               this.cardLayout1.show(this.jPanel1, "jPanel6");
      }
    }

    public void txtXID_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
                {
                           txtQID.requestFocus();
            }
    }

    public void txtQID_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
          {
            txtShang.requestFocus();
            }
    }

    public void txtShang_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
          {
           btnXiou.requestFocus();
            }
    }

    public void txtCardID_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
        {
          txtJQID.requestFocus();
            }
    }

    public void txtJQID_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
                                       {
                                                 txtTime.requestFocus();
            }
    }

    public void txtTime_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
         {
          btnTian.requestFocus();
            }
    }

    public void btnXiou_actionPerformed(ActionEvent e) {
        String CardID =(String) txtXID.getText();
          String ComputerID = (String)txtQID.getText() ;

           Date a=new Date();
            DateFormat df;
            df = DateFormat.getDateTimeInstance();
            String bs=df.format(a);
            int as =Integer.parseInt(txtShang.getText());
                Calendar cd =Calendar.getInstance();
                cd.add(Calendar.HOUR,as);
                Date td = cd.getTime();
                String xia=df.format(td);
           if (CardID.length() == 0 ||ComputerID.length()==0||as==0) {
                                 javax.swing.JOptionPane.showMessageDialog(this,
                                         "卡ID和机器ID不能为空,上机时间不能为0!");
                                 return;
                             }   else  if(!CardID.startsWith("C"))
       {javax.swing.JOptionPane.showMessageDialog(this,
                "卡ID不符合约束!");
                    return;
                   }
               else   if(!ComputerID.startsWith("G"))
               {javax.swing.JOptionPane.showMessageDialog(this,
                           "机器ID不符合约束!");
                   return;
               }

else{
          Card stu1 = new Card();
          //接收用户输入要查找的学员姓名.
                stu1.setId(CardID);
          //调用业务类方法,返回集合类对象.
              ArrayList arr = CardBusiness.select(stu1);
              for (int i = 0; i < arr.size(); i++) {
                          stu1 = (Card) arr.get(i);
                   }
           double tall =stu1.getBalance();





           //验证笔试和机试是否是0到100之间的一个数字
           //if (xHao!="Guest[0-9][0-9][0-9]")
              // throw new Exception();


           //如果验证通过,实例华一个学员对象,并设置学员对象的属性
          Record temp = new Record();
           temp.setCardId(CardID);
           temp.setComputerId(ComputerID);
           temp.setBeginTime(bs);
           temp.setEndTime(xia);
        temp.setBalance(tall);
        RecordBuiness.update(temp);
                 javax.swing.JOptionPane.showMessageDialog(this,
             "修改成功!");
}
    }

    public void txtCardid_keyPressed(KeyEvent e) {
        if(e.getKeyCode()==KeyEvent.VK_ENTER)
                {
                 btnCha.requestFocus();
            }
    }

    public void btnCha_actionPerformed(ActionEvent e) {
        Record stu = new Record();
                         //接收用户输入要查找的会员ID号.
              String xingMing =(String) txtCardid.getText();
              //把学员姓名封装到一个实体类对象中,用来在不同层传递数据。
              if(!xingMing.startsWith("C"))
       {javax.swing.JOptionPane.showMessageDialog(this,
             "卡ID不符合约束!");
                 return;
                }

                stu.setCardId(xingMing);

                         //调用业务类方法,返回集合类对象.
               ArrayList arr = RecordBuiness.select(stu);

                         //如果没有任何学员纪录
                         if (arr.isEmpty())
                         {javax.swing.JOptionPane.showMessageDialog(this,
         "卡ID不符合约束!");
            return;
            }

                         else {
                             //循环显示集合类中每个学员的信息
                             System.out.println("\n一共"+arr.size()+"消费记录的信息如下:");
                             for (int i = 0; i < arr.size(); i++) {
                                 stu = (Record) arr.get(i);

                          txtComputerid.setText(stu.getComputerId());
                             txtStartTime.setText( stu.getBeginTime());
                         txtEndTime.setText(stu.getEndTime());
                          txtYuE.setText( ""+ stu.getBalance());
                            }
                   }
    }

    public void jButton8_actionPerformed(ActionEvent e) {

                       weiZhi = 0;
                  Record stu = new Record();
                   stu = (Record) brr.get(weiZhi);
                      //设计界面文本框中的值
                      this.txtKID.setText(stu.getCardId());
                      this.txtCID.setText(stu.getComputerId());
                   this.txtSTime.setText( stu.getBeginTime());
                this.txtETime.setText(stu.getEndTime());
                   this.txtYu.setText("" + stu.getBalance());
    }

    public void jButton7_actionPerformed(ActionEvent e) {


        weiZhi--;

⌨️ 快捷键说明

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