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

📄 main.java

📁 网吧计费系统,很强大的功能 大家可以下载下来
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(81, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(27, 27, 27)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel10)
                    .add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel11)
                    .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel12)
                    .add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel13)
                    .add(jTextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel14)
                    .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(24, 24, 24)
                .add(jButton5)
                .addContainerGap(45, Short.MAX_VALUE))
        );
        getContentPane().add(jPanel4, "card5");

        jMenu1.setText("\u4f7f\u7528");
        jMenuItem1.setText("\u4e0a\u673a");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });

        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("\u4e0b\u673a");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });

        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("\u5e2e\u52a9");
        jMenuItem3.setText("\u5e2e\u52a9");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });

        jMenu2.add(jMenuItem3);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("\u9000\u51fa");
        jMenuItem4.setText("\u9000\u51fa");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });

        jMenu3.add(jMenuItem4);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
// 结算清单关闭事件
        jPanel1.setVisible(true);
        jPanel4.setVisible(false);
        jPanel2.setVisible(false);
        jPanel3.setVisible(false);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// 下机操作事件
        String computerid = jTextField1.getText();
        String computeronuse = "1";
        String sqlcomputerid = null;
        String sqlcomputeronuse = null;
        String sqlcardid = null;
        String begintime = null;
        String endtime = getDate();
        int balance = 0;
        int fee = 0;
        String sql1 = "select id,onuse from computer where id = "+computerid;
        String sql2 = "select cardid,begintime from record where endtime is null and computerid = "+computerid;
        String sql3 = "update computer set onuse = '0' where id = "+computerid;
        SQLClass sql = new SQLClass();
        ResultSet computer_rs = sql.SQL(sql1);
        ResultSet record_rs = sql.SQL(sql2);
        try {
            while (computer_rs.next()) {
                sqlcomputerid = computer_rs.getString(1);
                sqlcomputeronuse = computer_rs.getString(2);
            }
            while (record_rs.next()) {
                sqlcardid = record_rs.getString(1);
                begintime = record_rs.getString(2);
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        if (computerid.equals(sqlcomputerid) && computeronuse.equals(sqlcomputeronuse)) {
            sql.sql(sql3);
            fee = calFee(begintime,endtime);
            sql.sql("update record set endtime = '"+endtime+"',fee = '"+fee+"' where computerid = '"+computerid+"' and endtime is null");
            ResultSet card_rs = sql.SQL("select balance from card where id = "+sqlcardid);
            try {
                while (card_rs.next()) {
                    balance = Integer.valueOf(card_rs.getString(1))-Integer.valueOf(fee);
                }
            } catch (NumberFormatException ex) {
                ex.printStackTrace();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
            sql.sql("update card set balance = '"+balance+"' where id = "+sqlcardid);
            JOptionPane.showMessageDialog(this,"下机成功!");
            jTextField3.setText(sqlcardid);
            jTextField7.setText(computerid);
            jTextField8.setText(begintime.substring(0,19));
            jTextField9.setText(endtime);
            jTextField10.setText(String.valueOf(fee));
            jTextField11.setText(String.valueOf(balance));
            jPanel1.setVisible(false);
            jPanel4.setVisible(true);
            jPanel2.setVisible(false);
            jPanel3.setVisible(false);
        } else {
            JOptionPane.showMessageDialog(this,"下机失败!");
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// 下机重置事件
        jTextField2.setText(getDate());
        jTextField1.setText("");
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// 上机重置事件
        jTextField4.setText("");
        jTextField5.setText("");
        jPasswordField2.setText("");
        jTextField6.setText(getDate());      
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// 上机操作事件
        String cardid = jTextField5.getText();
        String password = new String(this.jPasswordField2.getPassword());
        String computerid = jTextField4.getText();
        String computeronuse = "0";
        String sqlcardid = null;
        String sqlpassword = null;
        String sqlcomputerid = null;
        String sqlcomputeronuse = null;
        String sql1 = "select id,password from card where id = "+cardid;
        String sql2 = "select id,onuse from computer where id = "+computerid;
        String sql3 = "update computer set onuse = '1' where id = "+computerid;
        String sql4 = "insert into record(cardid,computerid,begintime) values ('"+cardid+"','"+computerid+"','"+getDate()+"')";
        SQLClass sql = new SQLClass();
        ResultSet card_rs = sql.SQL(sql1);
        ResultSet computer_rs = sql.SQL(sql2);
        try {
            while (card_rs.next()) {
                sqlcardid = card_rs.getString(1);
                sqlpassword = card_rs.getString(2);
            }
            while (computer_rs.next()) {
                sqlcomputerid = computer_rs.getString(1);
                sqlcomputeronuse = computer_rs.getString(2); 
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        if (cardid.equals(sqlcardid) && password.equals(sqlpassword) && computerid.equals(sqlcomputerid) && computeronuse.equals(sqlcomputeronuse)) {
            sql.sql(sql3);
            sql.sql(sql4);
            JOptionPane.showMessageDialog(this,"上机成功!");
            jPanel1.setVisible(true);
            jPanel4.setVisible(false);
            jPanel2.setVisible(false);
            jPanel3.setVisible(false);
        } else {
            JOptionPane.showMessageDialog(this,"上机失败!");
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
// 显示下机窗体并显示下机时间
        jTextField2.setText(getDate());
        jPanel1.setVisible(false);
        jPanel2.setVisible(false);
        jPanel3.setVisible(true);
        jPanel4.setVisible(false);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// 显示上机窗体并显示上机时间
        jTextField6.setText(getDate());
        jPanel1.setVisible(false);
        jPanel2.setVisible(true);
        jPanel3.setVisible(false);
        jPanel4.setVisible(false);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// 显示帮助窗体
        Help help = new Help(this,true);
        help.setLocationRelativeTo(null);
        help.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
// 退出程序
        System.exit(0);
    }//GEN-LAST:event_jMenuItem4ActionPerformed
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Main m = new Main();
                m.setLocationRelativeTo(null);
                m.setVisible(true);
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    // 变量声明结束//GEN-END:variables
 
}

⌨️ 快捷键说明

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