public List <UserHouseOwnerInfo> GetList() { string cmdText = @"select UserId,HouseOwnerId,Password from UserHouseOwner order by LastUpdatedDate desc " ; List <UserHouseOwnerInfo> list = new List <UserHouseOwnerInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText)) { if (reader != null && reader.HasRows) { while (reader.Read()) { UserHouseOwnerInfo model = new UserHouseOwnerInfo(); model.UserId = reader.GetGuid(0); model.HouseOwnerId = reader.GetGuid(1); model.Password = reader.GetString(2); list.Add(model); } } } return(list); }
public List <UserHouseOwnerInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { string cmdText = @"select UserId,HouseOwnerId,Password from UserHouseOwner"; if (!string.IsNullOrEmpty(sqlWhere)) { cmdText += " where 1=1 " + sqlWhere; } List <UserHouseOwnerInfo> list = new List <UserHouseOwnerInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { UserHouseOwnerInfo model = new UserHouseOwnerInfo(); model.UserId = reader.GetGuid(0); model.HouseOwnerId = reader.GetGuid(1); model.Password = reader.GetString(2); list.Add(model); } } } return(list); }
public List <UserHouseOwnerInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; string cmdText = @"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, UserId,HouseOwnerId,Password from UserHouseOwner" ; if (!string.IsNullOrEmpty(sqlWhere)) { cmdText += " where 1=1 " + sqlWhere; } cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " "; List <UserHouseOwnerInfo> list = new List <UserHouseOwnerInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { UserHouseOwnerInfo model = new UserHouseOwnerInfo(); model.UserId = reader.GetGuid(1); model.HouseOwnerId = reader.GetGuid(2); model.Password = reader.GetString(3); list.Add(model); } } } return(list); }
public UserHouseOwnerInfo GetModel(object UserId) { UserHouseOwnerInfo model = null; string cmdText = @"select top 1 UserId,HouseOwnerId,Password from UserHouseOwner where UserId = @UserId " ; SqlParameter parm = new SqlParameter("@UserId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(UserId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parm)) { if (reader != null) { while (reader.Read()) { model = new UserHouseOwnerInfo(); model.UserId = reader.GetGuid(0); model.HouseOwnerId = reader.GetGuid(1); model.Password = reader.GetString(2); } } } return(model); }
private void AddUserHouseOwner(HttpContext context) { if (string.IsNullOrWhiteSpace(context.Request.Form["houseOwnerId"])) { context.Response.Write("{\"success\": false, \"message\": \"参数houseOwnerId值不能为空,请检查\"}"); return; } Guid houseOwnerId = Guid.Empty; Guid.TryParse(context.Request.Form["houseOwnerId"], out houseOwnerId); if (houseOwnerId.Equals(Guid.Empty)) { context.Response.Write("{\"success\": false, \"message\": \"参数houseOwnerId值无效,请检查\"}"); return; } if (string.IsNullOrWhiteSpace(context.Request.Form["userName"])) { context.Response.Write("{\"success\": false, \"message\": \"参数userName值不能为空,请检查\"}"); return; } MembershipUser user = Membership.GetUser(context.Request.Form["userName"]); if (user == null) { context.Response.Write("{\"success\": false, \"message\": \"参数userName值无效,请检查\"}"); return; } UserHouseOwnerInfo model = new UserHouseOwnerInfo(); model.UserId = user.ProviderUserKey; model.HouseOwnerId = houseOwnerId; model.Password = ""; UserHouseOwner bll = new UserHouseOwner(); string message = "操作成功"; if (bll.Insert(model) == 110) { message = "已存在相同记录"; } context.Response.Write("{\"success\": true, \"message\": \"" + message + "!\"}"); return; }
public int Update(UserHouseOwnerInfo model) { string cmdText = @"update UserHouseOwner set Password = @Password where UserId = @UserId and HouseOwnerId = @HouseOwnerId " ; SqlParameter[] parms = { new SqlParameter("@UserId", SqlDbType.UniqueIdentifier), new SqlParameter("@HouseOwnerId", SqlDbType.UniqueIdentifier), new SqlParameter("@Password", SqlDbType.VarChar, 30) }; parms[0].Value = model.UserId; parms[1].Value = model.HouseOwnerId; parms[2].Value = model.Password; return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms)); }
public int Insert(UserHouseOwnerInfo model) { if (IsExist(model.UserId, model.HouseOwnerId)) { return(110); } string cmdText = @"insert into UserHouseOwner (UserId,HouseOwnerId,Password) values (@UserId,@HouseOwnerId,@Password) " ; SqlParameter[] parms = { new SqlParameter("@UserId", SqlDbType.UniqueIdentifier), new SqlParameter("@HouseOwnerId", SqlDbType.UniqueIdentifier), new SqlParameter("@Password", SqlDbType.VarChar, 30) }; parms[0].Value = model.UserId; parms[1].Value = model.HouseOwnerId; parms[2].Value = model.Password; return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(UserHouseOwnerInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(UserHouseOwnerInfo model) { return(dal.Insert(model)); }