예제 #1
0
        public IList <ActivityPlayerNewInfo> 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,
			           Id,ActivityId,UserId,No,Named,Age,Occupation,Phone,Location,Professional,Descr,VoteCount,VirtualVoteCount,Remark,IsDisable,LastUpdatedDate
					   from ActivityPlayerNew "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ActivityPlayerNewInfo> list = new List <ActivityPlayerNewInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ActivityPlayerNewInfo model = new ActivityPlayerNewInfo();
                        model.Id               = reader.GetGuid(1);
                        model.ActivityId       = reader.GetGuid(2);
                        model.UserId           = reader.GetGuid(3);
                        model.Age              = reader.GetInt32(4);
                        model.Named            = reader.GetString(5);
                        model.Age              = reader.GetInt32(6);
                        model.Occupation       = reader.GetString(7);
                        model.Phone            = reader.GetString(8);
                        model.Location         = reader.GetString(9);
                        model.Professional     = reader.GetString(10);
                        model.Descr            = reader.GetString(11);
                        model.VoteCount        = reader.GetInt32(12);
                        model.VirtualVoteCount = reader.GetInt32(13);
                        model.Remark           = reader.GetString(14);
                        model.IsDisable        = reader.GetBoolean(15);
                        model.LastUpdatedDate  = reader.GetDateTime(16);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
예제 #2
0
        public int Insert(ActivityPlayerNewInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into ActivityPlayerNew (ActivityId,UserId,No,Named,Age,Occupation,Phone,Location,Professional,Descr,VoteCount,VirtualVoteCount,Remark,IsDisable,LastUpdatedDate)
			            values
						(@ActivityId,@UserId,@No,@Named,@Age,@Occupation,@Phone,@Location,@Professional,@Descr,@VoteCount,@VirtualVoteCount,@Remark,@IsDisable,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@ActivityId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@UserId",           SqlDbType.UniqueIdentifier),
                new SqlParameter("@No",               SqlDbType.Int),
                new SqlParameter("@Named",            SqlDbType.NVarChar,            30),
                new SqlParameter("@Age",              SqlDbType.Int),
                new SqlParameter("@Occupation",       SqlDbType.NVarChar,            50),
                new SqlParameter("@Phone",            SqlDbType.NVarChar,            20),
                new SqlParameter("@Location",         SqlDbType.NVarChar,            80),
                new SqlParameter("@Professional",     SqlDbType.NVarChar,            50),
                new SqlParameter("@Descr",            SqlDbType.NVarChar,          1000),
                new SqlParameter("@VoteCount",        SqlDbType.Int),
                new SqlParameter("@VirtualVoteCount", SqlDbType.Int),
                new SqlParameter("@Remark",           SqlDbType.NVarChar,           300),
                new SqlParameter("@IsDisable",        SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate",  SqlDbType.DateTime)
            };
            parms[0].Value  = model.ActivityId;
            parms[1].Value  = model.UserId;
            parms[2].Value  = model.No;
            parms[3].Value  = model.Named;
            parms[4].Value  = model.Age;
            parms[5].Value  = model.Occupation;
            parms[6].Value  = model.Phone;
            parms[7].Value  = model.Location;
            parms[8].Value  = model.Professional;
            parms[9].Value  = model.Descr;
            parms[10].Value = model.VoteCount;
            parms[11].Value = model.VirtualVoteCount;
            parms[12].Value = model.Remark;
            parms[13].Value = model.IsDisable;
            parms[14].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms));
        }
예제 #3
0
        public IList <ActivityPlayerNewInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ActivityId,UserId,No,Named,Age,Occupation,Phone,Location,Professional,Descr,VoteCount,VirtualVoteCount,Remark,IsDisable,LastUpdatedDate
                        from ActivityPlayerNew ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <ActivityPlayerNewInfo> list = new List <ActivityPlayerNewInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ActivityPlayerNewInfo model = new ActivityPlayerNewInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ActivityId       = reader.GetGuid(1);
                        model.UserId           = reader.GetGuid(2);
                        model.No               = reader.GetInt32(3);
                        model.Named            = reader.GetString(4);
                        model.Age              = reader.GetInt32(5);
                        model.Occupation       = reader.GetString(6);
                        model.Phone            = reader.GetString(7);
                        model.Location         = reader.GetString(8);
                        model.Professional     = reader.GetString(9);
                        model.Descr            = reader.GetString(10);
                        model.VoteCount        = reader.GetInt32(11);
                        model.VirtualVoteCount = reader.GetInt32(12);
                        model.Remark           = reader.GetString(13);
                        model.IsDisable        = reader.GetBoolean(14);
                        model.LastUpdatedDate  = reader.GetDateTime(15);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
예제 #4
0
        public ActivityPlayerNewInfo GetModel(object Id)
        {
            ActivityPlayerNewInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,ActivityId,UserId,No,Named,Age,Occupation,Phone,Location,Professional,Descr,VoteCount,VirtualVoteCount,Remark,IsDisable,LastUpdatedDate 
			            from ActivityPlayerNew
						where Id = @Id "                        );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                  = new ActivityPlayerNewInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ActivityId       = reader.GetGuid(1);
                        model.UserId           = reader.GetGuid(2);
                        model.No               = reader.GetInt32(3);
                        model.Named            = reader.GetString(4);
                        model.Age              = reader.GetInt32(5);
                        model.Occupation       = reader.GetString(6);
                        model.Phone            = reader.GetString(7);
                        model.Location         = reader.GetString(8);
                        model.Professional     = reader.GetString(9);
                        model.Descr            = reader.GetString(10);
                        model.VoteCount        = reader.GetInt32(11);
                        model.VirtualVoteCount = reader.GetInt32(12);
                        model.Remark           = reader.GetString(13);
                        model.IsDisable        = reader.GetBoolean(14);
                        model.LastUpdatedDate  = reader.GetDateTime(15);
                    }
                }
            }

            return(model);
        }
예제 #5
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Guid InsertByOutput(ActivityPlayerNewInfo model)
 {
     return(dal.InsertByOutput(model));
 }
예제 #6
0
        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 + "\"}");
            }
        }
예제 #7
0
        public Guid InsertByOutput(ActivityPlayerNewInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append("select Max(No) as MaxNo from ActivityPlayerNew where ActivityId=@ActivityId");
            SqlParameter parm = new SqlParameter("@ActivityId", SqlDbType.UniqueIdentifier);

            parm.Value = model.ActivityId;
            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        model.No = reader["MaxNo"] is DBNull ? 1 : reader.GetInt32(0) + 1;
                    }
                }
            }

            sb.Clear();
            sb.Append(@"insert into ActivityPlayerNew (ActivityId,UserId,No,Named,Age,Occupation,Phone,Location,Professional,Descr,VoteCount,VirtualVoteCount,Remark,IsDisable,LastUpdatedDate)
			            output inserted.Id values
						(@ActivityId,@UserId,@No,@Named,@Age,@Occupation,@Phone,@Location,@Professional,@Descr,@VoteCount,@VirtualVoteCount,@Remark,@IsDisable,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@ActivityId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@UserId",           SqlDbType.UniqueIdentifier),
                new SqlParameter("@No",               SqlDbType.Int),
                new SqlParameter("@Named",            SqlDbType.NVarChar,            30),
                new SqlParameter("@Age",              SqlDbType.Int),
                new SqlParameter("@Occupation",       SqlDbType.NVarChar,            50),
                new SqlParameter("@Phone",            SqlDbType.NVarChar,            20),
                new SqlParameter("@Location",         SqlDbType.NVarChar,            80),
                new SqlParameter("@Professional",     SqlDbType.NVarChar,            50),
                new SqlParameter("@Descr",            SqlDbType.NVarChar,          1000),
                new SqlParameter("@VoteCount",        SqlDbType.Int),
                new SqlParameter("@VirtualVoteCount", SqlDbType.Int),
                new SqlParameter("@Remark",           SqlDbType.NVarChar,           300),
                new SqlParameter("@IsDisable",        SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate",  SqlDbType.DateTime)
            };
            parms[0].Value  = model.ActivityId;
            parms[1].Value  = model.UserId;
            parms[2].Value  = model.No;
            parms[3].Value  = model.Named;
            parms[4].Value  = model.Age;
            parms[5].Value  = model.Occupation;
            parms[6].Value  = model.Phone;
            parms[7].Value  = model.Location;
            parms[8].Value  = model.Professional;
            parms[9].Value  = model.Descr;
            parms[10].Value = model.VoteCount;
            parms[11].Value = model.VirtualVoteCount;
            parms[12].Value = model.Remark;
            parms[13].Value = model.IsDisable;
            parms[14].Value = model.LastUpdatedDate;

            object obj = SqlHelper.ExecuteScalar(SqlHelper.HnztcTeamDbConnString, CommandType.Text, sb.ToString(), parms);

            if (obj != null)
            {
                return(Guid.Parse(obj.ToString()));
            }

            return(Guid.Empty);
        }
예제 #8
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ActivityPlayerNewInfo model)
 {
     return(dal.Update(model));
 }
예제 #9
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ActivityPlayerNewInfo model)
 {
     return(dal.Insert(model));
 }