protected void bt_Enabled_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (QNA_QuestionBLL.GetModelList("Project=" + ViewState["ID"].ToString() + " AND IsFirstQ='Y'").Count != 1) { MessageBox.Show(this, "对不起,问卷的标题中必须有,且只能有一项“问卷入口”!"); return; } if (QNA_QuestionBLL.GetModelList("Project=" + ViewState["ID"].ToString() + " AND IsLastQ='Y'").Count != 1) { MessageBox.Show(this, "对不起,问卷的标题中必须有,且只能有一项“问卷出口”!"); return; } QNA_ProjectBLL p = new QNA_ProjectBLL((int)ViewState["ID"]); p.Model.Enabled = "Y"; p.Model.UpdateStaff = (int)Session["UserID"]; p.Update(); MessageBox.ShowAndRedirect(this, "启用成功!", "QNA_ProjectList.aspx"); } }
private void BindData() { QNA_ProjectBLL p = new QNA_ProjectBLL((int)ViewState["Project"]); lb_ProjectName.Text = p.Model.Name; ViewState["ResultStatistics"] = p.GetResultStatistics(); lb_TotalCount.Text = p.GetResultCount().ToString(); if (MCSTabControl1.SelectedIndex == 0) { rpt_Question.DataSource = QNA_QuestionBLL.GetModelList("Project=" + p.Model.ID.ToString() + " ORDER BY SortCode"); rpt_Question.DataBind(); rpt_Question.Visible = true; gv_List.Visible = false; } else { gv_List.DataSource = (DataTable)ViewState["ResultStatistics"]; gv_List.DataBind(); rpt_Question.Visible = false; gv_List.Visible = true; } }
private void BindRepeater() { if ((int)ViewState["Project"] != 0) { Repeater1.DataSource = QNA_QuestionBLL.GetModelList("Project=" + ViewState["Project"].ToString() + " ORDER BY SortCode"); Repeater1.DataBind(); } }
private void BindData() { QNA_ResultBLL r = new QNA_ResultBLL((int)ViewState["Result"]); if (r.Model != null) { QNA_Project p = new QNA_ProjectBLL(r.Model.Project).Model; lb_ProjectName.Text = p.Name; Repeater1.DataSource = QNA_QuestionBLL.GetModelList("Project=" + r.Model.Project.ToString() + " ORDER BY ID"); Repeater1.DataBind(); 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"); foreach (QNA_Result_Detail _d in r.Items.Where <QNA_Result_Detail>(d => d.Question == question)) { if (_d.Option != 0) { if (rbl_Result.Visible) { rbl_Result.SelectedValue = _d.Option.ToString(); } else if (cbl_Result.Visible) { foreach (ListItem item in cbl_Result.Items) { if (item.Value == _d.Option.ToString()) { item.Selected = true; } } } } if (_d.OptionText != "") { tbx_Result.Visible = true; tbx_Result.Text = _d.OptionText; } } } } }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null?int.Parse(Request.QueryString["ID"]) : 0; ViewState["Project"] = Request.QueryString["Project"] != null?int.Parse(Request.QueryString["Project"]) : 0; #endregion BindDropDown(); if ((int)ViewState["ID"] != 0) { //修改 BindData(); #region 绑定跳转问题 ddl_NextQuestion.DataSource = QNA_QuestionBLL.GetModelList("Project=" + ViewState["Project"].ToString() + " AND IsFirstQ='N' AND ID<>" + ViewState["ID"].ToString()); ddl_NextQuestion.DataBind(); ddl_NextQuestion.Items.Insert(0, new ListItem("请选择...", "0")); #endregion } else { //新增 if ((int)ViewState["Project"] == 0) { MessageBox.ShowAndRedirect(this, "参数错误,未包含所属问卷Project参数!", "QNA_ProjectList.aspx"); return; } BindProjectInfo(); #region 新增标题时,界面控件默认设置 tr_OptionList.Visible = false; ((DropDownList)pl_detail.FindControl("QNA_Question_IsFirstQ")).SelectedValue = "N"; ((DropDownList)pl_detail.FindControl("QNA_Question_IsLastQ")).SelectedValue = "N"; #endregion } } }
private void BindProjectInfo() { QNA_Project q = new QNA_ProjectBLL((int)ViewState["Project"]).Model; if (q != null) { lb_ProjectName.Text = q.Name; #region 绑定默认下一标题控件 DropDownList ddl_DefaultNextQ = ((DropDownList)pl_detail.FindControl("QNA_Question_DefaultNextQ")); ddl_DefaultNextQ.DataTextField = "Title"; ddl_DefaultNextQ.DataValueField = "ID"; ddl_DefaultNextQ.DataSource = QNA_QuestionBLL.GetModelList("Project=" + ViewState["Project"].ToString() + " AND IsFirstQ='N' AND ID<>" + ViewState["ID"].ToString()); ddl_DefaultNextQ.DataBind(); ddl_DefaultNextQ.Items.Insert(0, new ListItem("无默认下一标题", "0")); #endregion if (q.DisplayType == 2) { //顺序显示 ddl_NextQuestion.Enabled = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 获取页面参数 ViewState["Project"] = Request.QueryString["Project"] != null?int.Parse(Request.QueryString["Project"]) : 0; ViewState["RelateClient"] = Request.QueryString["RelateClient"] != null?int.Parse(Request.QueryString["RelateClient"]) : 0; ViewState["RelateTask"] = Request.QueryString["RelateTask"] != null?int.Parse(Request.QueryString["RelateTask"]) : 0; #endregion ViewState["PreviousQuestion"] = new Stack <int>(); //上一题堆栈 ViewState["CurrentQuestion"] = 0; ViewState["NextQuestion"] = 0; ViewState["LastQuestion"] = 0; ViewState["ResultDetails"] = new List <QNA_Result_Detail>(); #region 验证问卷启用标及及出入口 if ((int)ViewState["Project"] == 0) { MessageBox.ShowAndClose(this, "对不起,参数中必须有指定的调研问卷Project!"); return; } else { QNA_Project p = new QNA_ProjectBLL((int)ViewState["Project"]).Model; if (p == null || p.Enabled == "N") { MessageBox.ShowAndClose(this, "对不起,该调研问卷未启用!"); return; } else { lb_ProjectName.Text = p.Name; if (p.DisplayType == 2) //顺序模式问卷 { Response.Redirect("QNA_FillQuestionnairB.aspx" + Request.Url.Query); return; } IList <QNA_Question> firstq = QNA_QuestionBLL.GetModelList("Project=" + p.ID.ToString() + " AND IsFirstQ='Y'"); if (firstq.Count != 1) { MessageBox.ShowAndClose(this, "对不起,该调研问卷没有正确的入口!"); return; } else { BindQuestion(firstq[0].ID); } IList <QNA_Question> lastq = QNA_QuestionBLL.GetModelList("Project=" + p.ID.ToString() + " AND IsLastQ='Y'"); if (lastq.Count != 1) { MessageBox.ShowAndClose(this, "对不起,该调研问卷没有正确的出口!"); return; } else { ViewState["LastQuestion"] = lastq[0].ID; } } } #endregion } }