?? coltest.aspx.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 + -