Example #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            int voteId = XYECOM.Core.XYRequest.GetQueryInt("voteid", 0);

            backURL = XYECOM.Core.XYRequest.GetString("backURL1");

            if (voteId <= 0)
            {
                Alert("非法参数!", backURL);
            }

            Model.VoteSubjectInfo subject = new XYECOM.Model.VoteSubjectInfo();

            subject.Subject = this.txtSubject.Text.Trim();
            subject.StrType = this.rdolstType.SelectedValue;
            subject.VoteId = voteId;

            int subjectId = 0;

            new Business.VoteSubject().Insert(subject, out subjectId);

            if (subjectId > 0)
            {
                int optionTotal = Core.MyConvert.GetInt32(this.OptionTotal.Value);

                Business.VoteOptions optionBLL = new XYECOM.Business.VoteOptions();
                Model.VoteOptionsInfo optionInfo = null;

                for (int i = 1; i <= optionTotal; i++)
                {
                    string option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim();

                    if (string.IsNullOrEmpty(option)) continue;

                    optionInfo = new XYECOM.Model.VoteOptionsInfo();
                    optionInfo.Text = option;
                    optionInfo.SubjectId = subjectId;
                    optionInfo.VoteTotal = 0;

                    optionBLL.Insert(optionInfo);
                }
            }

            Response.Redirect(backURL);
        }
Example #2
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            int subjectId = XYECOM.Core.XYRequest.GetQueryInt("subjectId", 0);

            backURL = XYECOM.Core.XYRequest.GetString("backURL1");

            if (subjectId <= 0)
            {
                Alert("非法参数!", backURL);
            }

            Model.VoteSubjectInfo subject = new Business.VoteSubject().GetItem(subjectId);

            if (subject==null)
            {
                Alert("异常失败!", backURL);
            }

            subject.Subject = this.txtSubject.Text.Trim();
            subject.StrType = this.rdolstType.SelectedValue;

            int j = new Business.VoteSubject().Update(subject);

            string option = "";
            int optionId = 0;

            int total = XYECOM.Core.MyConvert.GetInt32(this.OptionTotal.Value.ToString());

            Business.VoteOptions opBLL = new XYECOM.Business.VoteOptions();
            Model.VoteOptionsInfo optionInfo = null;

            for (int i = 1; i <= total; i++)
            {
                option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim();

                if (string.IsNullOrEmpty(option)) continue;

                optionId = XYECOM.Core.XYRequest.GetInt("option_id_" + i, 0);

                if (optionId > 0)
                {
                    if (this.rdolstType.SelectedValue.Equals("text") || this.rdolstType.SelectedValue.Equals("mtext"))
                    {
                        opBLL.Delete(optionId);
                        continue;
                    }

                    optionInfo = opBLL.GetItem(optionId);

                    if (optionInfo != null)
                    {
                        optionInfo.Text = option;
                        opBLL.Update(optionInfo);
                    }
                    else
                    {
                        optionInfo = new XYECOM.Model.VoteOptionsInfo();
                        optionInfo.Text = option;
                        optionInfo.SubjectId = subjectId;

                        opBLL.Insert(optionInfo);
                    }

                }
                else
                {
                    if (this.rdolstType.SelectedValue.Equals("text") || this.rdolstType.SelectedValue.Equals("mtext"))
                    {
                        continue;
                    }

                    optionInfo = new XYECOM.Model.VoteOptionsInfo();
                    optionInfo.Text = option;
                    optionInfo.SubjectId = subjectId;

                    opBLL.Insert(optionInfo);
                }
            }

            string delIds = this.DelOptionIds.Value.ToString();
            string[] ids = delIds.Split(',');

            foreach (string id in ids)
            {
                int _Id = Core.MyConvert.GetInt32(id);

                if (_Id <= 0) continue;

                opBLL.Delete(_Id);
            }

            Alert("修改成功!", backURL, true);
        }