public User Get(string Username, string Password) { User user = new User(); string sqlCommand = "SELECT * FROM [User] where CustomerID='" + Username+"' AND PassWord='******'"; using (IDataReader dataReader = ConnectionClass.GetInstance().ExecuteReader(sqlCommand)) { if (dataReader.Read()) { user.UserName = dataReader.GetString(0); user.PassWord = dataReader.GetString(1); } dataReader.Close(); } return user; }
public IQueryable<User> GetAll() { List<User> lsuser = new List<User>(); string sqlcm = "Select * from [user]"; using (IDataReader dr = ConnectionClass.GetInstance().ExecuteReader(sqlcm)) { while (dr.Read()) { User user = new User(); user.CustomerID = dr.GetInt32(0); user.PassWord = dr.GetString(2); lsuser.Add(user); } dr.Close(); } return lsuser.AsQueryable(); }
public string TestAddUser(User user) { var a = new IUserService(); var ret = a.Add(user); if (ret == 1) { return "success"; } else { return "failed"; } #endregion }
public int Delete(User user) { string sqlcm = "Delete from [user] where UserID=" + user.CustomerID; return ConnectionClass.GetInstance().ExecuteNonQuery(sqlcm); }
public int Update(User user) { string sqlcm = "update [user] set UserName='******',Password='******' where UserID=" + user.CustomerID; return ConnectionClass.GetInstance().ExecuteNonQuery(sqlcm); }
public int Add(User user) { string sqlcm = "insert into [User](UserName,Password) values('" + user.UserName + "','" + user.PassWord + "')"; //+ user.Picture == null ? " " : ",Picture=" + user.Picture + ")"; return ConnectionClass.GetInstance().ExecuteNonQuery(sqlcm); }