📄 accountservice.java
字号:
package com.vbank.operate;
import com.vbank.db.*;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.border.SoftBevelBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JCheckBox;
import java.awt.Point;
import javax.swing.JButton;
import javax.swing.border.BevelBorder;
public class AccountService extends JPanel {
private static final long serialVersionUID = 1L;
private JPanel jPanel = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JLabel jLabel1 = null;
private JPasswordField jPasswordField = null;
private JPanel jPanel1 = null;
private JPanel jPanel2 = null;
private JCheckBox jCheckBox = null;
private JLabel jLabel2 = null;
private JCheckBox jCheckBox1 = null;
private JLabel jLabel3 = null;
private JLabel jLabel4 = null;
private JCheckBox jCheckBox2 = null;
private JPanel jPanel3 = null;
private JButton jButton = null;
private JLabel jLabel5 = null;
private JPasswordField jPasswordField1 = null;
private JPanel jPanel4 = null;
private JLabel jLabel6 = null;
private JPasswordField jPasswordField2 = null;
private JLabel jLabel7 = null;
private JPasswordField jPasswordField3 = null;
private JLabel jLabel8 = null;
private JPasswordField jPasswordField4 = null;
private JButton jButton1 = null;
private JButton jButton2 = null;
/**
* This is the default constructor
*/
public AccountService() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(460, 368);
this.setLayout(null);
this.setBorder(BorderFactory.createTitledBorder(null, "\u5e10\u6237\u7ba1\u7406", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, new Font("\u5b8b\u4f53", Font.PLAIN, 12), Color.black));
this.add(getJPanel(), null);
this.add(getJPanel1(), null);
this.add(getJPanel2(), null);
this.add(getJPanel3(), null);
this.add(getJPanel4(), null);
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(54, 85, 66, 25));
jLabel6.setText("确认密码:");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(55, 53, 68, 22));
jLabel5.setText("新密码:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(57, 24, 64, 23));
jLabel1.setText("旧密码:");
jLabel = new JLabel();
jLabel.setText("帐号:");
jLabel.setBounds(new Rectangle(67, 16, 57, 22));
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(8, 76, 448, 124));
jPanel.setBorder(BorderFactory.createTitledBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED), "\u8bbe\u7f6e\u5e10\u53f7\u5bc6\u7801", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, new Font("\u5b8b\u4f53", Font.PLAIN, 14), Color.red));
jPanel.add(jLabel1, null);
jPanel.add(getJPasswordField(), null);
jPanel.add(jLabel5, null);
jPanel.add(getJPasswordField1(), null);
jPanel.add(jLabel6, null);
jPanel.add(getJPasswordField2(), null);
}
return jPanel;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(130, 9, 181, 29));
}
return jTextField;
}
/**
* This method initializes jPasswordField
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(124, 23, 182, 26));
}
return jPasswordField;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(60, 53, 83, 26));
jLabel8.setText("确认密码:");
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(61, 22, 81, 28));
jLabel7.setText("借记卡密码:");
jPanel1 = new JPanel();
jPanel1.setLayout(null);
jPanel1.setBounds(new Rectangle(6, 199, 444, 82));
jPanel1.setBorder(BorderFactory.createTitledBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED), "\u501f\u8bb0\u5361\u7ba1\u7406", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, new Font("\u5b8b\u4f53", Font.PLAIN, 14), Color.red));
jPanel1.add(jLabel7, null);
jPanel1.add(getJPasswordField3(), null);
jPanel1.add(jLabel8, null);
jPanel1.add(getJPasswordField4(), null);
}
return jPanel1;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jLabel4 = new JLabel();
jLabel4.setText("取消帐号");
jLabel4.setLocation(new Point(320, 15));
jLabel4.setSize(new Dimension(61, 22));
jLabel3 = new JLabel();
jLabel3.setText("借记卡挂失");
jLabel3.setLocation(new Point(191, 9));
jLabel3.setSize(new Dimension(72, 27));
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(73, 14, 62, 22));
jLabel2.setText("帐号挂失");
jPanel2 = new JPanel();
jPanel2.setLayout(null);
jPanel2.setBounds(new Rectangle(5, 282, 449, 42));
jPanel2.setBorder(BorderFactory.createTitledBorder(null, "\u6302\u5931", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, new Font("\u5b8b\u4f53", Font.PLAIN, 12), Color.red));
jPanel2.add(getJCheckBox(), null);
jPanel2.add(jLabel2, null);
jPanel2.add(getJCheckBox1(), null);
jPanel2.add(jLabel3, null);
jPanel2.add(jLabel4, null);
jPanel2.add(getJCheckBox2(), null);
}
return jPanel2;
}
/**
* This method initializes jCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox() {
if (jCheckBox == null) {
jCheckBox = new JCheckBox();
jCheckBox.setBounds(new Rectangle(45, 17, 21, 21));
}
return jCheckBox;
}
/**
* This method initializes jCheckBox1
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox1() {
if (jCheckBox1 == null) {
jCheckBox1 = new JCheckBox();
jCheckBox1.setBounds(new Rectangle(166, 17, 21, 21));
}
return jCheckBox1;
}
/**
* This method initializes jCheckBox2
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox2() {
if (jCheckBox2 == null) {
jCheckBox2 = new JCheckBox();
jCheckBox2.setSize(new Dimension(21, 21));
jCheckBox2.setLocation(new Point(290, 15));
}
return jCheckBox2;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
jPanel3 = new JPanel();
jPanel3.setLayout(null);
jPanel3.setBounds(new Rectangle(5, 325, 450, 36));
jPanel3.add(getJButton(), null);
jPanel3.add(getJButton1(), null);
jPanel3.add(getJButton2(), null);
}
return jPanel3;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(24, 2, 109, 29));
jButton.setText("帐号密码设置");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
verifyUser();
}
});
}
return jButton;
}
/**
*
*/
private void verifyUser() {
String account=jTextField.getText().trim();
String op="";
String np1="";
String np2="";
int i;
for( i=0;i<jPasswordField.getPassword().length;i++) {
op+=jPasswordField.getPassword()[i];
}
String str="select * from account where accountNum='"+
account+"' and accountPwd='"+op+"'";
DBManager.getConnection();
i=DBManager.executeQuery(str);
if(i!=0) {
JOptionPane.showMessageDialog(this, "alert", "alert", JOptionPane.ERROR_MESSAGE);
}else {
for( i=0;i<jPasswordField1.getPassword().length;i++) {
np1+=jPasswordField1.getPassword()[i];
}
for( i=0;i<jPasswordField2.getPassword().length;i++) {
np2+=jPasswordField2.getPassword()[i];
}
if(!np1.equals(np2)) {
JOptionPane.showConfirmDialog(this,
"两次密码不一样", "确认密码", JOptionPane.YES_NO_OPTION);
}else {
String sql="update account set ACCOUNTPWD='"+np1+"' where accountNum='"+account+"'";
DBManager.getConnection();
DBManager.execUpdate(sql);
DBManager.releaseCon();
}
}
}
/**
* This method initializes jPasswordField1
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField1() {
if (jPasswordField1 == null) {
jPasswordField1 = new JPasswordField();
jPasswordField1.setBounds(new Rectangle(123, 52, 183, 25));
}
return jPasswordField1;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel4() {
if (jPanel4 == null) {
TitledBorder titledBorder = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED), "\u8f93\u5165\u5e10\u53f7", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.PLAIN, 14), Color.red);
titledBorder.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
jPanel4 = new JPanel();
jPanel4.setLayout(null);
jPanel4.setBounds(new Rectangle(5, 23, 447, 48));
jPanel4.setBorder(titledBorder);
jPanel4.add(jLabel, null);
jPanel4.add(getJTextField(), null);
}
return jPanel4;
}
/**
* This method initializes jPasswordField2
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField2() {
if (jPasswordField2 == null) {
jPasswordField2 = new JPasswordField();
jPasswordField2.setBounds(new Rectangle(123, 85, 185, 24));
}
return jPasswordField2;
}
/**
* This method initializes jPasswordField3
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField3() {
if (jPasswordField3 == null) {
jPasswordField3 = new JPasswordField();
jPasswordField3.setBounds(new Rectangle(144, 18, 163, 28));
}
return jPasswordField3;
}
/**
* This method initializes jPasswordField4
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField4() {
if (jPasswordField4 == null) {
jPasswordField4 = new JPasswordField();
jPasswordField4.setBounds(new Rectangle(144, 49, 164, 29));
}
return jPasswordField4;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(162, -1, 120, 34));
jButton1.setText("借记卡密码设置");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
String account=jTextField.getText().trim();
String pwd1="";
for(int i=0;i<jPasswordField3.getPassword().length;i++) {
pwd1+=jPasswordField3.getPassword()[i];
}
String pwd2="";
for(int i=0;i<jPasswordField4.getPassword().length;i++) {
pwd1+=jPasswordField4.getPassword()[i];
}
if(!pwd1.equals(pwd2)) {
JOptionPane.showConfirmDialog(null,
"两次密码不一样", "确认密码", JOptionPane.YES_NO_OPTION);
}else {
String sql="update account set BANKCARDPWD='"+pwd1+"' where accountNum='"+account+"'";
DBManager.getConnection();
DBManager.execUpdate(sql);
DBManager.releaseCon();
}
}
});
}
return jButton1;
}
/**
* This method initializes jButton2
*
* @return javax.swing.JButton
*/
private JButton getJButton2() {
if (jButton2 == null) {
jButton2 = new JButton();
jButton2.setBounds(new Rectangle(311, 1, 99, 31));
jButton2.setText("挂失");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String account=jTextField.getText().trim();
int f=0,f1=0,f2=0;
String sql="update account set ";
if(jCheckBox.isSelected()) {
f=1;
sql+=" isaccountLost='y'";
}
if(f==1&&jCheckBox1.isSelected()) {
f1=1;
sql+=",ISBANKCARDLOST='y'";
}
if(f==0&&jCheckBox1.isSelected()) {
f1=1;
sql+="ISBANKCARDLOST='y'";
}
if(f==0&&f1==0&&jCheckBox2.isSelected()) {
f2=0;
sql+=" ISVALID='n'";
}
if(f==1||f1==1&&jCheckBox2.isSelected()) {
f2=0;
sql+=",ISVALID='n'";
}
if(f+f1+f2==0) {
selectOne();
}
sql+=" where accountNum='"+account+"'";
DBManager.getConnection();
DBManager.execUpdate(sql);
DBManager.releaseCon();
}
});
}
return jButton2;
}
private void selectOne() {
JOptionPane.showConfirmDialog(this,
"请选择挂失或取消帐号", "alter", JOptionPane.YES_NO_OPTION);
}
} // @jve:decl-index=0:visual-constraint="10,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -