⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 question.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Questionnaire
{
    public partial class Question : System.Web.UI.Page
    {
        protected string LineOption = "none";
        BasePage bp = null;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack && Request.QueryString["Action"] != string.Empty)
            {
                string action = Request.QueryString["Action"];
                ViewState["Action"] = action;
                switch (action) 
                {
                    case "Add":
                        if (!PowerTree.PowerPass.isPass("013003002", PowerTree.PowerPanel.PowerType.add))
                        {
                            bp = new BasePage();
                            bp.PageError("对不起,你没有添加问卷调查的权限!", "../index.aspx");
                        }
                        break;
                    case "mod":
                        if (!PowerTree.PowerPass.isPass("013003004", PowerTree.PowerPanel.PowerType.update))
                        {
                            bp = new BasePage();
                            bp.PageError("对不起,你没有修改问卷调查的权限!", "../index.aspx");
                        }
                        break;
                }
                
            }
            if (!IsPostBack && Request.QueryString["ID"] != string.Empty && Request.QueryString["ID"] != null)
            {
                this.fillContent(Convert.ToInt32(Request.QueryString["ID"]));
                this.lbtilte.Text = "修改问卷";
            }
        }
        #region 填充数据
        protected void fillContent(int id)
        {
            YXShop.BLL.QuestionList datab = new YXShop.BLL.QuestionList();
            YXShop.Model.QuestionList data = datab.GetId(id);
            this.tbContent.Text = data.QuestionContent;
            this.tbAddress.Text = data.QuestionArea != string.Empty ? fillArea(Convert.ToInt32(data.QuestionArea)) : string.Empty;
            this.ClassID.Value = data.QuestionArea;
            this.rbPutout.SelectedValue = data.Result.ToString();
            this.rbSingleText.Checked = data.QuestionType.ToString() == "1" ? true : false;
            this.rbMunitText.Checked = data.QuestionType.ToString() == "2" ? true : false;
            this.rbSingleOption.Checked = data.QuestionType.ToString() == "3" ? true : false;
            this.rbMumintOption.Checked = data.QuestionType.ToString() == "4" ? true : false;
            this.rbSelect.Checked = data.QuestionType.ToString() == "5" ? true : false;
            this.rbPutoutOption.Checked = data.QuestionType.ToString() == "6" ? true : false;
            if (data.QuestionType.ToString() == "3" || data.QuestionType.ToString() == "4" || data.QuestionType.ToString() == "5")
            {
                LineOption = "";
                this.tbOption.Text = data.QuestionDiscription != string.Empty ? data.QuestionDiscription.ToString().Replace(",", "\n") : string.Empty;
            }

        }
        #endregion

        #region 地区
        protected string fillArea(int id)
        {
            YXShop.BLL.Provinces datab = new YXShop.BLL.Provinces();
            List<YXShop.Model.Provinces> data = datab.GetListByColumn("ID", id);
            if (data.Count > 0)
            {
                return data[0].Province_city.ToString();
            }
            return string.Empty;
        }
        #endregion

        #region 修改\添加
        protected void submitButton_Click(object sender, EventArgs e)
        {
            YXShop.BLL.QuestionList datab = new YXShop.BLL.QuestionList();
            YXShop.Model.QuestionList data = new YXShop.Model.QuestionList();
            data.QuestionID = Request.QueryString["SurveyID"].ToString();
            data.QuestionArea = this.ClassID.Value != string.Empty ? this.ClassID.Value.ToString() : "";
            data.QuestionContent = this.tbContent.Text;
            string QuestionType = "0";
            if (this.rbSingleText.Checked == true)
                QuestionType = "1";
            if (this.rbMunitText.Checked == true)
                QuestionType = "2";
            if (this.rbSingleOption.Checked == true)
                QuestionType = "3";
            if (this.rbMumintOption.Checked == true)
                QuestionType = "4";
            if (this.rbSelect.Checked == true)
                QuestionType = "5";
            if (this.rbPutoutOption.Checked == true)
                QuestionType = "6";

            data.QuestionType = Convert.ToInt32(QuestionType);
            string ResultStr = "0";
            if (QuestionType == "3" || QuestionType == "4" || QuestionType == "5")
            {
                data.QuestionDiscription = this.tbOption.Text != string.Empty ? this.tbOption.Text.ToString().Replace("\n", ",") : string.Empty;
                if (this.tbOption.Text != string.Empty)
                {
                    string[] reStr = this.tbOption.Text.ToString().Replace("\n", ",").Split(',');
                    for (int i = 1; i < reStr.Length; i++)
                    {
                        ResultStr += ",0";
                    }
                }
            }
            data.Necessarily = Convert.ToInt32(this.rbPutout.SelectedValue);
            data.InvestigateEndDate = System.DateTime.Now;
            data.InvestigateStateDate = System.DateTime.Now;

            data.Result = ResultStr;
            BasePage bp = new BasePage();
            if (ViewState["Action"].ToString() == "Add")
            {
                datab.Create(data);
                //更新导航

                bp.PageRight("添加栏目成功!", "QuestionList.aspx?SurveyID=" + Request.QueryString["SurveyID"].ToString() + "");
            }
            else
            {
                data.ID = Convert.ToInt32(Request.QueryString["ID"]);
                //更新导航
                datab.Amend(data);
                bp.PageRight("修改栏目成功!", "QuestionList.aspx?SurveyID=" + Request.QueryString["SurveyID"].ToString() + "");
            }
        }
        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -