Example #1
0
        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);
                }
            }
        }
Example #2
0
        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 (StoreHelper.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);
        }
Example #3
0
 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);
             }
         }
     }
 }
Example #4
0
        private void btnAddVote_Click(object obj, EventArgs eventArg)
        {
            if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim()))
            {
                this.ShowMsg("关键字重复!", false);
                return;
            }
            if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
            {
                this.ShowMsg("开始时间不能晚于结束时间!", false);
                return;
            }
            string uploadedImageUrl = this.uploader1.UploadedImageUrl;

            if (string.IsNullOrEmpty(uploadedImageUrl))
            {
                this.ShowMsg("请上传封面图片", false);
                return;
            }
            if (!this.calendarStartDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择活动开始时间", false);
                return;
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择活动结束时间", false);
                return;
            }
            VoteInfo voteInfo = new VoteInfo()
            {
                VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()),
                Keys     = this.txtKeys.Text.Trim(),
                IsBackup = this.checkIsBackup.Checked
            };
            int num = 1;

            if (int.TryParse(this.txtMaxCheck.Text.Trim(), out num))
            {
                voteInfo.MaxCheck = num;
            }
            voteInfo.ImageUrl  = uploadedImageUrl;
            voteInfo.StartDate = this.calendarStartDate.SelectedDate.Value;
            voteInfo.EndDate   = this.calendarEndDate.SelectedDate.Value;
            IList <VoteItemInfo> voteItemInfos = null;

            if (string.IsNullOrEmpty(this.txtValues.Text.Trim()))
            {
                this.ShowMsg("投票选项不能为空", false);
                return;
            }
            voteItemInfos = new List <VoteItemInfo>();
            //string str = this.txtValues.Text.Trim().Replace("DQAKAA==", "CgA=");
            //string[] strArrays = str.Replace("CgA=", "KgA=").Split(new char[] { '*' });
            string[] strArrays = this.txtValues.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[]
            {
                '*'
            });
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                VoteItemInfo voteItemInfo = new VoteItemInfo();
                if (strArrays[i].Length > 60)
                {
                    this.ShowMsg("投票选项长度限制在60个字符以内", false);
                    return;
                }
                voteItemInfo.VoteItemName = Globals.HtmlEncode(strArrays[i]);
                voteItemInfos.Add(voteItemInfo);
            }
            voteInfo.VoteItems = voteItemInfos;
            if (!this.ValidationVote(voteInfo))
            {
                return;
            }
            if (StoreHelper.CreateVote(voteInfo) <= 0)
            {
                this.ShowMsg("添加投票失败", false);
                return;
            }
            if (base.Request.QueryString["reurl"] != null)
            {
                this.ReUrl = base.Request.QueryString["reurl"].ToString();
            }
            this.ShowMsgAndReUrl("成功的添加了一个投票", true, this.ReUrl);
        }
Example #5
0
 private void btnAddVote_Click(object sender, EventArgs e)
 {
     if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim(), this.wid))
     {
         this.ShowMsg("关键字重复!", false);
     }
     else if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
     {
         this.ShowMsg("开始时间不能晚于结束时间!", false);
     }
     else
     {
         string uploadedImageUrl = this.uploader1.UploadedImageUrl;
         if (string.IsNullOrEmpty(uploadedImageUrl))
         {
             this.ShowMsg("请上传封面图片", false);
         }
         else if (!this.calendarStartDate.SelectedDate.HasValue)
         {
             this.ShowMsg("请选择活动开始时间", false);
         }
         else if (!this.calendarEndDate.SelectedDate.HasValue)
         {
             this.ShowMsg("请选择活动结束时间", false);
         }
         else
         {
             VoteInfo vote = new VoteInfo {
                 VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()),
                 IsBackup = this.checkIsBackup.Checked
             };
             int result = 1;
             if (int.TryParse(this.txtMaxCheck.Text.Trim(), out result))
             {
                 vote.MaxCheck = result;
             }
             vote.ImageUrl  = uploadedImageUrl;
             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)
                 {
                     if (base.Request.QueryString["reurl"] != null)
                     {
                         this.ReUrl = base.Request.QueryString["reurl"].ToString();
                     }
                     this.ShowMsgAndReUrl("成功的添加了一个投票", true, this.ReUrl);
                 }
                 else
                 {
                     this.ShowMsg("添加投票失败", false);
                 }
             }
         }
     }
 }
Example #6
0
        private void btnAddVote_Click(object sender, EventArgs e)
        {
            VoteInfo voteInfo = new VoteInfo();

            voteInfo.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim());
            voteInfo.IsBackup = true;
            int maxCheck = default(int);

            if (int.TryParse(this.txtMaxCheck.Text.Trim(), out maxCheck))
            {
                voteInfo.MaxCheck = maxCheck;
            }
            else
            {
                voteInfo.MaxCheck = -2147483648;
            }
            voteInfo.StartDate     = this.calendarStartDate.SelectedDate;
            voteInfo.EndDate       = this.calendarEndDate.SelectedDate;
            voteInfo.IsDisplayAtWX = this.chkDisplayWeixin.Checked;
            voteInfo.Keys          = string.Empty;
            if (this.chkDisplayWeixin.Checked)
            {
                if (string.IsNullOrEmpty(this.txtKeys.Text.Trim()))
                {
                    this.ShowMsg("关键字不能为空!", false);
                    return;
                }
                if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim()))
                {
                    this.ShowMsg("关键字重复!", false);
                    return;
                }
                voteInfo.Keys = this.txtKeys.Text.Trim();
                string empty = string.Empty;
                try
                {
                    string text2 = voteInfo.ImageUrl = this.UploadImage();
                }
                catch (Exception ex)
                {
                    this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限" + ex.Message, false);
                    return;
                }
            }
            IList <VoteItemInfo> list = null;

            if (!string.IsNullOrEmpty(this.txtValues.Text.Trim()))
            {
                list = new List <VoteItemInfo>();
                string   text3 = this.txtValues.Text.Trim().Replace("\r\n", "\n");
                string[] array = text3.Replace("\n", "*").Split('*');
                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))
                {
                    if (StoreHelper.CreateVote(voteInfo) > 0)
                    {
                        if (this.txtKeys.Text.Trim().Length > 0)
                        {
                            if (string.IsNullOrEmpty(voteInfo.ImageUrl))
                            {
                                voteInfo.ImageUrl = "/Storage/master/vote/default.jpg";
                            }
                            this.CreateVshopKeyReply(voteInfo.VoteId, voteInfo.ImageUrl);
                        }
                        this.ShowMsg("成功的添加了一个投票", true);
                        this.txtAddVoteName.Text      = string.Empty;
                        this.checkIsBackup.Checked    = false;
                        this.txtMaxCheck.Text         = string.Empty;
                        this.txtValues.Text           = string.Empty;
                        this.chkDisplayWeixin.Checked = false;
                        this.txtKeys.Text             = string.Empty;
                        this.liimg.Visible            = false;
                        this.likey.Visible            = false;
                    }
                    else
                    {
                        this.ShowMsg("添加投票失败", false);
                    }
                }
            }
            else
            {
                this.ShowMsg("投票选项不能为空", false);
            }
        }