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

📄 admininterface.java

📁 资产管理系统的数据库设计 (一)开发背景 随着我国高等教育事业的迅猛发展
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                author.setText(null);
                publish.setText(null);
                price.setText(null);
                userID.setText(null);
                userName.setText(null);
                Institute.setText(null);
                pastDay.setText(null);
            }
            pt.close();
            ps.close();
            con.close();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
            JOptionPane.showMessageDialog(this,"还书操作失败,请重试!");
            
        }
    }//GEN-LAST:event_jButton2ActionPerformed
    
    private void AckBorrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AckBorrowActionPerformed
// TODO 借书模块:
        this.connect();
        try {
            Connection con = DriverManager.getConnection(conURL);
            PreparedStatement ps = con.prepareStatement("insert into BorrowInfo values(?,?,?,'NULL')");
            String userid = UserID.getText().toString();
            String bookid=BookID.getText().toString();
            Date c1=new Date();
            long m=c1.getTime();
            java.sql.Date date=new java.sql.Date(m);
            // SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            // String date = bartDateFormat.format(c1);
            String ss=date.toString();
            ps.setString(1,userid);
            ps.setString(2,bookid);
            ps.setString(3,ss);
            ps.execute();
            ps.close();
            PreparedStatement s=con.prepareStatement("update BookInfo set Remain=?");
            PreparedStatement st=con.prepareStatement("select Remain from BookInfo where ISBN=(select ISBN from LibBook where BookID=?)");
            st.setString(1,bookid);
            int amout=0;
            ResultSet rs=st.executeQuery();
            while(rs.next()){
                amout=rs.getInt(1);
            }
            rs.close();
            s.setInt(1,amout-1);
            boolean rsborrow=s.execute();
            if(!rsborrow){
                JOptionPane.showMessageDialog(this,"借书成功!");
                UserID.setText(null);
                UserName.setText(null);
                UserInstitute.setText(null);
                BookID.setText(null);
                BookName.setText(null);
                Author.setText(null);
                Publish.setText(null);
            }
            s.close();
            con.close();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
            JOptionPane.showMessageDialog(this,"借书失败,检查人品!");
            
        }
    }//GEN-LAST:event_AckBorrowActionPerformed
    
    private void jLabel18AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jLabel18AncestorAdded
// TODO 将在此处添加您的处理代码:
        
    }//GEN-LAST:event_jLabel18AncestorAdded
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO 将在此处添加您的处理代码:
        //test
        Date d = new Date();
        System.out.println(d);
        SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String formatedDate = bartDateFormat.format(d).toString();
        System.out.println(formatedDate);
    }//GEN-LAST:event_jButton1ActionPerformed
    
    private void enterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enterActionPerformed
        // TODO 注册新用户:
        String id = newUserID.getText().toString();
        String name = newUserName.getText().toString();
        String institute = newUserInstitute.getText().toString();
        String pwd = newUserPwd.getText().toString();
        int gender = newUserGender.getSelectedIndex();
        String realGender;
        if(gender==0)
            realGender = "M";
        else
            realGender = "F";
        boolean adminTest = isAdmin.isSelected();
        int admin = 0;
        if(adminTest == true)
            admin = 1;
        else
            admin = 0;
        
        if((id.toCharArray()).length !=8){//判断借记卡号是否为空
            JOptionPane.showMessageDialog(this,"借记卡卡号不正确");
            return;
        }
        if((name.toCharArray()).length == 0){//判断借记卡号是否为空
            JOptionPane.showMessageDialog(this,"姓名不能为空");
            return;
        }
        if((pwd.toCharArray()).length == 0){
            JOptionPane.showMessageDialog(this,"密码不能为空");
            return;
        }
        
        String JDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
        String conURL = "jdbc:odbc:pejuwe";
        try {
            Class.forName(JDriver);
        } catch (ClassNotFoundException ex) {
            System.out.println("forname:" + ex.getMessage());
        }
        try {
            Connection con = DriverManager.getConnection(conURL);
            Statement s = con.createStatement();
            Date date = new Date();
            SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String regUser = "insert into UserInfo Values('"+id +"', '"+name+"', '"+ realGender+"','"+
                    bartDateFormat.format(date) +"', '"+institute+"')";
            System.out.println(regUser);// System.out.println(s.executeUpdate(regUser));
            String insertUserPwd = "insert into UserPsd Values('" + id + "', '" + pwd + "', " + admin + ")";
            System.out.println(insertUserPwd);
            int rsUser = s.executeUpdate(regUser);
            int rsUserPwd = s.executeUpdate(insertUserPwd);
            if(rsUser==1){
                JOptionPane.showMessageDialog(this,"新用户注册成功");
                newUserID.setText(null);
                newUserName.setText(null);
                newUserInstitute.setText(null);
                isAdmin.setSelected(false);
                newUserPwd.setText(null);
            }
            s.close();
            con.close();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
            if(ex.getErrorCode()==2627)
                JOptionPane.showMessageDialog(this,"此用户ID已存在,用户注册失败!");
            else
                JOptionPane.showMessageDialog(this,ex.getMessage());
        }
    }//GEN-LAST:event_enterActionPerformed
    
    private void returnBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_returnBookActionPerformed
// TODO 将在此处添加您的处理代码:
    }//GEN-LAST:event_returnBookActionPerformed
    
    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
// TODO 将在此处添加您的处理代码:
    }//GEN-LAST:event_jComboBox1ActionPerformed
    
    private void aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutActionPerformed
        // TODO 显示关于:
        JOptionPane.showMessageDialog(this,"网二图书管理系统 v3.9d\n于兴红\n版权所有\n这是试用版,您还有29天试用期,请购买正版!!","关于",2);
    }//GEN-LAST:event_aboutActionPerformed
    
    private void helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpActionPerformed
        // TODO 显示帮助:
        JOptionPane.showMessageDialog(this,"靠!这么简单还要看帮助?!?!","帮助",3);
    }//GEN-LAST:event_helpActionPerformed
    
    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        // TODO 退出:
        this.dispose();
    }//GEN-LAST:event_exitActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AdminInterface().setVisible(true);
                
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton AckBorrow;
    private javax.swing.JTextField Author;
    private javax.swing.JTextField BookID;
    private javax.swing.JTextField BookName;
    private javax.swing.JTextField Institute;
    private javax.swing.JMenuBar MB;
    private javax.swing.JTextField Publish;
    private javax.swing.JTextField UserID;
    private javax.swing.JTextField UserInstitute;
    private javax.swing.JTextField UserName;
    private javax.swing.JMenuItem about;
    private javax.swing.JTextField author;
    private javax.swing.JTextField bookID;
    private javax.swing.JTextField bookName;
    private javax.swing.JPanel brwBookPanel;
    private javax.swing.JLabel companyLabel1;
    private javax.swing.JButton enter;
    private javax.swing.JMenuItem exit;
    private javax.swing.JLabel genderLabel1;
    private javax.swing.JMenuItem help;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JLabel idLabel1;
    private javax.swing.JMenuItem insertBook;
    private javax.swing.JPanel insertPanel;
    private javax.swing.JRadioButton isAdmin;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    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 jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    

⌨️ 快捷键说明

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