?? auto.aspx.cs.svn-base
字號:
?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.SqlClient;
public partial class AutoManage_Auto : System.Web.UI.Page
{
private static bool Readcheck;
private static bool Fullcheck;
private static bool Yufacheck;
private static bool ReadAutocheck;
private static bool FullAutocheck;
private static bool YufaAutocheck;
protected void Page_Load(object sender, EventArgs e)
{
// Clear();
if (Session["USERSTYLE"] == "TEACHER")
{
LabTno.Text = Session["USERID"].ToString();
TB_Chutiren.ReadOnly = true;
TB_Chutiren.Text = Session["USERID"].ToString();
}
else
{
Dialog("對不起,你沒有權限訪問這個頁面!");
Response.Redirect("~/SystemManage/Login.aspx");
}
int s,t,q;
string ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
if (Readcheck)
{
string[] Readth = (string[])Session["Readth"];
string sqlread = "SELECT TRNO,TRGRADE FROM V_TESTREAD WHERE TRNO IN('";
for (s = 0; s < Readth.Length; s++)
{
if (s != Readth.Length - 1)
{
sqlread += Readth[s] + "','";
}
else
{
sqlread += Readth[s] + "')";
}
}
SqlConnection myConnection1 = new SqlConnection(ConnectionString);
SqlDataAdapter command1 = new SqlDataAdapter(sqlread, myConnection1);
myConnection1.Open();
DataSet mydataset1 = new DataSet();
//command1.CommandType = CommandType.Text;
command1.Fill(mydataset1, "V_TESTREAD");
GridView_Read.DataSource = mydataset1;
GridView_Read.DataBind();
myConnection1.Close();
// ReadAutocheck = false;
}
else if (ReadAutocheck)
{
string ReadAutosql = (string)Session["ReadAutosql"];
string sqlreadauto = ReadAutosql;
SqlConnection myConnection1 = new SqlConnection(ConnectionString);
SqlDataAdapter command1 = new SqlDataAdapter(sqlreadauto, myConnection1);
myConnection1.Open();
DataSet mydataset1 = new DataSet();
//command1.CommandType = CommandType.Text;
command1.Fill(mydataset1, "V_TESTREAD");
GridView_Read.DataSource = mydataset1;
GridView_Read.DataBind();
myConnection1.Close();
// Readcheck = false;
}
if (Fullcheck)
{
string[] Fullth = (string[])Session["Fullth"];
string sqlfull = "SELECT TFNO,TFGRADE FROM V_TESTFULL WHERE TFNO IN('";
for (t = 0; t < Fullth.Length; t++)
{
if (t != Fullth.Length - 1)
{
sqlfull += Fullth[t] + "','";
}
else
{
sqlfull += Fullth[t] + "')";
}
}
SqlConnection myConnection2 = new SqlConnection(ConnectionString);
SqlDataAdapter command2 = new SqlDataAdapter(sqlfull, myConnection2);
myConnection2.Open();
DataSet mydataset2 = new DataSet();
//command2.CommandType = CommandType.Text;
command2.Fill(mydataset2, "V_TESTFULL");
GridView_Full.DataSource = mydataset2;
GridView_Full.DataBind();
myConnection2.Close();
// FullAutocheck = false;
}
else if (FullAutocheck)
{
string FullAutosql = (string)Session["FullAutosql"];
string sqlfullauto = FullAutosql;
// Fullcheck = false;
SqlConnection myConnection2 = new SqlConnection(ConnectionString);
SqlDataAdapter command2 = new SqlDataAdapter(sqlfullauto, myConnection2);
myConnection2.Open();
DataSet mydataset2 = new DataSet();
//command2.CommandType = CommandType.Text;
command2.Fill(mydataset2, "V_TESTFULL");
GridView_Full.DataSource = mydataset2;
GridView_Full.DataBind();
myConnection2.Close();
}
if (Yufacheck)
{
string[] Yufath = (string[])Session["Yufath"];
string sqlyf = "SELECT TSNO,TSGRADE FROM V_TESTSYNTAX WHERE TSNO IN('";
for (q = 0; q < Yufath.Length; q++)
{
if (q != Yufath.Length - 1)
{
sqlyf += Yufath[q] + "','";
}
else
{
sqlyf += Yufath[q] + "')";
}
}
// YufaAutocheck = false;
SqlConnection myConnection3 = new SqlConnection(ConnectionString);
SqlDataAdapter command3 = new SqlDataAdapter(sqlyf, myConnection3);
myConnection3.Open();
DataSet mydataset3 = new DataSet();
//command3.CommandType = CommandType.Text;
command3.Fill(mydataset3, "V_TESTSYNTAX");
GridView_Yf.DataSource = mydataset3;
GridView_Yf.DataBind();
myConnection3.Close();
}
else if (YufaAutocheck)
{
string YufaAutosql = (string)Session["YufaAutosql"];
string sqlyfauto = YufaAutosql;
// Yufacheck = false;
SqlConnection myConnection3= new SqlConnection(ConnectionString);
SqlDataAdapter command3 = new SqlDataAdapter(sqlyfauto, myConnection3);
myConnection3.Open();
DataSet mydataset3= new DataSet();
//command3.CommandType = CommandType.Text;
command3.Fill(mydataset3, "V_TESTSYNTAX");
GridView_Yf.DataSource = mydataset3;
GridView_Yf.DataBind();
myConnection3.Close();
}
}
private void Dialog(String Str)
{
Response.Write(@"<script type='text/JavaScript'>");
Response.Write(@"alert('" + Str + "');");
//Response.Write(@"window.location='./list_logingroup.aspx';");
Response.Write(@"</script>");
}
protected void BtnReadAuto_Click(object sender, EventArgs e)
{
ReadAutocheck = true;
Readcheck = false;
string nandu = DropDownList1.Text;
string ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);
string sql = "SELECT TOP 4 TRNO,TRGRADE FROM V_TESTREAD WHERE TRGRADE='" + nandu + "'ORDER BY newid()";
SqlDataAdapter command=new SqlDataAdapter(sql,myConnection);
myConnection.Open();
DataSet mydataset = new DataSet();
//command.CommandType = CommandType.Text;
command.Fill(mydataset, "V_TESTREAD");
GridView_Read.DataSource =mydataset;
GridView_Read.DataBind();
myConnection.Close();
Session["ReadAutosql"] = sql;
}
protected void GridView_Read_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void BtnFullAuto_Click(object sender, EventArgs e)
{
FullAutocheck = true;
Fullcheck = false;
string nandu = DropDownList1.Text;
string ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);
string sql = "SELECT TOP 1 TFNO,TFGRADE FROM V_TESTFULL WHERE TFGRADE='" + nandu + "'ORDER BY newid()";
SqlDataAdapter command = new SqlDataAdapter(sql, myConnection);
myConnection.Open();
DataSet mydataset = new DataSet();
//command.CommandType = CommandType.Text;
command.Fill(mydataset, "V_TESTFULL");
GridView_Full.DataSource = mydataset;
GridView_Full.DataBind();
myConnection.Close();
Session["FullAutosql"] = sql;
}
protected void BtnYufaAuto_Click(object sender, EventArgs e)
{
YufaAutocheck = true;
Yufacheck = false;
string nandu = DropDownList1.Text;
string ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);
string sql = "SELECT TOP 30 TSNO,TSGRADE FROM V_TESTSYNTAX WHERE TSGRADE='" + nandu + "'ORDER BY newid()";
SqlDataAdapter command = new SqlDataAdapter(sql, myConnection);
myConnection.Open();
DataSet mydataset = new DataSet();
//command.CommandType = CommandType.Text;
command.Fill(mydataset, "V_TESTSYNTAX");
GridView_Yf.DataSource = mydataset;
GridView_Yf.DataBind();
myConnection.Close();
Session["YufaAutosql"] = sql;
}
protected void BtnCommit_Click(object sender, EventArgs e)
{
SqlData sql=new SqlData();
int i, j, k;
string[] readth = new string[GridView_Read.Rows.Count];
string[] fullth = new string[GridView_Full.Rows.Count];
string[] yfth = new string[GridView_Yf.Rows.Count];
string sjbiao = "TAB_TESTINFO";
string readbiao = "TAB_SAVETESTREAD";
string fullbiao = "TAB_SAVETESTFULL";
string yfbiao = "TAB_SAVETESTSYNTAX";
string chutiren = TB_Chutiren.Text;
string nandu = DropDownList1.Text;
string sjbianhao = TB_Shijuanbianhao.Text;
string manfen = TB_Manfen.Text;
string leixing = DropDownList2.Text;
string kaoshishijian = TB_Kaoshi.Text;
string kaishishijian = TB_Kaishi.Text;
String[] insert ={ sjbianhao, kaoshishijian, kaishishijian, manfen, nandu, leixing, chutiren };
sql.InsertRow(sjbiao,insert,insert.Length);
sql.SqlDataClose();
//////////////////////////////////insert into saveread
for (i = 0; i < GridView_Read.Rows.Count; i++)
{
readth[i] = GridView_Read.Rows[i].Cells[0].Text;
string[] readtj ={ ""+(i+1), readth[i],sjbianhao};
sql.InsertRow(readbiao, readtj, readtj.Length);
sql.SqlDataClose();
}
///////////////////////////////insert into saveyufa
for (k = 0; k < GridView_Yf.Rows.Count; k++)
{
yfth[k] = GridView_Yf.Rows[k].Cells[0].Text;
string[] yftj ={ ""+(i+k+1), yfth[k],sjbianhao };
sql.InsertRow(yfbiao, yftj, yftj.Length);
sql.SqlDataClose();
}
///////////////////////////////insert into savefull
for (j = 0; j < GridView_Full.Rows.Count; j++)
{
fullth[j] = GridView_Full.Rows[j].Cells[0].Text;
string[] fulltj ={ ""+(k+i+j+1),sjbianhao, fullth[j] };
sql.InsertRow(fullbiao, fulltj, fulltj.Length);
sql.SqlDataClose();
}
Dialog("試卷已生成!!");
Clear();
//Response.Redirect("~/SystemManage/TeacherMain.aspx");
}
protected void Clear()
{
Session.Remove("Readth");
Session.Remove("ReadAutosql");
Session.Remove("Fullth");
Session.Remove("FullAutosql");
Session.Remove("Yufath");
Session.Remove("YufaAutosql");
Readcheck=false;
Fullcheck = false;
Yufacheck = false;
ReadAutocheck = false;
FullAutocheck = false;
YufaAutocheck = false;
}
protected void BtnReadByhand_Click(object sender, EventArgs e)
{
Readcheck = true;
ReadAutocheck = false;
Server.Transfer("ByHand_Read.aspx");
}
protected void BtnFull_Byhand_Click(object sender, EventArgs e)
{
Fullcheck = true;
FullAutocheck = false;
Server.Transfer("ByHand_Full.aspx");
}
protected void BtnYufa_Byhand_Click(object sender, EventArgs e)
{
Yufacheck = true;
YufaAutocheck = false;
Server.Transfer("ByHand_Snytax.aspx");
}
/*
* protected void GridView_Read_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView_Read.DeleteRow(GridView_Read.SelectedIndex);
}
*/
protected void BtnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("~/SystemManage/TeacherMain.aspx");
}
protected void BtnReturn_Click(object sender, EventArgs e)
{
Response.Redirect("~/SystemManage/TeacherMain.aspx");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -