reportpanel.java~36~

来自「银行信用评估系统」· JAVA~36~ 代码 · 共 245 行

JAVA~36~
245
字号
package management;

import java.awt.*;
import javax.swing.*;
import java.sql.*;
import com.borland.dx.dataset.*;
import com.borland.jbcl.layout.*;
import com.borland.dx.sql.dataset.*;
import java.awt.event.*;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class reportPanel extends JPanel {
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JPasswordField jPasswordField1 = new JPasswordField();
  JPasswordField jPasswordField2 = new JPasswordField();
  JLabel jLabel3 = new JLabel();
  JPasswordField jPasswordField3 = new JPasswordField();
  JLabel jLabel4 = new JLabel();
  JPasswordField jPasswordField4 = new JPasswordField();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();
  JLabel jLabel5 = new JLabel();
  JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
  Database database1 = new Database();
  QueryDataSet queryDataSet1 = new QueryDataSet();
  QueryResolver queryResolver1 = new QueryResolver();

  PreparedStatement pstmt;
  Connection con;
  String query;
  ResultSet rs;
  String str;
  String strx;

  public reportPanel() {
    try {
      jbInit();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }
  public reportPanel(String strx1) {
  strx=strx1;
    try {
    jbInit();
  }
  catch(Exception ex) {
    ex.printStackTrace();
  }
}

  void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 22));
    jLabel1.setText(" 旧 密 码:");
    jLabel1.setBounds(new Rectangle(12, 94, 127, 24));
    this.setLayout(null);
    this.setBackground(Color.lightGray);
    this.setDebugGraphicsOptions(0);
    this.setMaximumSize(new Dimension(2147483647, 2147483647));
    jLabel2.setFont(new java.awt.Font("Dialog", 1, 22));
    jLabel2.setText("确认旧密码:");
    jLabel2.setBounds(new Rectangle(19, 144, 148, 20));
    jPasswordField1.setText("");
    jPasswordField1.setBounds(new Rectangle(189, 90, 214, 26));
    jPasswordField2.setText("");
    jPasswordField2.setBounds(new Rectangle(190, 144, 213, 25));
    jLabel3.setFont(new java.awt.Font("Dialog", 1, 22));
    jLabel3.setText("新密码:");
    jLabel3.setBounds(new Rectangle(18, 198, 124, 22));
    jPasswordField3.setText("");
    jPasswordField3.setBounds(new Rectangle(191, 198, 210, 27));
    jLabel4.setFont(new java.awt.Font("Dialog", 1, 22));
    jLabel4.setText("确认新密码:");
    jLabel4.setBounds(new Rectangle(19, 252, 151, 26));
    jPasswordField4.setSelectionStart(15);
    jPasswordField4.setText("");
    jPasswordField4.setBounds(new Rectangle(192, 255, 209, 27));
    jButton1.setBounds(new Rectangle(215, 307, 97, 31));
    jButton1.setFont(new java.awt.Font("Dialog", 1, 18));
    jButton1.setText("修改");
    jButton1.addActionListener(new reportPanel_jButton1_actionAdapter(this));
    jButton2.setBounds(new Rectangle(421, 144, 96, 26));
    jButton2.setText("重置旧密码");
    jButton2.addActionListener(new reportPanel_jButton2_actionAdapter(this));
    jButton3.setBounds(new Rectangle(422, 255, 95, 27));
    jButton3.setText("重置新密码");
    jButton3.addActionListener(new reportPanel_jButton3_actionAdapter(this));
    jLabel5.setFont(new java.awt.Font("Dialog", 1, 40));
    jLabel5.setText("    学 生 密 码 管 理");
    jLabel5.setBounds(new Rectangle(54, 8, 396, 52));
    jLabel6.setFont(new java.awt.Font("Dialog", 1, 15));
    jLabel6.setText("");
    jLabel6.setBounds(new Rectangle(26, 367, 480, 64));
    jLabel7.setFont(new java.awt.Font("Dialog", 1, 22));
    jLabel7.setText("操作:");
    jLabel7.setBounds(new Rectangle(18, 304, 134, 28));
    this.add(jLabel5, null);
    this.add(jLabel6, null);
    this.add(jLabel4, null);
    this.add(jLabel2, null);
    this.add(jPasswordField2, null);
    this.add(jLabel1, null);
    this.add(jLabel3, null);
    this.add(jPasswordField3, null);
    this.add(jPasswordField1, null);
    this.add(jPasswordField4, null);
    this.add(jButton3, null);
    this.add(jButton2, null);
    this.add(jLabel7, null);
    this.add(jButton1, null);

    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student";
    String username= "sa";
    String password= "lomf8244";
    con = DriverManager.getConnection(url,username,password);

    jLabel6.setText(strx);
  }

  void jButton1_actionPerformed(ActionEvent e) {
    String str1=null;
    String str2=null;
    String str3=null;
    String str4=null;

    for(int i=0;i<jPasswordField1.getPassword().length;i++)
      str1+=jPasswordField1.getPassword()[i];
      str1=str1.substring(4);
    for(int i=0;i<jPasswordField2.getPassword().length;i++)
      str2+=jPasswordField2.getPassword()[i];
      str2=str2.substring(4);
    for(int i=0;i<jPasswordField3.getPassword().length;i++)
      str3+=jPasswordField3.getPassword()[i];
      str3=str3.substring(4);
    for(int i=0;i<jPasswordField4.getPassword().length;i++)
      str4+=jPasswordField4.getPassword()[i];
      str4=str4.substring(4);
    if(str1.equals(str2))
    {
       try{
         query = "select * from usercheck where STUDENTNO=?";
         pstmt = con.prepareStatement(query);
         pstmt.setString(1,strx);
          rs=pstmt.executeQuery();
           if(rs.next()){
              str = rs.getString("PASSWORDS");

              if(str1.equals(str))
               {
                  if(str3.equals(str4))
                  {
                    //更新密码;
                    jLabel6.setText("更新密码成功");
                    query = "update usercheck set PASSWORDS="+ "\'"+str3+ "\'"+"where STUDENTNO=?";
                    pstmt = con.prepareStatement(query);
                    pstmt.setString(1,strx);
                   rs=pstmt.executeQuery();

                  }
                 else
                  { jLabel6.setText("新密码不匹配,请重新输入");
                   jPasswordField3.setText("");
                   jPasswordField4.setText("");
                  }
                }

              else
              {
                  jLabel6.setText("旧密码输入错误,请重新输入");
                   jPasswordField1.setText("");
                   jPasswordField2.setText("");
              }
           }
           else
             jLabel6.setText("没有匹配项!");
       }
       catch(Exception ep)
       {
       }
    }
    else
    {
     jLabel6.setText("旧密码不匹配,请重新输入");
     jPasswordField1.setText("");
     jPasswordField2.setText("");
     }
 }

  void jButton2_actionPerformed(ActionEvent e) {
    jPasswordField1.setText("");
     jPasswordField2.setText("");
  }

  void jButton3_actionPerformed(ActionEvent e) {
    jPasswordField3.setText("");
    jPasswordField4.setText("");
  }
}

class reportPanel_jButton1_actionAdapter implements java.awt.event.ActionListener {
  reportPanel adaptee;

  reportPanel_jButton1_actionAdapter(reportPanel adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}

class reportPanel_jButton2_actionAdapter implements java.awt.event.ActionListener {
  reportPanel adaptee;

  reportPanel_jButton2_actionAdapter(reportPanel adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton2_actionPerformed(e);
  }
}

class reportPanel_jButton3_actionAdapter implements java.awt.event.ActionListener {
  reportPanel adaptee;

  reportPanel_jButton3_actionAdapter(reportPanel adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton3_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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