コード例 #1
0
ファイル: EditSubject.aspx.cs プロジェクト: xyecom/AMS
        protected override void BindData()
        {
            int voteId = XYECOM.Core.XYRequest.GetQueryInt("voteid", 0);

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

            if (backURL.Equals("")) backURL = "list.aspx";

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

            Model.VoteInfo vote = new Business.Vote().GetItem(voteId);

            if (vote == null) Alert("指定调查不存在或已被删除!", backURL);

            this.lblVoteTitle.Text = vote.Title;

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

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

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

            if (subject == null) Alert("调查问题信息不存在或已被删除!", backURL);

            txtSubject.Text = subject.Subject;
            rdolstType.SelectedValue = subject.StrType;

            if (subject.StrType.Equals("select") || subject.StrType.Equals("mselect"))
            {
                this.pnlOptions.Visible = true;

                this.rdolstType.Items[0].Enabled = false;
                this.rdolstType.Items[1].Enabled = false;

                InitOption(subjectId);
            }
            else
            {
                this.rdolstType.Items[2].Enabled = false;
                this.rdolstType.Items[3].Enabled = false;

                this.pnlOptions.Visible = false;
            }
        }
コード例 #2
0
ファイル: EditSubject.aspx.cs プロジェクト: xyecom/AMS
        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);
        }