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

📄 kjhk.java

📁 软件工程学生习作
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                     break;  
                   
            	}  
              }
            	  
                    	  
          con.close();	  
       
        if(查询记录==0)//弹出消息对话框
       
          	{    JOptionPane.showMessageDialog(this," 该卡号是空号","警告对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);
          	     
          	     text1.setText(null);   
          	      text2.setText(null); 
          	      
           	}
         }
}/***************************************************************************************************/  
  

 
 class 开户 extends Panel  implements ActionListener  //开户面板
{Box boxh1,boxv1,boxv2;   
 TextField text1,text2,text3;
  Button button1,button2;
  Statement sq1=null;
  Connection con=null;
  Cursor c=new  Cursor(Cursor.HAND_CURSOR);//光标

  开户()
  {button1=new Button("确定");
   button2=new Button("清除");
     button1.setBackground(Color.gray); 
     button1.setCursor(c);
     button2.setCursor(c);
   button2.setBackground(Color.gray);   
   
   text1=new TextField (15);
   text2=new TextField (15);
      text2.setEchoChar('*');
   text3=new TextField (15);
 
 
   
   boxv1=Box.createVerticalBox();//列式
   boxv1.add(Box.createVerticalStrut(20));
   boxv1.add(new Label("输入身份证号:"));
   
   boxv1.add(Box.createVerticalStrut(8));
   boxv1.add(new Label("请输入密码: "));
   boxv1.add(Box.createVerticalStrut(8));
   boxv1.add(new Label("输入存入金额:"));
   boxv1.add(Box.createVerticalStrut(20));
   boxv1.add(button1);
   
    boxv2=Box.createVerticalBox();//列式 
    boxv2.add(Box.createVerticalStrut(20));
    boxv2.add(text1);
    boxv2.add(Box.createVerticalStrut(8));
    boxv2.add(text2);
    boxv2.add(Box.createVerticalStrut(8));
    boxv2.add(text3);
    
    boxv2.add(Box.createVerticalStrut(20));
    boxv2.add(button2);
    
    boxh1=Box.createHorizontalBox();//行式  
    boxh1.add(boxv1);
    boxh1.add(Box.createHorizontalStrut(10));
    boxh1.add(boxv2); 
    add(boxh1);
    
    button1.addActionListener(this);//监视器
    button2.addActionListener(this);
    
    
     try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              }
          catch(ClassNotFoundException e) {} 
          
        try {  con=DriverManager.getConnection("jdbc:odbc:redsun","","");
         
       sq1=con.createStatement();}
          catch( SQLException e) {}  
    
    
    
    }
  
  public void actionPerformed (ActionEvent e )//实现监视
     { 
        if(e.getSource()==button1)
         {
         	
          int nv= JOptionPane.showConfirmDialog(this,"确定要开户吗?","确认对话框",
          	      
          	        JOptionPane.YES_NO_OPTION);//弹出确认对话框
         	
           if(nv==JOptionPane.YES_OPTION)//如果点yes.则执行
           {	try{ 开户增量();}	
         	  catch(SQLException ee) {}
         	  }
        
         else if(nv==JOptionPane.NO_OPTION)	//如果点no.则退出清空
         	  text1.setText(null);       	
         	text2.setText(null);
          	      text3.setText(null);
         	
          }  // 数据库在函数中
        
        
         
         else if(e.getSource()==button2)
              {  
                  text1.setText(null);   
          	      text2.setText(null);
          	      text3.setText(null); 
          	 
          	    }	
         	
     	}
    
    public void 开户增量() throws  SQLException   //数据库函数
     {    String   sfz;    int b=0, a=0;int c=0;   
         ResultSet rs=sq1.executeQuery("SELECT * FROM 表1 ");
       
    
        
       while(rs.next())
            { c=c+1;
              
           
                String   t1=text1.getText();//判断是否为非法字符
            String  t2=text2.getText();
            String  t3=text3.getText();
           
      char  a1[]=t1.toCharArray();
       char  a2[]=t2.toCharArray(); 
       char a3[]=t3.toCharArray();  
    
       
          
          for(int i=0;i<a1.length;i++)
         {  if(!(Character.isDigit(a1[i])))
                         { b=1; a=1; }
           }   
          for(int i=0;i<a2.length;i++)
         {  if(!(Character.isDigit(a2[i])))
                          { b=1; a=1; }
          }  
          for(int i=0;i<a3.length;i++)
         {  if(!(Character.isDigit(a3[i])))
                          { b=1; a=1; }
          }  
       
         
        if(b==1)
          {  JOptionPane.showMessageDialog(this,"您输入了非法字符,请重新输入","警告对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);
          	      text1.setText(null);   
          	      text2.setText(null);
          	      text3.setText(null); 
          	       break;
          }
            
          
         
         
         
     
           sfz=rs.getString("身份证");
           

           if(sfz.equals(text1.getText().trim()))
               {   
 JOptionPane.showMessageDialog(this,"身份证号已存在,请重新输入","消息对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);
              a=1;  text1.setText(null);      break;}  
 
              
             
             
              
              }
              
         
              
              
              
              
              
           
              if(a==0)  
            {   String sfz1="'"+text1.getText().trim()+"'";
           String mima="'"+text2.getText().trim()+"'";
                 String money="'"+text3.getText().trim()+"'";
              
                 int d=10000000+c;
                 String kahao= String.valueOf(d); 
                 
                       
             String temp="INSERT INTO 表1 VALUES ("+sfz1+","+ kahao+","+mima+","+money+")";
                    
                 con=DriverManager.getConnection("jdbc:odbc:redsun","","");
                 
                 sq1.executeUpdate(temp);    
          
                    
                   
                     JOptionPane.showMessageDialog(this,"开户成功,您的卡号是"+kahao+"密码是"+mima,"消息对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);
          	        
          	        con.close();
          	        
          	      text1.setText(null);   
          	      text2.setText(null);
          	      text3.setText(null); 
          	  }   
        
          
            	  
       
           	
         }
}/***************************************************************************************************/  

class 挂失 extends Panel  implements ActionListener  //挂失面板
{Box boxh1,boxv1,boxv2;   
 TextField text1;
  Button button1,button2;  int a=0;
  Cursor c=new  Cursor(Cursor.HAND_CURSOR);//光标
 
  挂失()
  {button1=new Button("确定");
   button2=new Button("清除");
     button1.setCursor(c);
    button2.setCursor(c);
 
      button1.setBackground(Color.gray); 
   button2.setBackground(Color.gray); 
 
   
   text1=new TextField (18);
   
   boxv1=Box.createVerticalBox();//列式
      boxv1.add(Box.createVerticalStrut(31));
   boxv1.add(new Label("输入身份证号:"));
   boxv1.add(Box.createVerticalStrut(40));
   boxv1.add(button1);
   
    boxv2=Box.createVerticalBox();//列式 
       boxv2.add(Box.createVerticalStrut(30));
    boxv2.add(text1);
    boxv2.add(Box.createVerticalStrut(41));
    boxv2.add(button2);
    
    boxh1=Box.createHorizontalBox();//行式  
    boxh1.add(boxv1);
    boxh1.add(Box.createHorizontalStrut(10));
    boxh1.add(boxv2); 
    add(boxh1);
    
    button1.addActionListener(this);//监视器
    button2.addActionListener(this);
    
    
     }
  
  public void actionPerformed (ActionEvent e )//实现监视
     { 
        if(e.getSource()==button1)
         {
         	
          int nv= JOptionPane.showConfirmDialog(this,"确定要挂失吗?","确认对话框",
          	      
          	        JOptionPane.YES_NO_OPTION);//弹出确认对话框
         	
           if(nv==JOptionPane.YES_OPTION)//如果点yes.则执行
           {	try{ 挂失();}	
         	  catch(SQLException ee) {}
         	  }
        
         else if(nv==JOptionPane.NO_OPTION)	//如果点no.则退出清空
         	  text1.setText(null);       	
         	
         	
          }  // 数据库在函数中
        
      
         	
         else if(e.getSource()==button2)
              {  
                  text1.setText(null);   
          	    
          	    }	
         	
     	}
    
    public void  挂失() throws  SQLException   //数据库函数
     { String sfz;

           try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              }
          catch(ClassNotFoundException e) {} 
          
         Connection con=DriverManager.getConnection("jdbc:odbc:redsun","","");
         
        Statement sq1=con.createStatement();
        
        ResultSet rs=sq1.executeQuery("SELECT * FROM 表1 ");
           
              while(rs.next())       
             {   sfz=rs.getString("身份证");
               
                 if(sfz.equals(text1.getText().trim()))
             
                {
                
                 String temp="DELETE FROM 表1 WHERE 身份证="+sfz;
                    
                 con=DriverManager.getConnection("jdbc:odbc:redsun","","");
                 
                 sq1.executeUpdate(temp);    
          
                    
                   
                     JOptionPane.showMessageDialog(this,sfz+"挂失成功","消息对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);  a=1;
          	        
          	        con.close();
                  text1.setText(null); break;
                   } 
                }
                   
                if(a==0)
                  {JOptionPane.showMessageDialog(this," 卡号不存在","消息对话框",
          	      
          	        JOptionPane.WARNING_MESSAGE);  }
          	      
           	  
       
           	
   } 
 }
/***************************************************************************************************/  
  

class 修改 extends Panel  implements ActionListener  //挂失面板
{Box boxh1,boxv1,boxv2;   
 TextField text1,text2,text3;   
  Button button1,button2; 
   int a=0;
  Cursor c=new  Cursor(Cursor.HAND_CURSOR);//光标
 
  修改()
  {button1=new Button("确定");
   button2=new Button("清除");
     button1.setCursor(c);
    button2.setCursor(c);
 
      button1.setBackground(Color.gray); 
   button2.setBackground(Color.gray); 
 
   
   text1=new TextField (15);
    text2=new TextField (15);
     text3=new TextField (15);
   
   boxv1=Box.createVerticalBox();//列式
      boxv1.add(Box.createVerticalStrut(20));
   boxv1.add(new Label("请输入卡号:"));
   boxv1.add(Box.createVerticalStrut(8));
   boxv1.add(new Label("输入旧密码:"));
   boxv1.add(Box.createVerticalStrut(8));
   boxv1.add(new Label("输入新密码:"));
   boxv1.add(Box.createVerticalStrut(26));
   boxv1.add(button1);
   
    boxv2=Box.createVerticalBox();//列式 
    boxv2.add(Box.createVerticalStrut(20));
        boxv2.add(text1);
      boxv2.add(Box.createVerticalStrut(8));

⌨️ 快捷键说明

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