/// <summary> /// 注册用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool AddUser(Tab_user user) { SqlParameter[] p = new SqlParameter[] { new SqlParameter("@u_emaile", user.U_emaile), new SqlParameter("@u_name", user.U_name), new SqlParameter("@u_password", user.U_password), new SqlParameter("@LastLoginTime", user.LastLoginTime) }; int i = SQLHelper.ExecuteNonQuery("AddUser", CommandType.StoredProcedure, p); return(i > 0); }
/// <summary> /// 获取所有用户 /// </summary> /// <returns></returns> public static List <Tab_user> GetAllUsers() { SqlDataReader dr = SQLHelper.ExecuteReader("GetAllUsers", CommandType.StoredProcedure, null); List <Tab_user> List = new List <Tab_user>(); while (dr.Read()) { Tab_user tab_user = new Tab_user(); tab_user.U_emaile = Convert.ToString(dr["u_emaile"]); tab_user.U_name = Convert.ToString(dr["u_name"]); tab_user.U_password = Convert.ToString(dr["u_password"]); tab_user.U_head = Convert.ToString(dr["u_head"]); tab_user.U_message = Convert.ToString(dr["u_message"]); tab_user.U_collect = Convert.ToString(dr["u_collect"]); tab_user.LastLoginTime = Convert.ToDateTime(dr["lastLoginTime"]); tab_user.U_discuss = Convert.ToString(dr["u_discuss"]); List.Add(tab_user); } return(List); }
/// <summary> /// 根据用户Emaile获取用户信息 /// </summary> /// <param name="u_emaile"></param> /// <returns></returns> public static Tab_user GetUserByEmaile(string u_emaile) { SqlParameter[] p = new SqlParameter[] { new SqlParameter("@u_emaile", u_emaile) }; SqlDataReader dr = SQLHelper.ExecuteReader("GetUserByEmaile", CommandType.StoredProcedure, p); Tab_user tab_user = new Tab_user(); if (dr.Read()) { tab_user.U_emaile = Convert.ToString(dr["u_emaile"]); tab_user.U_name = Convert.ToString(dr["u_name"]); tab_user.U_password = Convert.ToString(dr["u_password"]); tab_user.U_head = Convert.ToString(dr["u_head"]); tab_user.U_message = Convert.ToString(dr["u_message"]); tab_user.U_collect = Convert.ToString(dr["u_collect"]); tab_user.LastLoginTime = Convert.ToDateTime(dr["LastLoginTime"]); tab_user.U_discuss = Convert.ToString(dr["u_discuss"]); } return(tab_user); }