private void btnAddVote_Click(object sender, EventArgs e) { int num; VoteInfo vote = new VoteInfo(); vote.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()); 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.CreateVote(vote) > 0) { this.ShowMsg("成功的添加了一个投票", true); this.txtAddVoteName.Text = string.Empty; this.checkIsBackup.Checked = false; this.txtMaxCheck.Text = string.Empty; this.txtValues.Text = string.Empty; } else { this.ShowMsg("添加投票失败", false); } } }
private void btnAddVote_Click(object sender, System.EventArgs e) { VoteInfo voteInfo = new VoteInfo(); voteInfo.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()); 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.CreateVote(voteInfo) > 0) { this.ShowMsg("成功的添加了一个投票", true); this.txtAddVoteName.Text = string.Empty; this.checkIsBackup.Checked = false; this.txtMaxCheck.Text = string.Empty; this.txtValues.Text = string.Empty; return; } this.ShowMsg("添加投票失败", false); }