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

📄 fixedfetch.java

📁 一个简单的银行管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO 将在此处添加您的处理代码:
        this.dispose();
        try
        {
            fixedFetch.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
// TODO 将在此处添加您的处理代码:
        accountField.setText("");
        passwordField.setText("");
        nameField.setText("");
        depositField.setText("");
        sumField.setText("");
    }//GEN-LAST:event_resetButtonActionPerformed

    private void commitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commitButtonActionPerformed
// TODO 将在此处添加您的处理代码:
        String accountID = " "+accountField.getText();
        String password = passwordField.getText();
        String depositID = " "+depositField.getText();
        String name = nameField.getText();
        int sum = Integer.parseInt(sumField.getText());
        
        CallableStatement proc = null;
        try
        {
            String sql = "select * from deAccount where accountID = '"+accountID+"' and accountType='TE'";
//          String sql = "select * from deAccount,fixedDeposit where state='EF' and deAccount.accountID = fixedDeposit.accountID and deAccount.accountID = '"+accountID+"' and accountType='TE' and accountPassword='"+password+"'";
            Statement stat = fixedFetch.createStatement();
            ResultSet result = stat.executeQuery(sql);
            if(!result.next())
            {
                JOptionPane.showMessageDialog(null,"您输入的定期帐号不存在,请确认后重新输入!","出错",JOptionPane.ERROR_MESSAGE);
                accountField.setText("");
                passwordField.setText("");
                System.out.println("fasfsfs");
            }
            else
            {
                System.out.println("fasdfsdf");
                String sql1 = "select * from deAccount where accountID = '"+accountID+"' and accountType='TE' and accountPassword='"+password+"'";
                ResultSet result1 = stat.executeQuery(sql1);
                if(!result1.next())
                {
                    JOptionPane.showMessageDialog(null,"您输入的密码不正确,请确认后重新输入!","出错",JOptionPane.ERROR_MESSAGE);
                    passwordField.setText("");
                }
                else
                {
                    String sql2 = "select * from deAccount,fixedDeposit where deAccount.accountID = fixedDeposit.accountID and deAccount.accountID = '"+accountID+"' and accountType='TE' and accountPassword='"+password+"' and depositID='"+depositID+"'";
                    ResultSet result2 = stat.executeQuery(sql2);
                    if(!result2.next())
                    {
                        JOptionPane.showMessageDialog(null,"您输入的定期存款号错误,请确认后重新输入!","出错",JOptionPane.ERROR_MESSAGE);
                        depositField.setText("");
                    }
                    else
                    {
                        String sql3 = "select * from deAccount,fixedDeposit where state='EF' and deAccount.accountID = fixedDeposit.accountID and deAccount.accountID = '"+accountID+"' and accountType='TE' and accountPassword='"+password+"'";
                        ResultSet result3 = stat.executeQuery(sql3);
                        if(!result3.next())
                        {
                            JOptionPane.showMessageDialog(null,"您输入的定期帐号已经被挂失,请确认后重新输入!","出错",JOptionPane.ERROR_MESSAGE);
                            accountField.setText("");
                            passwordField.setText("");
                        }
                        else
                        {
                            String sql4 = "select * from deAccount,fixedDeposit where state='EF' and deAccount.accountID = fixedDeposit.accountID and deAccount.accountID = '"+accountID+"' and accountType='TE' and accountPassword='"+password+"' and fixedSum >"+sum;                     
                            ResultSet result4 = stat.executeQuery(sql4);
                            if(!result4.next())
                            {
                                JOptionPane.showMessageDialog(null,"您输入的帐户余额不足,请确认后重新输入!","出错",JOptionPane.ERROR_MESSAGE);
                               sumField.setText("");
                            }
                            else
                            {
                                proc = fixedFetch.prepareCall("{ call FixedFetchMoney(?,?,?,?,?) }");
                                proc.setString(1, staffID);
                                proc.setString(2, accountID); 
                                proc.setString(3, depositID); 
                                proc.setString(4, name);
                                proc.setInt(5, sum);
                                proc.execute(); 
                                this.dispose();
                                proc.close();
                                fixedFetch.close();
                            }
                        }
                    }
                }
            }
         }
         catch(Exception insertAccountException)
         {
            insertAccountException.printStackTrace();
         }
    }//GEN-LAST:event_commitButtonActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FixedFetch(" 00001").setVisible(true);
            }
        });
    }
    
    //连接数据库操作------------------------------
    private void connectDB()
    {
        String dbUrl = "jdbc:odbc:afei";
        String user = "scott";
        String password = "tiger";
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            fixedFetch = DriverManager.getConnection(dbUrl,user,password);
        }
        catch(Exception connectException)
        {
            connectException.printStackTrace();
        }
    }
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JTextField accountField;
    private javax.swing.JButton cancelButton;
    private javax.swing.JButton commitButton;
    private javax.swing.JTextField depositField;
    private javax.swing.JLabel jLabel1;
    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.JTextField nameField;
    private javax.swing.JPasswordField passwordField;
    private javax.swing.JButton resetButton;
    private javax.swing.JTextField sumField;
    // 变量声明结束//GEN-END:variables
    private Connection fixedFetch;
}

⌨️ 快捷键说明

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