private void btnEditVote_Click(object sender, EventArgs e)
 {
     if (SubsiteStoreHelper.GetVoteCounts(this.voteId) > 0)
     {
         this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
     }
     else
     {
         int      num;
         VoteInfo vote = new VoteInfo();
         vote.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
         vote.VoteId   = this.voteId;
         vote.IsBackup = this.checkIsBackup.Checked;
         if (int.TryParse(this.txtMaxCheck.Text.Trim(), out num))
         {
             vote.MaxCheck = num;
         }
         else
         {
             vote.MaxCheck = -2147483648;
         }
         IList <VoteItemInfo> list = null;
         if (!string.IsNullOrEmpty(this.txtValues.Text.Trim()))
         {
             list = new List <VoteItemInfo>();
             string[] strArray = this.txtValues.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
             for (int i = 0; i < strArray.Length; i++)
             {
                 VoteItemInfo item = new VoteItemInfo();
                 if (strArray[i].Length > 60)
                 {
                     this.ShowMsg("投票选项长度限制在60个字符以内", false);
                     return;
                 }
                 item.VoteItemName = Globals.HtmlEncode(strArray[i]);
                 list.Add(item);
             }
         }
         else
         {
             this.ShowMsg("投票选项不能为空", false);
             return;
         }
         vote.VoteItems = list;
         if (this.ValidationVote(vote))
         {
             if (SubsiteStoreHelper.UpdateVote(vote))
             {
                 this.ShowMsg("修改投票成功", true);
             }
             else
             {
                 this.ShowMsg("修改投票失败", false);
             }
         }
     }
 }
Beispiel #2
0
        private void btnEditVote_Click(object sender, System.EventArgs e)
        {
            if (SubsiteStoreHelper.GetVoteCounts(this.voteId) > 0)
            {
                this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
                return;
            }
            VoteInfo voteInfo = new VoteInfo();

            voteInfo.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
            voteInfo.VoteId   = this.voteId;
            voteInfo.IsBackup = this.checkIsBackup.Checked;
            int maxCheck;

            if (int.TryParse(this.txtMaxCheck.Text.Trim(), out maxCheck))
            {
                voteInfo.MaxCheck = maxCheck;
            }
            else
            {
                voteInfo.MaxCheck = -2147483648;
            }
            if (string.IsNullOrEmpty(this.txtValues.Text.Trim()))
            {
                this.ShowMsg("投票选项不能为空", false);
                return;
            }
            System.Collections.Generic.IList <VoteItemInfo> list = new System.Collections.Generic.List <VoteItemInfo>();
            string text = this.txtValues.Text.Trim().Replace("\r\n", "\n");

            string[] array = text.Replace("\n", "*").Split(new char[]
            {
                '*'
            });
            for (int i = 0; i < array.Length; i++)
            {
                VoteItemInfo voteItemInfo = new VoteItemInfo();
                if (array[i].Length > 60)
                {
                    this.ShowMsg("投票选项长度限制在60个字符以内", false);
                    return;
                }
                voteItemInfo.VoteItemName = Globals.HtmlEncode(array[i]);
                list.Add(voteItemInfo);
            }
            voteInfo.VoteItems = list;
            if (!this.ValidationVote(voteInfo))
            {
                return;
            }
            if (SubsiteStoreHelper.UpdateVote(voteInfo))
            {
                this.ShowMsg("修改投票成功", true);
                return;
            }
            this.ShowMsg("修改投票失败", false);
        }