Exemplo n.º 1
0
        private void Bind()
        {
            if (!Id.Equals(Guid.Empty))
            {
                Page.Title = "编辑选手";

                ActivityPlayerNew bll = new ActivityPlayerNew();
                DataSet           ds  = bll.GetModelOW(Id);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0)
                {
                    DataTable dt = ds.Tables[0];
                    txtName.Value             = dt.Rows[0]["Named"].ToString();
                    txtAge.Value              = dt.Rows[0]["Age"].ToString();
                    txtOccupation.Value       = dt.Rows[0]["Occupation"].ToString();
                    txtPhone.Value            = dt.Rows[0]["Phone"].ToString();
                    txtLocation.Value         = dt.Rows[0]["Location"].ToString();
                    txtProfessional.Value     = dt.Rows[0]["Professional"].ToString();
                    txtDescr.Value            = dt.Rows[0]["Descr"].ToString();
                    imgSinglePicture.Src      = dt.Rows[0]["PictureId"] is DBNull ? "../../Images/nopic.gif" : string.Format("{0}{1}/PC/{1}_1{2}", dt.Rows[0]["FileDirectory"], dt.Rows[0]["RandomFolder"], dt.Rows[0]["FileExtension"]);
                    hImgSinglePictureId.Value = dt.Rows[0]["PictureId"].ToString();
                    txtActualVoteCount.Value  = dt.Rows[0]["VoteCount"].ToString();
                    txtUpdateVoteCount.Value  = dt.Rows[0]["VirtualVoteCount"].ToString();
                    hId.Value  = Id.ToString();
                    asId.Value = dt.Rows[0]["ActivityId"].ToString();

                    PlayerPictureNew bllPP = new PlayerPictureNew();
                    DataSet          dsPP  = bllPP.GetListOW(dt.Rows[0]["Id"].ToString());
                    if (dsPP != null && dsPP.Tables.Count > 0 && dsPP.Tables[0].Rows != null && dsPP.Tables[0].Rows.Count > 0)
                    {
                        DataTable dtPP  = dsPP.Tables[0];
                        int       index = 0;
                        foreach (DataRow row in dtPP.Rows)
                        {
                            if (index > 0)
                            {
                                string html = "<div class=\"row_col w110 mb10\" style=\"width:200px;\">" +
                                              "<table style=\"width:100%;\">" +
                                              "<tr>" +
                                              "<td style=\"width:130px; vertical-align:top;\">" +
                                              "<img src=\"{0}\" alt=\"\" width=\"110px\" height=\"110px\" />" +
                                              "<input type=\"hidden\" name=\"PicId\" value=\"{1}\"/>" +
                                              "</td>" +
                                              "<td style=\"width:70px;\">" +
                                              "<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-remove',plain:true\" onclick=\"$(this).parents('.row_col').remove()\">删 除</a>" +
                                              "</td>" +
                                              "</tr>" +
                                              "</table>" +
                                              "</div>";
                                string picSrc = row["PictureId"] is DBNull ? "../../Images/nopic.gif" : string.Format("{0}{1}/PC/{1}_1{2}", row["FileDirectory"], row["RandomFolder"], row["FileExtension"]);
                                html = string.Format(html, picSrc, row["PictureId"].ToString());
                                imgContentPicture.InnerHtml += html;
                            }
                            index++;
                        }
                    }
                    if (Convert.ToBoolean(dt.Rows[0]["IsDisable"]))
                    {
                        rdFalse.Checked = false;
                        rdTrue.Checked  = true;
                    }
                    else
                    {
                        rdFalse.Checked = true;
                        rdTrue.Checked  = false;
                    }
                }
            }
            else
            {
                asId.Value = Request["asId"];
            }
        }
Exemplo n.º 2
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 + "\"}");
            }
        }