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

📄 empdto.java

📁 宠物医院
💻 JAVA
字号:
package bean;

import java.sql.*;


public class EmpDTO {
  private String emp_name;
  private String emp_psw;
  JDBCBean jdbc=new JDBCBean();
  private Connection con=jdbc.getCon();
  private PreparedStatement pstm=null;
  private ResultSet rs=null;
  String sql;
  private int popedom;   //职员权限
  private int temp;
  private int vet_id;

  public EmpDTO() {
  }

  public void setEmp_name(String emp_name) {
    this.emp_name = emp_name;
  }

  public void setEmp_psw(String emp_psw) {
    this.emp_psw = emp_psw;
  }

  public void setPopedom(int popedom) {
    this.popedom = popedom;
  }

  public void setVet_id(int vet_id) {
    this.vet_id = vet_id;
  }

  public String getEmp_name() {
    return emp_name;
  }

  public String getEmp_psw() {
    return emp_psw;
  }

  public int getPopedom() {
    return this.popedom;
  }

  public int getVet_id() {
    return vet_id;
  }

  public boolean judgement()
  {
    try
    {
      sql="select popedom from employee where name=? and password=?";
      pstm=con.prepareStatement(sql);
      pstm.setString(1,getEmp_name());
      pstm.setString(2,getEmp_psw());
      rs=pstm.executeQuery();
      if(rs.next())
      {
        temp=rs.getInt(1);
        setPopedom(temp);
        return true;
      }
      pstm.close();
    }
    catch(Exception e)
    {
      e.printStackTrace();
      return false;
    }
    return false;
  }

public boolean insertEmp()
  {
    try
    {
      sql="insert into employee (name,password,popedom,vet_id) values (?,?,?,?)";
      pstm=con.prepareStatement(sql);
      pstm.setString(1,getEmp_name());
      pstm.setString(2,getEmp_psw());
      pstm.setInt(3,getPopedom());
      pstm.setInt(4,getVet_id());
      pstm.executeUpdate();
      return true;
    }
    catch(Exception e)
    {
      e.printStackTrace();
      return false;
    }
  }
  public boolean isInEmp()  //判断是否在Emp表中
  {
    try
    {
      sql="select name from employee where name=?";
      pstm=con.prepareStatement(sql);
      pstm.setString(1,getEmp_name());
      System.out.println(getEmp_name());
      rs=pstm.executeQuery();
      if(rs.next())
      {
        return true;
      }

    }
    catch(Exception e)
    {
      e.printStackTrace();
      return true;
    }
    return false;  //没有同名的职员登录号
  }

}

⌨️ 快捷键说明

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