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

📄 queryframe.java

📁 很经典的银行ATM操作系统。 可以创建账户
💻 JAVA
字号:
import java.sql.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.JOptionPane;

class WinQue extends Frame implements ActionListener
{
	Panel p;
	TextField text,text1,text2;
	Button button1,button2;
	Connection Con=null;
	Statement Stmt=null;
	{
		p=new Panel();
		text=new TextField(20);
		text.setEditable(false);
		text1=new TextField();
		text2=new TextField();
		text2.setEchoChar('*');
		button1=new Button("查询");
		button2=new Button("返回");
		button1.addActionListener(this);
		button2.addActionListener(this);
		Box boxV;
		boxV=Box.createVerticalBox();
		Box boxH1,boxH2,boxH3,boxH4;
		Box boxH5,boxH6;
		boxH5=Box.createHorizontalBox();
		boxH6=Box.createHorizontalBox();
		boxH1=Box.createHorizontalBox();
		boxH2=Box.createHorizontalBox();
		boxH3=Box.createHorizontalBox();
		boxH4=Box.createHorizontalBox();
		boxH5.add(new Label("请输入您的帐号:"));
		boxH5.add(text1);
		boxH6.add(new Label("请输入您的密码:"));
		boxH6.add(text2);
		boxH1.add(new Label("您的余额为:"));
		boxH1.add(Box.createHorizontalGlue());
		boxH2.add(new Label("人民币:"));
		boxH2.add(text);
		boxH3.add(Box.createHorizontalGlue());
		boxH3.add(button1);
		boxH4.add(Box.createHorizontalGlue());
		boxH4.add(button2);
		boxV.add(boxH5);
		boxV.add(boxH6);
		boxV.add(boxH1);
		boxV.add(boxH2);
		boxV.add(boxH3);
		boxV.add(boxH4);
		p.add(boxV);
		add(p);
	}
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==button1)
		{
			try
			{
				Query();
			}
			catch(SQLException ee)
			{
				JOptionPane.showMessageDialog(this,"对不起,数据库连接失败,请稍候再试",
			    "Warning",JOptionPane.WARNING_MESSAGE);
			}
		}
		if(e.getSource()==button2)
		{
			String s[]={"调用"};
			UserFrame.main(s);
		}
	}
	public void Query()throws SQLException
	{
		String 帐号,密码,余额,挂失;
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		}
		catch(ClassNotFoundException ee)
		{
			JOptionPane.showMessageDialog(this,"对不起,数据库连接失败,请稍候再试",
			"Warning",JOptionPane.WARNING_MESSAGE);
		}
		Con=DriverManager.getConnection("jdbc:odbc:Bank","杨高","yanggao");
		Stmt=Con.createStatement();
		ResultSet rs=Stmt.executeQuery("SELECT * FROM 银行卡数据库");
		boolean boo=false;
		while((boo=rs.next())==true)
		{
			帐号=rs.getString("帐号");
			密码=rs.getString("密码");
			余额=rs.getString("余额");
			挂失=rs.getString("挂失");
			if(帐号.equals(text1.getText())&&密码.equals(text2.getText()))
			{
				if(挂失.equals("Y"))
				{
					JOptionPane.showMessageDialog(this,"您的卡已挂失,请先取消挂失!",
		  			"Warning",JOptionPane.WARNING_MESSAGE);
		  			break;
				}
				else
				{
					text.setText(余额);
					break;
				}
			}
		}
		Con.close();
		if(boo==false)
		{
			JOptionPane.showMessageDialog(this,"您还没有注册或帐号密码有错,请检查",
			"Warning",JOptionPane.WARNING_MESSAGE);
			text.setText("");
		}
	}
}

public  class QueryFrame
{
	public static void main(String args[])
	{
		WinQue window=new WinQue();
		window.setBounds(100,100,300,300);
		window.setVisible(true);
		window.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
	}
}

⌨️ 快捷键说明

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