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

📄 peoplebean.java

📁 教师办公管理系统
💻 JAVA
字号:
package to.model.People;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
import to.model.*;

public class PeopleBean 
{
  Connection con=null;
  PreparedStatement ps=null;
  ResultSet rs=null;
  DBConnection db=new DBConnection("PeoplePool",500);
  
  
  public ResultSet getAllNation()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Nation");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllNation()
  
  
  public ResultSet getAllCollege()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_College");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllCollege()
  
  
  
   public ResultSet getAllDeparement()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Department");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllDeparement()
  
  
   public ResultSet getAllRole()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Role");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllRole()
  
  
  
 public ResultSet getAllSpeciality()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Speciality");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllSpeciality()
  
  
  
   public ResultSet getAllEducation()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Education");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllEducation()
  
  
  
  public ResultSet getAllPolitics()
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Politics");
      rs=ps.executeQuery();
      return rs;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getAllPolitics()
  
  
  
  public String insertPeople(PeopleItem pi)
  {
    try
    {
        con=db.getConnection();
        ps=con.prepareStatement("insert into kjc_People values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        ps.setString(1,pi.getUserName());
        ps.setString(2,pi.getUserPwd());
        ps.setString(3,pi.getPeopleName());
        ps.setString(4,pi.getPeopleSex());
        ps.setString(5,pi.getNation());
        ps.setString(6,pi.getAddr());
        ps.setString(7,pi.getBirth());
//      ps.setDate(7,Date.valueOf(pi.getBirth()));
        ps.setString(8,pi.getCertid());
        ps.setString(9,pi.getPost());
        ps.setString(10,pi.getOfficetel());
        ps.setString(11,pi.getMobile());
        ps.setString(12,pi.getHometel());
        ps.setString(13,pi.getEmail());
        ps.setString(14,pi.getDescs());
        ps.setInt(15,pi.getCollegeID());
        ps.setInt(16,pi.getDepartmentID());
        ps.setInt(17,pi.getRoleID());
        ps.setInt(18,pi.getSpecialityID());
        ps.setInt(19,pi.getEducationID());
        ps.setInt(20,pi.getPoliticsID());
        ps.setString(21,pi.getFromschool());
//        ps.setDate(22,Date.valueOf(pi.getSchooltime()));
        ps.setString(22,pi.getSchooltime());
        ps.executeUpdate();
        return "添加成功";
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return "添加失败";
    }//end block catch
  }//end method insertPeople()
  
  
  public Collection selectPeople()
  {
    Vector v=new Vector();    
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select kjc_People.PeopleID,kjc_People.UserName,kjc_People.PeopleName,kjc_Department.DepartmentName,kjc_College.CollegeName from kjc_People,kjc_Department,kjc_College where kjc_People.CollegeID=kjc_College.CollegeID and kjc_People.DepartmentID=kjc_Department.DepartmentID");
      rs=ps.executeQuery();
      while(rs.next())
      {
        PeopleItem pi=new PeopleItem();
        pi.setPeopleID(rs.getInt("PeopleID"));
        pi.setUserName(rs.getString("UserName"));
        pi.setPeopleName(rs.getString("PeopleName"));
        pi.setDepartmentName(rs.getString("DepartmentName"));
        pi.setCollegeName(rs.getString("CollegeName"));
        v.add(pi);
      }
      return v;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method selectRight()
  
  
  
  public String deletePeople(int id)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("delete kjc_People where PeopleID=?");
      ps.setInt(1,id);
      ps.executeUpdate();
      return "删除成功";
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return "删除失败";
    }
  }//end method deletePeople()
  
  
  public String updatePeople(PeopleItem pi)
  {
    try
    {
        con=db.getConnection();
        ps=con.prepareStatement("update kjc_People set UserName=?,UserPwd=?,PeopleName=?,PeopleSex=?,Nation=?,Addr=?,Birth=?,Certid=?,Post=?,Officetel=?,Mobile=?,Hometel=?,Email=?,Descs=?,CollegeID=?,DepartmentID=?,RoleID=?,SpecialityID=?,EducationID=?,PoliticsID=?,Fromschool=?,Schooltime=? where PeopleID=?");
        ps.setString(1,pi.getUserName());
        ps.setString(2,pi.getUserPwd());
        ps.setString(3,pi.getPeopleName());
        ps.setString(4,pi.getPeopleSex());
        ps.setString(5,pi.getNation());
        ps.setString(6,pi.getAddr());
        ps.setString(7,pi.getBirth());
        ps.setString(8,pi.getCertid());
        ps.setString(9,pi.getPost());
        ps.setString(10,pi.getOfficetel());
        ps.setString(11,pi.getMobile());
        ps.setString(12,pi.getHometel());
        ps.setString(13,pi.getEmail());
        ps.setString(14,pi.getDescs());
        ps.setInt(15,pi.getCollegeID());
        ps.setInt(16,pi.getDepartmentID());
        ps.setInt(17,pi.getRoleID());
        ps.setInt(18,pi.getSpecialityID());
        ps.setInt(19,pi.getEducationID());
        ps.setInt(20,pi.getPoliticsID());
        ps.setString(21,pi.getFromschool());
        ps.setString(22,pi.getSchooltime());
        ps.setInt(23,pi.getPeopleID());
        ps.executeUpdate();
        return "修改成功";
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return "修改失败";
    }//end block catch
  }//end method updatePeople
  
  
  public PeopleItem getPeoplebyID(int id)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_People where PeopleID='"+id+"'");
      rs=ps.executeQuery();
      PeopleItem pi=new PeopleItem();
      while(rs.next())
      {
        pi.setPeopleID(rs.getInt("PeopleID"));
        pi.setUserName(rs.getString("UserName"));
        pi.setUserPwd(rs.getString("UserPwd"));
        pi.setPeopleName(rs.getString("PeopleName"));
        pi.setPeopleSex(rs.getString("PeopleSex"));
        pi.setNation(rs.getString("Nation"));
        pi.setAddr(rs.getString("Addr"));
        pi.setBirth(rs.getString("Birth"));
        pi.setCertid(rs.getString("Certid"));
        pi.setPost(rs.getString("Post"));
        pi.setOfficetel(rs.getString("Officetel"));
        pi.setMobile(rs.getString("Mobile"));
        pi.setHometel(rs.getString("Hometel"));
        pi.setEmail(rs.getString("Email"));
        pi.setDescs(rs.getString("Descs"));
        pi.setCollegeID(rs.getInt("CollegeID"));
        pi.setDepartmentID(rs.getInt("DepartmentID"));
        pi.setRoleID(rs.getInt("RoleID"));
        pi.setSpecialityID(rs.getInt("SpecialityID"));
        pi.setEducationID(rs.getInt("EducationID"));
        pi.setPoliticsID(rs.getInt("PoliticsID"));
        pi.setFromschool(rs.getString("Fromschool"));
        pi.setSchooltime(rs.getString("Schooltime"));
      }
      return pi;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return null;
    }//end block catch
  }//end method getPeoplebyID
  
  
  
  
  public int getCollege(int id)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_College where Principal=?");
      ps.setInt(1,id);
      rs=ps.executeQuery();
      int a=0;
      while(rs.next())
      {
        a=1;
      }
      return a;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return 0;
    }//end block catch
  }
  
  
  public int getDepartment(int id)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Department where Principal=?");
      ps.setInt(1,id);
      rs=ps.executeQuery();
      int a=0;
      while(rs.next())
      {
        a=1;
      }
      return a;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return 0;
    }//end block catch
  }
  
  
  
  public int getInform(int id)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("select * from kjc_Inform where Embracer=?");
      ps.setInt(1,id);
      rs=ps.executeQuery();
      int a=0;
      while(rs.next())
      {
        a=1;
      }
      return a;
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return 0;
    }//end block catch
  }
  
  
    public int getEmail(int id)
    {
      try
      {
        con=db.getConnection();
        ps=con.prepareStatement("select * from kjc_Email where Embracer=?");
        ps.setInt(1,id);
        rs=ps.executeQuery();
        int a=0;
        while(rs.next())
        {
          a=1;
        }
        return a;
      }//end block try
      catch(Exception e)
      {
        e.printStackTrace();
        return 0;
      }//end block catch
    }
    
    
    public int getUserName(String name)
    {
      try
      {
        con=db.getConnection();
        ps=con.prepareStatement("select * from kjc_People where UserName=?");
        ps.setString(1,name);
        rs=ps.executeQuery();
        int a=0;
        while(rs.next())
        {
          a=1;
        }
        return a;
      }//end block try
      catch(Exception e)
      {
        e.printStackTrace();
        return 0;
      }//end block catch
    }
}//end class PeopleBean

⌨️ 快捷键说明

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