コード例 #1
0
ファイル: EditVote.aspx.cs プロジェクト: davinx/himedi
 private void btnEditVote_Click(object sender, EventArgs e)
 {
     if (StoreHelper.GetVoteCounts(voteId) > 0)
     {
         ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
     }
     else
     {
         int num;
         VoteInfo vote = new VoteInfo();
         vote.VoteName = Globals.HtmlEncode(txtAddVoteName.Text.Trim());
         vote.VoteId = voteId;
         if (int.TryParse(txtMaxCheck.Text.Trim(), out num))
         {
             vote.MaxCheck = num;
         }
         else
         {
             vote.MaxCheck = -2147483648;
         }
         IList<VoteItemInfo> list = null;
         if (!string.IsNullOrEmpty(txtValues.Text.Trim()))
         {
             list = new List<VoteItemInfo>();
             string[] strArray = 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)
                 {
                     ShowMsg("投票选项长度限制在60个字符以内", false);
                     return;
                 }
                 item.VoteItemName = Globals.HtmlEncode(strArray[i]);
                 list.Add(item);
             }
         }
         else
         {
             ShowMsg("投票选项不能为空", false);
             return;
         }
         vote.VoteItems = list;
         if (ValidationVote(vote))
         {
             if (StoreHelper.UpdateVote(vote))
             {
                 ShowMsg("修改投票成功", true);
             }
             else
             {
                 ShowMsg("修改投票失败", false);
             }
         }
     }
 }
コード例 #2
0
ファイル: AddVote.aspx.cs プロジェクト: davinx/himedi
 private void btnAddVote_Click(object sender, EventArgs e)
 {
     int num;
     VoteInfo vote = new VoteInfo();
     vote.VoteName = Globals.HtmlEncode(txtAddVoteName.Text.Trim());
     vote.IsBackup = checkIsBackup.Checked;
     if (int.TryParse(txtMaxCheck.Text.Trim(), out num))
     {
         vote.MaxCheck = num;
     }
     else
     {
         vote.MaxCheck = -2147483648;
     }
     IList<VoteItemInfo> list = null;
     if (!string.IsNullOrEmpty(txtValues.Text.Trim()))
     {
         list = new List<VoteItemInfo>();
         string[] strArray = 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)
             {
                 ShowMsg("投票选项长度限制在60个字符以内", false);
                 return;
             }
             item.VoteItemName = Globals.HtmlEncode(strArray[i]);
             list.Add(item);
         }
     }
     else
     {
         ShowMsg("投票选项不能为空", false);
         return;
     }
     vote.VoteItems = list;
     if (ValidationVote(vote))
     {
         if (StoreHelper.CreateVote(vote) > 0)
         {
             ShowMsg("成功的添加了一个投票", true);
             txtAddVoteName.Text = string.Empty;
             checkIsBackup.Checked = false;
             txtMaxCheck.Text = string.Empty;
             txtValues.Text = string.Empty;
         }
         else
         {
             ShowMsg("添加投票失败", false);
         }
     }
 }
コード例 #3
0
ファイル: VoteDao.cs プロジェクト: ZhangVic/asp1110git
 public int CreateVoteItem(VoteItemInfo voteItem, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_VoteItems(VoteId, VoteItemName, ItemCount) Values(@VoteId, @VoteItemName, @ItemCount)");
     this.database.AddInParameter(sqlStringCommand, "VoteId", DbType.Int64, voteItem.VoteId);
     this.database.AddInParameter(sqlStringCommand, "VoteItemName", DbType.String, voteItem.VoteItemName);
     this.database.AddInParameter(sqlStringCommand, "ItemCount", DbType.Int32, voteItem.ItemCount);
     if (dbTran == null)
     {
         return this.database.ExecuteNonQuery(sqlStringCommand);
     }
     return this.database.ExecuteNonQuery(sqlStringCommand, dbTran);
 }
コード例 #4
0
ファイル: SubsiteStoreProvider.cs プロジェクト: davinx/himedi
 public abstract int CreateVoteItem(VoteItemInfo voteItem, DbTransaction dbTran);
コード例 #5
0
ファイル: DataMapper.cs プロジェクト: davinx/himedi
 public static VoteItemInfo PopulateVoteItem(IDataRecord reader)
 {
     VoteItemInfo info = new VoteItemInfo();
     info.VoteId = (long) reader["VoteId"];
     info.VoteItemId = (long) reader["VoteItemId"];
     info.VoteItemName = (string) reader["VoteItemName"];
     info.ItemCount = (int) reader["ItemCount"];
     return info;
 }
コード例 #6
0
ファイル: AddVote.cs プロジェクト: ZhangVic/asp1110git
 private void btnAddVote_Click(object sender, EventArgs e)
 {
     if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim()))
     {
         this.ShowMsg("关键字重复!", false);
     }
     else
     {
         string str = string.Empty;
         if (!this.fileUpload.HasFile)
         {
             this.ShowMsg("请上传一张封面图", false);
         }
         else
         {
             try
             {
                 str = StoreHelper.UploadVoteImage(this.fileUpload.PostedFile);
             }
             catch
             {
                 this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                 return;
             }
             if (this.calendarStartDate.SelectedDate.HasValue)
             {
                 if (!this.calendarEndDate.SelectedDate.HasValue)
                 {
                     this.ShowMsg("请选择活动结束时间", false);
                 }
                 else
                 {
                     VoteInfo vote = new VoteInfo {
                         VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()),
                         Keys = this.txtKeys.Text.Trim(),
                         IsBackup = this.checkIsBackup.Checked
                     };
                     int result = 1;
                     if (int.TryParse(this.txtMaxCheck.Text.Trim(), out result))
                     {
                         vote.MaxCheck = result;
                     }
                     vote.ImageUrl = str;
                     vote.StartDate = this.calendarStartDate.SelectedDate.Value;
                     vote.EndDate = this.calendarEndDate.SelectedDate.Value;
                     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 (StoreHelper.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);
                         }
                     }
                 }
             }
             else
             {
                 this.ShowMsg("请选择活动开始时间", false);
             }
         }
     }
 }
コード例 #7
0
ファイル: EditVote.cs プロジェクト: ZhangVic/asp1110git
 private void btnEditVote_Click(object sender, EventArgs e)
 {
     if (StoreHelper.GetVoteCounts(this.voteId) > 0)
     {
         this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false);
     }
     else
     {
         VoteInfo voteById = StoreHelper.GetVoteById(this.voteId);
         if ((voteById.Keys != this.txtKeys.Text.Trim()) && ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim()))
         {
             this.ShowMsg("关键字重复!", false);
         }
         else
         {
             if (this.fileUpload.HasFile)
             {
                 try
                 {
                     ResourcesHelper.DeleteImage(voteById.ImageUrl);
                     this.imgPic.ImageUrl = voteById.ImageUrl = StoreHelper.UploadVoteImage(this.fileUpload.PostedFile);
                 }
                 catch
                 {
                     this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                     return;
                 }
             }
             voteById.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
             voteById.Keys = this.txtKeys.Text.Trim();
             int result = 1;
             if (int.TryParse(this.txtMaxCheck.Text.Trim(), out result))
             {
                 voteById.MaxCheck = result;
             }
             voteById.StartDate = this.calendarStartDate.SelectedDate.Value;
             voteById.EndDate = this.calendarEndDate.SelectedDate.Value;
             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;
             }
             voteById.VoteItems = list;
             if (this.ValidationVote(voteById))
             {
                 if (StoreHelper.UpdateVote(voteById))
                 {
                     this.ShowMsg("修改投票成功", true);
                 }
                 else
                 {
                     this.ShowMsg("修改投票失败", false);
                 }
             }
         }
     }
 }