consumerinfobean.java

来自「精美的画面。完善的功能」· Java 代码 · 共 118 行

JAVA
118
字号
package Flower.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
public class ConsumerInfoBean 
{
  Connection con=null;
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  public boolean addConInfo(Consumerinfo ConsInfo) throws Exception
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("insert into ConsumerInfo values(?,?,?,?,?,?,?,?)");
      pstmt.setString(1,ConsInfo.getConsumerid());
      pstmt.setString(2,ConsInfo.getRealname());
      pstmt.setString(3,ConsInfo.getConsumersex());
      pstmt.setString(4,ConsInfo.getIdentitycard());
      pstmt.setString(5,ConsInfo.getAddress());
      pstmt.setString(6,ConsInfo.getZipcode());
      pstmt.setString(7,ConsInfo.getEmail());
      pstmt.setString(8,ConsInfo.getTel());
      pstmt.executeUpdate();
      pstmt.close();
      con.close();
      res=true;
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    
    return res;
  }

  public boolean delConInfo(String id)
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("delete from ConsumerInfo where ConsumerID=?");
      pstmt.setString(1,id);
      pstmt.executeUpdate();
      pstmt.close();
      con.close();
      res=true;
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    
    return res;
  }

  public boolean updateConInfo(Consumerinfo consInfo) throws Exception
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("update ConsumerInfo set RealName=?,ConsumerSex=?,Identitycard=?,address=?,zipcode=?,email=?,tel=? where ConsumerID=?");
      pstmt.setString(1,consInfo.getRealname());
      pstmt.setString(2,consInfo.getConsumersex());
      pstmt.setString(3,consInfo.getIdentitycard());
      pstmt.setString(4,consInfo.getAddress());
      pstmt.setString(5,consInfo.getZipcode());
      pstmt.setString(6,consInfo.getEmail());
      pstmt.setString(7,consInfo.getTel());
      pstmt.setString(8,consInfo.getConsumerid());
      pstmt.executeUpdate();
      pstmt.close();
      con.close();
      res=true;
      
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    } 
    
    return res;
  }

  public boolean getConID(String id)
  {
    boolean res=false;
    try 
    {
      con=DBConnect.getConnection();
      pstmt=con.prepareStatement("select * form ConsumerInfo where ConsumerID=?");
      pstmt.setString(1,id);
      rs=pstmt.executeQuery();
      if(rs.next())
      {
        res=true;
      }
      else
      {
        res=false;
      }
      
    } 
    catch (Exception ex) 
    {
      ex.printStackTrace();
    }
    
    return res;
  }

 
}

⌨️ 快捷键说明

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