📄 qukuan.java~66~
字号:
package MainFrame;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//import DataBaseManager.DataBaseManager;
import java.sql.*;
public class QuKuan extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel3 = new JLabel();
JPasswordField jPasswordField1 = new JPasswordField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public QuKuan() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(xYLayout1);
jLabel1.setFont(new java.awt.Font("华文彩云", Font.BOLD, 22));
jLabel1.setForeground(Color.green);
jLabel1.setText("取款操作界面");
jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
jLabel2.setText("取款金額");
jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
jLabel3.setText("密碼");
jPasswordField1.setToolTipText("");
jButton1.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
jButton1.setText("交易");
jButton1.addActionListener(new QuKuan_jButton1_actionAdapter(this));
jButton2.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
jButton2.setText("取消");
jButton2.addActionListener(new QuKuan_jButton2_actionAdapter(this));
this.addWindowListener(new QuKuan_this_windowAdapter(this));
// this.addWindowListener(new QuKuan_this_windowAdapter(this));
this.getContentPane().add(jLabel2, new XYConstraints(26, 77, 99, 38));
this.getContentPane().add(jButton2, new XYConstraints(246, 246, 71, 35));
this.getContentPane().add(jButton1, new XYConstraints(76, 247, 80, 35));
this.getContentPane().add(jLabel1, new XYConstraints(122, 22, 213, 44));
this.getContentPane().add(jTextField1,
new XYConstraints(136, 78, 161, 37));
this.getContentPane().add(jPasswordField1,
new XYConstraints(137, 149, 161, 38));
this.getContentPane().add(jLabel3, new XYConstraints(35, 153, 81, 34));
}
public static void main(String[] args) {
QuKuan q = new QuKuan();
q.setBounds(200,200,400,400);
q.setVisible(true);
}
public void jButton1_actionPerformed(ActionEvent e) {
try {
Connection con;
Statement stmt;
ResultSet rs1,rs2;
String a= jTextField1.getText();
char b[]=jPasswordField1.getPassword();
String c=new String(b);
float d=Float.parseFloat(c);
if(a.equals("")){
JOptionPane.showMessageDialog(null,"沒有輸入用戶ID!","輸入錯誤",JOptionPane.ERROR_MESSAGE);}
else if(c.equals("")){
JOptionPane.showMessageDialog(null,"沒有輸入密碼!","輸入錯誤",JOptionPane.ERROR_MESSAGE); }
else {
try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=ATM",
"sa", "huang100");
Statement Stat = conn.createStatement();
rs1 = Stat.executeQuery("select * from userTable where userpassword='"+ c+"'");
if(rs1.next()){
Stat.executeUpdate("update userTable set usermoney=usermoney-'"+a+"' where userpassword='"+c+"'");
JOptionPane.showMessageDialog(null,"登录成功,您成功取了"+a);
jTextField1.setText("");
jPasswordField1.setText("");}
else {
JOptionPane.showMessageDialog(null,"密码错误!");
jTextField1.setText("");
jPasswordField1.setText("");
}
}catch (Exception ex) {
System.out.println("数据库连接失败");
}
}
} catch(Exception ex){
JOptionPane.showConfirmDialog(null,"請您取卡");
}
}
public void this_windowClosing(WindowEvent e) {
System.exit(0);
}
public void jButton2_actionPerformed(ActionEvent e) {
ZhuJieMian z = new ZhuJieMian();
z.setBounds(200,200,400,400);
z.setVisible(true);
}
}
class QuKuan_this_windowAdapter extends WindowAdapter {
private QuKuan adaptee;
QuKuan_this_windowAdapter(QuKuan adaptee) {
this.adaptee = adaptee;
}
public void windowClosing(WindowEvent e) {
adaptee.this_windowClosing(e);
}
}
class QuKuan_jButton2_actionAdapter implements ActionListener {
private QuKuan adaptee;
QuKuan_jButton2_actionAdapter(QuKuan adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class QuKuan_jButton1_actionAdapter implements ActionListener {
private QuKuan adaptee;
QuKuan_jButton1_actionAdapter(QuKuan adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -