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

📄 bank.java

📁 简易的银行卡管理系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			text1.setText("");
			text2.setText("");
			mycard.show(p,"1");
		}
		else if(e.getSource()==button2)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
			    sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
			    r=sql.executeQuery("SELECT * FROM user");
				if(text3.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else 
				{
					boolean b=false;
					r.beforeFirst();
					while((b=r.next())==true)
					{
						String s1=r.getString("counts");
						long l=r.getLong("deposit");
						if(s1.equals(text3.getText().trim()))
						{
							if(text4.getText().trim().equals(""))
				            {
				            	JOptionPane.showMessageDialog(this,"请输入存款金额!","提示",JOptionPane.ERROR_MESSAGE);
				            	con.close();
					        }
					        else if(Float.valueOf(text4.getText().trim()).floatValue()<1.0)
					        {
					        	JOptionPane.showMessageDialog(this,"存款金额必须大于1!","提示",JOptionPane.ERROR_MESSAGE);
					        	con.close();
					        }
					        else
					        {
 					        	l=l+Long.parseLong(text4.getText().trim());
 					        	s1="'"+s1+"'";
					        	sql.executeUpdate("UPDATE user SET deposit = "+l+" WHERE counts="+s1);
					        	JOptionPane.showMessageDialog(this,"交易成功,谢谢使用!","消息",JOptionPane.INFORMATION_MESSAGE);
					        	text3.setText("");
					        	text4.setText("");
					        	con.close();
					        }
						}
					}
					if(b==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e3)
			{
			}
		}
		else if(e.getSource()==button3)
		{
			text3.setText(null);
			text4.setText(null);
			mycard.show(p,"1");
		}
		else if(e.getSource()==button4)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
			    sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
			    r=sql.executeQuery("SELECT * FROM user");
				if(text5.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else
				{
					boolean b2=false;
					r.beforeFirst();
					while((b2=r.next())==true)
					{
						String s2=r.getString("counts");
						if(s2.equals(text5.getText()))
						{
							text5.setText(null);
							mycard.show(p,"8");
							text13.setText(r.getString("name"));text13.setEditable(false);
							text14.setText(s2);text14.setEditable(false);
							text15.setText(r.getString("deposit"));text15.setEditable(false);
							text16.setText(r.getString("number"));text16.setEditable(false);
							con.close();
						}
					}
					if(b2==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e4)
			{
			}
		}
		else if(e.getSource()==button5)
		{
			text5.setText(null);
			mycard.show(p,"1");
		}
		else if(e.getSource()==button6)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
			    sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
			    r=sql.executeQuery("SELECT * FROM user");
				if(text6.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else
				{
					boolean b=false;
					r.beforeFirst();
					while((b=r.next())==true)
					{
						String s=r.getString("counts");
						if(s.equals(text6.getText().trim()))
						{
							String s1=r.getString("password");
							if(s1.equals(text7.getText().trim()))
							{
								if(text8.getText().trim().equals(""))
								{
									JOptionPane.showMessageDialog(this,"请输入取款金额!","提示",JOptionPane.ERROR_MESSAGE);
									con.close();
								}
								else if(Float.valueOf(text8.getText().trim()).floatValue()<1.0)
								{
									JOptionPane.showMessageDialog(this,"取款金额必须大于1!","提示",JOptionPane.ERROR_MESSAGE);
					        	    con.close();
								}
								else if(r.getLong("deposit")<=Long.parseLong(text8.getText().trim()))
								{
									JOptionPane.showMessageDialog(this,"对不起,余额不足!","提示",JOptionPane.ERROR_MESSAGE);
					        	    con.close();
								}
								else
								{
									long q=r.getLong("deposit")-Long.parseLong(text8.getText().trim());
									s="'"+s+"'";
									sql.executeUpdate("UPDATE user SET deposit="+q+" WHERE counts="+s);
									JOptionPane.showMessageDialog(this,"交易成功,谢谢使用!","消息",JOptionPane.INFORMATION_MESSAGE);
									text6.setText(null);
									text7.setText(null);
									text8.setText(null);
									con.close();
								}
							}
							else
							{
								JOptionPane.showMessageDialog(this,"对不起,密码不正确!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
						}
					}
					if(b==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e5)
			{
			}
		}
		else if(e.getSource()==button7)
		{
			text6.setText(null);
			text7.setText(null);
			text8.setText(null);
			mycard.show(p,"1");
		}
		else if(e.getSource()==button8)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
			    sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
		    	r=sql.executeQuery("SELECT * FROM user");
				if(text9.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else 
				{
					boolean b=false;
					r.beforeFirst();
					while((b=r.next())==true)
					{
						String s=r.getString("counts");
						if(s.equals(text9.getText().trim()))
						{
							String s1=r.getString("number");
							if(text10.getText().trim().equals(""))
							{
								JOptionPane.showMessageDialog(this,"请输入身份证号!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
							else if(s1.equals(text10.getText().trim()))
							{
								s="'"+s+"'";
								sql.executeUpdate("UPDATE user SET report=0 WHERE counts="+s);
								JOptionPane.showMessageDialog(this,"帐号已经成功挂失!","消息",JOptionPane.INFORMATION_MESSAGE);
								text9.setText(null);
								text10.setText(null);
								con.close();
							}
							else
							{
								JOptionPane.showMessageDialog(this,"身份证不正确!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
						}
					}
					if(b==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e6)
			{
			}
		}
		else if(e.getSource()==button9)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
		    	sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
		    	r=sql.executeQuery("SELECT * FROM user");
				if(text9.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else 
				{
					boolean b=false;
					r.beforeFirst();
					while((b=r.next())==true)
					{
						String s=r.getString("counts");
						if(s.equals(text9.getText().trim()))
						{
							String s1=r.getString("number");
							if(text10.getText().trim().equals(""))
							{
								JOptionPane.showMessageDialog(this,"请输入身份证号!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
							else if(s1.equals(text10.getText().trim()))
							{
								s="'"+s+"'";
								sql.executeUpdate("UPDATE user SET report=1 WHERE counts="+s);
								JOptionPane.showMessageDialog(this,"帐号已经成功解挂!","消息",JOptionPane.INFORMATION_MESSAGE);
								text9.setText(null);
								text10.setText(null);
								con.close();
							}
							else
							{
								JOptionPane.showMessageDialog(this,"身份证不正确!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
						}
					}
					if(b==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e7)
			{
			}
		}
		else if(e.getSource()==button10)
		{
			text9.setText(null);
			text10.setText(null);
			mycard.show(p,"1");
		}
		else if(e.getSource()==button11)
		{
			try
			{
				con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
		    	sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
		    	r=sql.executeQuery("SELECT * FROM user");
				if(text11.getText().trim().equals(""))
				{
					JOptionPane.showMessageDialog(this,"请输入帐号!","提示",JOptionPane.ERROR_MESSAGE);
					con.close();
				}
				else 
				{
					boolean b=false;
					r.beforeFirst();
					while((b=r.next())==true)
					{
						String s=r.getString("counts");
						if(s.equals(text11.getText().trim()))
						{
							String s1=r.getString("password");
							if(text12.getText().trim().equals(""))
							{
								JOptionPane.showMessageDialog(this,"请输入密码!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
							else if(s1.equals(text12.getText().trim()))
							{
								s="'"+s+"'";
								sql.executeUpdate("DELETE FROM user WHERE counts="+s);
								JOptionPane.showMessageDialog(this,"此帐号已经成功消除!","消息",JOptionPane.INFORMATION_MESSAGE);
								text11.setText(null);
								text12.setText(null);
								con.close();
							}
							else
							{
								JOptionPane.showMessageDialog(this,"对不起,密码不正确!","提示",JOptionPane.ERROR_MESSAGE);
								con.close();
							}
						}
					}
					if(b==false)
					{
						JOptionPane.showMessageDialog(this,"对不起,帐号不正确!","提示",JOptionPane.ERROR_MESSAGE);
						con.close();
					}
				}
			}
			catch(SQLException e7)
			{
			}
		}
		else if(e.getSource()==button12)
		{
			text11.setText(null);
			text12.setText(null);
			mycard.show(p,"1");
		}
	}
}
public class Bank
{
	public static void main(String args[])
	{
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		}
		catch(ClassNotFoundException e)
		{
			System.out.println(""+e);
		}
		denglu jiemian=new denglu();
	}
}

⌨️ 快捷键说明

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