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

📄 delwin.java

📁 界面不错的东西
💻 JAVA
字号:
/*******************************************
* 程序DelWin.java 完成银行用户的注销
*****************************************/
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;

  class DelWin extends JFrame implements ActionListener
  {
    JTextField del_conacco;//要销户的储户帐号
    JButton delbtn,cancelbtn;
    Connection Con=null;
    Statement Stmt=null;
    DelWin()
     {
       super("银行账户销户");
       this.setBounds(250,250,450,200);
       this.setVisible(true);
       Container con=getContentPane();
       con.setLayout(new FlowLayout());
       con.add(new Label("光大银行储户销户处理:"),"NORTH");
       
       JPanel p1=new JPanel();
       p1.setLayout(new GridLayout(2,2));
       p1.add(new Label("请输入要销户的账户账号:"));
       del_conacco=new JTextField(15);
       p1.add(del_conacco);
       delbtn=new JButton("销户");
       cancelbtn=new JButton("取消");
       p1.add(delbtn);
       p1.add(cancelbtn);
       delbtn.addActionListener(this);
       cancelbtn.addActionListener(this);
       con.add(p1,"CENTER");
       this.validate();
    }
   
  public void actionPerformed(ActionEvent e)
   {
     if(e.getSource()==delbtn)
      {
         if(del_conacco.getText().equals(""))
         {
          JOptionPane.showMessageDialog(this,"请输入要注销的帐号!","警告",JOptionPane.WARNING_MESSAGE);
         }
         else
          {
           try{ del_con();}
           catch(SQLException ee){System.out.println("SQLException:"+ee.getMessage());}
          }
       }
     else if(e.getSource()==cancelbtn)
       {
         dispose();
       }
   }

     public void del_con() throws SQLException
   {
     String _con_acco;
     _con_acco="'"+del_conacco.getText().trim()+"'";
     String con_acco;
     con_acco=del_conacco.getText().trim();
     boolean boo=false;
     try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        }
     catch(ClassNotFoundException e){System.out.println("ClassNotFoundException:"+e.getMessage());}
     try{
     Con=DriverManager.getConnection("jdbc:odbc:Bankdb","","");
     Stmt=Con.createStatement();
     ResultSet rs=Stmt.executeQuery("select * from consumer");
     while((boo=rs.next())==true)
      {
        String temp;
        temp=rs.getString("con_acco");
        if(temp.equals(con_acco))
          {
           String s1="DELETE FROM consumer WHERE con_acco="+_con_acco;
           Stmt.executeUpdate(s1);
           dispose();
           JOptionPane.showMessageDialog(this,"用户成功注销","恭喜",JOptionPane.WARNING_MESSAGE);
           break;
          }
    }
   Con.close();
  }catch(SQLException e_5){System.out.println("SQLException:"+e_5.getMessage());}
   if(boo==false)
    {
      JOptionPane.showMessageDialog(this,"不存在要注销的帐号!请查证!","警告",JOptionPane.WARNING_MESSAGE);
    }
 }
}

⌨️ 快捷键说明

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