protected void bt_Next_Click(object sender, EventArgs e)
    {
        List <QNA_Result_Detail> _details = new List <QNA_Result_Detail>();

        if (cbl_Result.Visible && cbl_Result.SelectedValue != "")
        {
            foreach (ListItem item in cbl_Result.Items)
            {
                if (item.Selected)
                {
                    QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                    _resultdetail.Question = (int)ViewState["CurrentQuestion"];
                    _resultdetail.Option   = int.Parse(item.Value);
                    _details.Add(_resultdetail);
                }
            }
        }

        if (rbl_Result.Visible)
        {
            if (rbl_Result.SelectedValue == "")
            {
                MessageBox.Show(this, "单选列表中,您必须选择一项!");
                rbl_Result.Focus();
                return;
            }
            else
            {
                QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                _resultdetail.Question = (int)ViewState["CurrentQuestion"];
                _resultdetail.Option   = int.Parse(rbl_Result.SelectedValue);
                _details.Add(_resultdetail);
            }
        }

        if (tbx_Result.Visible)
        {
            if (tbx_Result.Text == "")
            {
                MessageBox.Show(this, "文本框中,您必须填写内容!");
                tbx_Result.Focus();
                return;
            }
            else
            {
                QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                _resultdetail.Question   = (int)ViewState["CurrentQuestion"];
                _resultdetail.OptionText = tbx_Result.Text;
                _details.Add(_resultdetail);
            }
        }

        foreach (QNA_Result_Detail item in _details)
        {
            ((List <QNA_Result_Detail>)ViewState["ResultDetails"]).Add(item);
        }

        ((Stack <int>)ViewState["PreviousQuestion"]).Push((int)ViewState["CurrentQuestion"]);
        BindQuestion((int)ViewState["NextQuestion"]);
    }
示例#2
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["Project"] != 0)
        {
            QNA_ResultBLL r = new QNA_ResultBLL();
            r.Model.Project      = (int)ViewState["Project"];
            r.Model.RelateClient = (int)ViewState["RelateClient"];
            r.Model.RelateTask   = (int)ViewState["RelateTask"];
            r.Model.InsertStaff  = (int)Session["UserID"];

            foreach (RepeaterItem _ri in Repeater1.Items)
            {
                int             question   = int.Parse(((Label)_ri.FindControl("lb_ID")).Text);
                RadioButtonList rbl_Result = (RadioButtonList)_ri.FindControl("rbl_Result");
                CheckBoxList    cbl_Result = (CheckBoxList)_ri.FindControl("cbl_Result");
                TextBox         tbx_Result = (TextBox)_ri.FindControl("tbx_Result");

                if (cbl_Result.Visible && cbl_Result.SelectedValue != "")
                {
                    foreach (ListItem item in cbl_Result.Items)
                    {
                        if (item.Selected)
                        {
                            QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                            _resultdetail.Question = question;
                            _resultdetail.Option   = int.Parse(item.Value);
                            r.Items.Add(_resultdetail);
                        }
                    }
                }

                if (rbl_Result.Visible)
                {
                    if (rbl_Result.SelectedValue == "")
                    {
                        MessageBox.Show(this, "单选列表中,您必须选择一项!");
                        rbl_Result.Focus();
                        return;
                    }
                    else
                    {
                        QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                        _resultdetail.Question = question;
                        _resultdetail.Option   = int.Parse(rbl_Result.SelectedValue);
                        r.Items.Add(_resultdetail);
                    }
                }

                if (tbx_Result.Visible)
                {
                    if (tbx_Result.Text == "")
                    {
                        MessageBox.Show(this, "文本框中,您必须填写内容!");
                        tbx_Result.Focus();
                        return;
                    }
                    else
                    {
                        QNA_Result_Detail _resultdetail = new QNA_Result_Detail();
                        _resultdetail.Question   = question;
                        _resultdetail.OptionText = tbx_Result.Text;
                        r.Items.Add(_resultdetail);
                    }
                }
            }

            Session["QuestionnaireResult"] = r.Add();

            MessageBox.ShowAndClose(this, "问卷保存成功!");
        }
    }