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

📄 uquestion.aspx.cs

📁 一个多用户在线题库管理系统,可以实现各类试题的添加和管理
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using TQMS;
using TQMS.BusinessLogicLayer;
using TQMS.DataAccessHelper;

public partial class User_UQuestion : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            
            Common.BindDdlCourse(this.ddlCourse);//绑定科目下拉列表框
            Common.BindChapter(ddlChapter, int.Parse(ddlCourse.SelectedValue));
            this.ddlType.Items.Add(new ListItem("全选", "0"));//绑定题型下拉列表框
            Common.BindDdlType(this.ddlType);
            this.ddlDifficult.Items.Add(new ListItem("全选", "0"));
            Common.BindDdlDifficult(this.ddlDifficult);//绑定难度下拉列表框
           
        }
    }

    /// <summary>
    /// 自动绑定章目信息到章目下拉列表框中
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.ddlCourse.SelectedValue == "0" || this.ddlCourse.SelectedValue == "1")
        {
            this.ddlChapter.Items.Clear();
            return;
        }
        else
        {
            this.ddlChapter.Items.Clear();
            Common.BindChapter(this.ddlChapter, int.Parse(this.ddlCourse.SelectedValue));//绑定章节下拉列表框
        }
    }


    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {

            Label lbl = (Label)e.Item.FindControl("lblid");
            
              lbl.Text =(e.Item.ItemIndex+1).ToString()+". ";
           
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        Hashtable ht = new Hashtable();

        if (this.ddlChapter.Items.Count < 1)
        {
            Response.Write("<script language='javascript'>alert('暂无试题!!');</script>");
            this.DataList1.Visible = false;

            return;
        }
        if (this.ddlChapter.SelectedValue != "0")
        {
            ht.Add("TQ_ChapterID", this.ddlChapter.SelectedValue);
        }
        if (this.ddlType.SelectedValue != "0")
        {
            ht.Add("TQ_Type", this.ddlType.SelectedValue);
        }
        if (this.ddlDifficult.SelectedValue != "0")
        {
            ht.Add("TQ_DifficultyLevel", ddlDifficult.SelectedValue);
        }
        if (this.tbxKey1.Text != "")
        {
            string strKey = this.tbxKey1.Text.Trim();
            ht.Add("TQ_QuestionContent", strKey);
        }
        //DataTable dt = Question.QueryQuestionForShort(ht);
        DataTable dt = Question.QueryQuestion(ht);
     
       
        if (dt.Rows.Count <= 0)
        {
            this.lblEmptyMessge.Text = "没有符合条件的结果,请变换条件以进行重新查询";
            this.lblEmptyMessge.Visible = true;
            this.DataList1.Visible = false;
        }
        else
        {
            this.lblEmptyMessge.Visible = false;
            
            this.DataList1.Visible = true;
            this.DataList1.DataSource = dt;
            this.DataList1.DataBind();
        }
    }
/*
    protected void btnsave_Click(object sender, EventArgs e)
    {
        //Response.ContentType = "application/vnd.ms-excel";
        //Response.AddHeader("Content-Disposition", "inline;filename="
        //    + HttpUtility.UrlEncode("下载文件.xls", Encoding.UTF8));


        //如果输出为Word,修改为以下代码
        Response.ContentType = "application/ms-word";
        Response.AddHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode("test.doc", Encoding.UTF8));
        StringBuilder sb = new StringBuilder();
        System.IO.StringWriter sw = new System.IO.StringWriter(sb);
        System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
        //sb.Append("<html><body>");
        DataList1.RenderControl(hw);
        //DataList1.FindControl("questionTable").RenderControl(hw);
        
        //sb.Append("</body></html>");
        Response.Write(sb.ToString());
        Response.End();
    }
*/
}

⌨️ 快捷键说明

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