- package StudyNote;
- import java.util.*;
- import java.sql.Connection;
- import java.sql.ResultSet;
- public class InterUser {
- private String username = null;
- private String password = null;
- private String grade = null;
- private int empId = 0;
- public InterUser(){}
- public void setUsername(String username) {
- this.username = username;
- }
- public String getUsername() {
- return username;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getPassword() {
- return password;
- }
- public void setGrade(String grade) {
- this.grade = grade;
- }
- public String getGrade() {
- return grade;
- }
- public void setEmpId(int empId) {
- this.empId = empId;
- }
- public int getEmpId() {
- return empId;
- }
- public static boolean CheckUser(DB db,String name,String psw) throws Exception{
- String strSql;
- ResultSet rs;
- strSql = "select * from interuser where username='" + name + "'"
- + " and password='" + psw + "'";
- rs = db.OpenSql(strSql);
- if ( rs.next()) {
- return true;
- }
- else{
- return false;
- }
- }
- public static int GetUserGrade(DB db,String name) throws Exception{
- String strSql;
- ResultSet rs;
- int iResult=0;
- strSql = "select grade from interuser where username='" + name + "'";
- rs = db.OpenSql(strSql);
- if ( rs.next()) {
- iResult= rs.getInt("grade");
- }
- return iResult;
- }
- public static String GetEmpName(DB db,String username) throws Exception{
- String strSql;
- ResultSet rs;
- String sResult=null;
- strSql = "select emp.name from interuser,emp where interuser.username='" + username
- + "' and interuser.empid=emp.id ";
- rs = db.OpenSql(strSql);
- if ( rs.next()) {
- sResult= rs.getString("name");
- }
- return sResult;
- }
- public boolean Insert(DB db,int empId) throws Exception{
- String strSql;
- strSql = "insert into interuser values('"
- + username +"','"
- + password +"','普通用户',"
- + empId +")";
- if ( db.ExecSql(strSql)==0) {
- return false;
- }
- else{
- return true;
- }
- }
- }