public IList <PlayerPictureNewInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select PlayerId,PictureId,Sort,IsHeadImg from PlayerPictureNew "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <PlayerPictureNewInfo> list = new List <PlayerPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureNewInfo model = new PlayerPictureNewInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); model.Sort = reader.GetInt32(2); model.IsHeadImg = reader.GetBoolean(3); list.Add(model); } } } return(list); }
public IList <PlayerPictureNewInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select PlayerId,PictureId,Sort,IsHeadImg from PlayerPictureNew order by LastUpdatedDate desc " ); IList <PlayerPictureNewInfo> list = new List <PlayerPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureNewInfo model = new PlayerPictureNewInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); model.Sort = reader.GetInt32(2); model.IsHeadImg = reader.GetBoolean(3); list.Add(model); } } } return(list); }
public PlayerPictureNewInfo GetModel(object PlayerId) { PlayerPictureNewInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 PlayerId,PictureId,Sort,IsHeadImg from PlayerPictureNew 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 PlayerPictureNewInfo(); model.PlayerId = reader.GetGuid(0); model.PictureId = reader.GetGuid(1); model.Sort = reader.GetInt32(2); model.IsHeadImg = reader.GetBoolean(3); } } } return(model); }
public IList <PlayerPictureNewInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select count(*) from PlayerPictureNew "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms); if (totalRecords == 0) { return(new List <PlayerPictureNewInfo>()); } sb.Clear(); 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,Sort,IsHeadImg from PlayerPictureNew " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <PlayerPictureNewInfo> list = new List <PlayerPictureNewInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { PlayerPictureNewInfo model = new PlayerPictureNewInfo(); model.PlayerId = reader.GetGuid(1); model.PictureId = reader.GetGuid(2); model.Sort = reader.GetInt32(3); model.IsHeadImg = reader.GetBoolean(4); list.Add(model); } } } return(list); }
public int Update(PlayerPictureNewInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update PlayerPictureNew set PictureId = @PictureId,Sort = @Sort,IsHeadImg = @IsHeadImg where PlayerId = @PlayerId " ); SqlParameter[] parms = { new SqlParameter("@PlayerId", SqlDbType.UniqueIdentifier), new SqlParameter("@PictureId", SqlDbType.UniqueIdentifier), new SqlParameter("@Sort", SqlDbType.Int), new SqlParameter("@IsHeadImg", SqlDbType.Bit) }; parms[0].Value = model.PlayerId; parms[1].Value = model.PictureId; parms[2].Value = model.Sort; parms[3].Value = model.IsHeadImg; return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms)); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(PlayerPictureNewInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(PlayerPictureNewInfo model) { return(dal.Insert(model)); }
public void SaveActivityPlayerNew(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 sAge = context.Request.Form["ctl00$cphMain$txtAge"].Trim(); string sOccupation = context.Request.Form["ctl00$cphMain$txtOccupation"].Trim(); string sPhone = context.Request.Form["ctl00$cphMain$txtPhone"].Trim(); string sLocation = context.Request.Form["ctl00$cphMain$txtLocation"].Trim(); string sProfessional = context.Request.Form["ctl00$cphMain$txtProfessional"].Trim(); string sDescr = context.Request.Form["ctl00$cphMain$txtDescr"].Trim(); string sPictureIdList = context.Request.Form["pictureId"].TrimEnd(','); string sVoteCount = context.Request.Form["ctl00$cphMain$txtActualVoteCount"].Trim(); sVoteCount = sVoteCount == "" ? "0" : sVoteCount; string sVirtualVoteCount = context.Request.Form["ctl00$cphMain$txtUpdateVoteCount"].Trim(); sVirtualVoteCount = sVirtualVoteCount == "" ? "0" : sVirtualVoteCount; string sIsDisable = context.Request.Form["isDisable"].Trim(); ActivitySubjectNew bllAS = new ActivitySubjectNew(); ActivitySubjectNewInfo info = new ActivitySubjectNewInfo(); info = bllAS.GetModel(sActivityId); if (info.SignUpCount >= info.MaxVoteCount) { context.Response.Write("{\"success\": false,\"message\": \"报名数已达上限\"}"); return; } Guid gId = Guid.Empty; if (id != "") { Guid.TryParse(id, out gId); } Guid activityId = Guid.Empty; Guid.TryParse(sActivityId, out activityId); ActivityPlayerNewInfo model = new ActivityPlayerNewInfo(); model.LastUpdatedDate = DateTime.Now; model.Remark = ""; model.Id = gId; model.ActivityId = activityId; model.UserId = WebCommon.GetUserId(); model.Named = sName; model.Age = int.Parse(sAge); model.Occupation = sOccupation; model.Phone = sPhone; model.Location = sLocation; model.Professional = sProfessional; model.Descr = sDescr; model.VoteCount = int.Parse(sVoteCount); model.VirtualVoteCount = int.Parse(sVirtualVoteCount); model.IsDisable = bool.Parse(sIsDisable); ActivityPlayerNew bll = new ActivityPlayerNew(); PlayerPictureNew bllPP = new PlayerPictureNew(); int effect = -1; if (!gId.Equals(Guid.Empty)) { effect = bll.Update(model); if (effect > 0) { bllPP.Delete(model.Id); int index = 1; foreach (string sPictureId in sPictureIdList.Split(',')) { PlayerPictureNewInfo infoPP = new PlayerPictureNewInfo(); Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); infoPP.PlayerId = model.Id; infoPP.PictureId = pictureId; infoPP.Sort = index; infoPP.IsHeadImg = index == 1 ? true : false; bllPP.Insert(infoPP); index++; } } } else { Guid playerId = bll.InsertByOutput(model); if (!playerId.Equals(Guid.Empty)) { effect = 1; int index = 1; foreach (string sPictureId in sPictureIdList.Split(',')) { PlayerPictureNewInfo infoPP = new PlayerPictureNewInfo(); Guid pictureId = Guid.Empty; Guid.TryParse(sPictureId, out pictureId); infoPP.PlayerId = playerId; infoPP.PictureId = pictureId; infoPP.Sort = index; infoPP.IsHeadImg = index == 1 ? true : false; bllPP.Insert(infoPP); index++; } } } 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 + "\"}"); } }