示例#1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            string labelName = "XY_POLL_" + txtName.Text.Trim();
            string title = this.txtTitle.Text.Trim();

            Model.PollInfo poll = new XYECOM.Model.PollInfo();
            Business.Poll pollBLL = new XYECOM.Business.Poll();

            poll.LabelName = labelName;
            poll.Title = title;
            poll.Mode = XYECOM.Model.PollMode.Single;

            if (rdoCheck.Checked) poll.Mode = XYECOM.Model.PollMode.Check;

            int lastPollId = 0;

            pollBLL.Insert(poll, out lastPollId);

            int optionTotal = Core.MyConvert.GetInt32(this.OptionTotal.Value);

            Business.PollOption optionBLL = new XYECOM.Business.PollOption();
            Model.PollOptionInfo 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.PollOptionInfo();
                optionInfo.Option = option;
                optionInfo.PollId = lastPollId;

                optionBLL.Insert(optionInfo);
            }

            Response.Redirect("PollLabelList.aspx");
        }
示例#2
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (!XYECOM.Core.XYRequest.IsPost()) return;

            int pollId = XYECOM.Core.XYRequest.GetQueryInt("pollId", 0);

            if (pollId <= 0) return;

            Business.Poll pollBLL = new XYECOM.Business.Poll();
            Model.PollInfo poll = pollBLL.GetItem(pollId);

            if (poll == null) return;

            poll.LabelName = "XY_POLL_" + this.txtName.Text.Trim();
            poll.Title = this.txtTitle.Text.Trim();
            poll.Mode = XYECOM.Model.PollMode.Single;
            if (rdoCheck.Checked) poll.Mode = XYECOM.Model.PollMode.Check;

            pollBLL.Update(poll);

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

            Business.PollOption opBLL = new XYECOM.Business.PollOption();
            Model.PollOptionInfo optionInfo = null;

            string option = "" ;
            int optionId = 0;
            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)
                {
                    optionInfo = opBLL.GetItem(optionId);

                    if (optionInfo != null)
                    {
                        optionInfo.Option = option;
                        opBLL.Update(optionInfo);
                    }
                    else
                    {
                        optionInfo = new XYECOM.Model.PollOptionInfo();
                        optionInfo.Option = option;
                        optionInfo.PollId = poll.PollId;

                        opBLL.Insert(optionInfo);
                    }

                }
                else
                {
                    optionInfo = new XYECOM.Model.PollOptionInfo();
                    optionInfo.Option = option;
                    optionInfo.PollId = poll.PollId;

                    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("�޸ijɹ���", "PollLabelList.aspx",true);
        }