/// <summary>
 /// 根据用户类型返回数据库查询信息(用于登录验证)
 /// </summary>
 /// <param name="userType">用户类型</param>
 /// <param name="USID">用户唯一验证USID</param>
 /// <returns>返回登录实体类</returns>
 public static CheckUserLogin ReturnSqlJudgeByUserType(int userType, string USID)
 {
     CheckUserLogin CheckUserLogin = new CheckUserLogin();
     SqlParameter[] parameters;
     switch (userType)
     {
         case 1:
             parameters = new SqlParameter[1] {
             new SqlParameter("@teacherUSID", SqlDbType.NVarChar,50)};
             parameters[0].Value = USID;
             CheckUserLogin.spName = "spTeachersList";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 1;
             break;
         case 3:
             parameters = new SqlParameter[1] {
             new SqlParameter("@studentUSID",SqlDbType.NVarChar,50)};
             parameters[0].Value = USID;
             CheckUserLogin.spName = "spStudentsList";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 3;
             break;
         default:
             break;
     }
     return CheckUserLogin;
 }
        /// <summary>
        /// 检测用户登录合法性
        /// </summary>
        /// <param name="CheckUserLogin">用户登陆实体</param>
        /// <returns>用户登陆信息实体</returns>
        public UserCookiesInfo CheckUserLogin(CheckUserLogin CheckUserLogin)
        {
            UserCookiesInfo UserCookiesInfo = null;

            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CheckUserLogin.spName, CheckUserLogin.sqlParammeters);

            while (dr.Read())
            {
                UserCookiesInfo = new UserCookiesInfo { userNo = dr[0].ToString(), userName = dr[2].ToString() };

                UserCookiesInfo.userType = ((dr["isAdmin"] != null && bool.Parse(dr["isAdmin"].ToString().Trim())) ? 0 : CheckUserLogin.userType);

                UserCookiesInfo.teacherType = (dr.FieldCount !=6 ? "student" : dr["TeacherType"].ToString().Trim());

                UserCookiesInfo.Sex = (dr.FieldCount != 6 ? "student" : dr["Sex"].ToString().Trim()); ;
            }

            dr.Close();
            conn.Close();

            return UserCookiesInfo;
        }
 /// <summary>
 /// 修改用户密码
 /// </summary>
 /// <param name="CheckUserLogin">用户登陆实体</param>
 /// <returns>修改是否成功</returns>
 public bool UpdateUserPwd(CheckUserLogin CheckUserLogin)
 {
     SqlHelper.ExecuteNonQuery(conn, CheckUserLogin.spName, CheckUserLogin.sqlParammeters);
     conn.Close();
     return true;
 }
 /// <summary>
 /// 根据用户类型返回数据库查询相关信息
 /// </summary>
 /// <param name="userType">用户类型</param>
 /// <param name="userName">用户名</param>
 /// <param name="userPwd">用户密码</param>
 /// <param name="newPwd">新密码</param>
 /// <returns>返回登录实体类</returns>
 public static CheckUserLogin ReturnSqlJudgeByUserTypeforEditPwd(int userType, string userName, string userPwd, string newPwd)
 {
     CheckUserLogin CheckUserLogin = new CheckUserLogin();
     SqlParameter[] parameters;
     switch (userType)
     {
         case 0:
             parameters = new SqlParameter[3] {
             new SqlParameter("@adminUserName", userName),
             new SqlParameter("@adminUserPwd", userPwd),
             new SqlParameter("@adminUserNewPwd", newPwd)};
             CheckUserLogin.spName = "spUpdateAdminListPwd";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 0;
             break;
         case 1:
             parameters = new SqlParameter[3] {
             new SqlParameter("@teacherNo", userName),
             new SqlParameter("@teacherUserPwd", userPwd),
              new SqlParameter("@teacherUserNewPwd", newPwd)};
             CheckUserLogin.spName = "spUpdateTeachersListPwd";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 1;
             break;
         case 2:
             parameters = new SqlParameter[3] {
             new SqlParameter("@teacherNo", userName),
             new SqlParameter("@teacherUserPwd", userPwd),
              new SqlParameter("@teacherUserNewPwd", newPwd)};
             CheckUserLogin.spName = "spUpdateTeachersListPwd";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 2;
             break;
         case 3:
             parameters = new SqlParameter[3] {
             new SqlParameter("@studentNo",userName),
             new SqlParameter("@studentUserPwd", userPwd),
             new SqlParameter("@studentUserNewPwd", newPwd)};
             CheckUserLogin.spName = "spUpdateStudentsListPwd";
             CheckUserLogin.sqlParammeters = parameters;
             CheckUserLogin.userType = 3;
             break;
         default:
             break;
     }
     return CheckUserLogin;
 }