public IList <PlayerPictureInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select PlayerId,PictureId from PlayerPicture order by LastUpdatedDate desc " ); IList <PlayerPictureInfo> list = new List <PlayerPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureInfo model = new PlayerPictureInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <PlayerPictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select PlayerId,PictureId from PlayerPicture "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <PlayerPictureInfo> list = new List <PlayerPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureInfo model = new PlayerPictureInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <PlayerPictureInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, PlayerId,PictureId from PlayerPicture " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <PlayerPictureInfo> list = new List <PlayerPictureInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureInfo model = new PlayerPictureInfo(); model.PlayerId = reader.GetGuid(1); model.PictureId = reader.GetGuid(2); list.Add(model); } } } return(list); }
public PlayerPictureInfo GetModel(object PlayerId) { PlayerPictureInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 PlayerId,PictureId from PlayerPicture where PlayerId = @PlayerId " ); SqlParameter parm = new SqlParameter("@PlayerId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(PlayerId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm)) { if (reader != null) { while (reader.Read()) { model = new PlayerPictureInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); } } } return(model); }
public int Update(PlayerPictureInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update PlayerPicture set PictureId = @PictureId where PlayerId = @PlayerId " ); SqlParameter[] parms = { new SqlParameter("@PlayerId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.PlayerId; parms[1].Value = model.PictureId; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(PlayerPictureInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(PlayerPictureInfo model) { return(dal.Insert(model)); }
public void SaveActivityPlayer(HttpContext context) { try { string id = context.Request.Form["ctl00$cphMain$hId"].Trim(); string sActivityId = context.Request.Form["ctl00$cphMain$asId"].Trim(); string sName = context.Request.Form["ctl00$cphMain$txtName"].Trim(); string sPictureId = context.Request.Form["pictureId"].Trim(); string sDetailInfo = context.Request.Form["detailInfo"].Trim(); string sActualVoteCount = context.Request.Form["ctl00$cphMain$txtActualVoteCount"].Trim(); sActualVoteCount = sActualVoteCount == "" ? "0" : sActualVoteCount; string sUpdateVoteCount = context.Request.Form["ctl00$cphMain$txtUpdateVoteCount"].Trim(); sUpdateVoteCount = sUpdateVoteCount == "" ? "0" : sUpdateVoteCount; string sIsDisable = context.Request.Form["isDisable"].Trim(); sDetailInfo = HttpUtility.HtmlDecode(sDetailInfo); Guid gId = Guid.Empty; if (id != "") { Guid.TryParse(id, out gId); } Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); Guid activityId = Guid.Empty; Guid.TryParse(sActivityId, out activityId); ActivityPlayerInfo model = new ActivityPlayerInfo(); model.LastUpdatedDate = DateTime.Now; model.Remark = ""; model.HeadPicture = ""; model.Id = gId; model.ActivityId = activityId; model.Named = sName; model.DetailInformation = sDetailInfo; model.ActualVoteCount = int.Parse(sActualVoteCount); model.UpdateVoteCount = int.Parse(sUpdateVoteCount); model.IsDisable = bool.Parse(sIsDisable); if (string.IsNullOrWhiteSpace(model.DetailInformation)) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } ActivityPlayer bll = new ActivityPlayer(); PlayerPicture bllPP = new PlayerPicture(); PlayerPictureInfo infoPP = new PlayerPictureInfo(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); if (effect > 0) { infoPP.PlayerId = model.Id; infoPP.PictureId = pictureId; bllPP.Delete(model.Id); bllPP.Insert(infoPP); } } else { Guid playerId = bll.InsertByOutput(model); if (!playerId.Equals(Guid.Empty)) { effect = 1; if (!pictureId.Equals(Guid.Empty)) { infoPP.PlayerId = playerId; infoPP.PictureId = pictureId; bllPP.Insert(infoPP); } } } if (effect == 110) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}"); return; } if (effect < 1) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Error + "\"}"); return; } context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\"}"); } catch (Exception ex) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}"); } }