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

📄 coltest.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.Data.Sql;
using System.Data.SqlClient;

public partial class Student_ColTest_ColTest : System.Web.UI.Page
{
    public static readonly string ConnectionString =
        ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    public static String TestNo;//试卷编号
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["USERSTYLE"] == "STUDENT")
        {
            sNo.Text=Session["USERID"].ToString();
            sName.Text = Session["USERNAME"].ToString();
        }
        else
        {
            Dialog("对不起,你没有权限访问这个页面!");
            Response.Redirect("~/SystemManage/Login.aspx");
        }
    }
    protected void btnTest_Click(object sender, EventArgs e)
    {
        SqlData sql = new SqlData();
        String[] StrAll ={ "没选择试卷!", "学号或姓名没有输入或该考生没有注册!" };
        String StrSno = sNo.Text.ToString();
        String StrSname = sName.Text.ToString();
        if (txtView.SelectedIndex != -1)
        {
            String TableName = "TAB_STUDENT";
            String ColumnName1 = "SNO";
            String ColumnName2 = "SNAME";
            if (sql.CheckStringUnique(TableName, ColumnName1, ColumnName2, StrSno, StrSname) != 1)
            {
                Dialog(StrAll[1]);
                return;
            }
        }
        else
        {
            Dialog(StrAll[0]);
            return;
        }
        String sParam = "?TestNo=" + TestNo;
        sParam += "&Sno=" +StrSno;
        Response.Redirect("~/Student/ColTest/Test.aspx" + sParam);
    }
    protected void txtView_SelectedIndexChanged(object sender, EventArgs e)
    {
        String TableName="TAB_TESTINFO";
        SqlConnection myConnection = new SqlConnection(ConnectionString);
        String conString = "SELECT * FROM " + TableName;
        try
        {
            SqlDataAdapter myAdapter = new SqlDataAdapter(conString, myConnection);
            DataSet myDateSet = new DataSet();
            myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            myAdapter.Fill(myDateSet, "getTestRead");
            DataTable Table = myDateSet.Tables[0];
            TestNo=(String)Table.Rows[txtView.SelectedIndex].ItemArray[0];
            testNo.Text = TestNo;
        }
        finally
        {
            myConnection.Close();
        }
    }
    private void Dialog(String Str)
    {
        Response.Write(@"<script type='text/JavaScript'>");
        Response.Write(@"alert('" + Str + "');");
        Response.Write(@"</script>");
    }
    protected void BtnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/SystemManage/Main.aspx");
    }
}

⌨️ 快捷键说明

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