tianjiatimu.aspx.cs
来自「用asp.net开发的考试系统」· CS 代码 · 共 60 行
CS
60 行
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 Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((bool )Session["kaoti"] == false ) {
Response.Redirect("bianji.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string conn = ConfigurationManager.AppSettings["strconn"];
SqlConnection cn = new SqlConnection(conn);
cn.Open();
SqlCommand com=new SqlCommand ( );
string sql1="insert into wendati(kaoshi,question,jointime,difficulty,answer) values('"+Request.QueryString["kaoshiid"]+"','"+TextBox1.Text.ToString()+"','"+DateTime.Now.ToShortDateString()+"','"+DropDownList1.SelectedValue +"','"+TextBox2.Text .ToString()+"')";
string sql2 = "insert into xuanzeti(kaoshi,question,jointime,difficulty,answer) values('" + Request.QueryString["kaoshiid"] + "','" + TextBox5.Text.ToString() + "','" + DateTime.Now.ToShortDateString() + "','" + DropDownList3.SelectedValue + "','" +DropDownList7.SelectedValue + "')";
string sql3 = "insert into tiankongti(kaoshi,question,jointime,difficulty,answer) values('" + Request.QueryString["kaoshiid"] + "','" + TextBox9.Text.ToString() + "','" + DateTime.Now.ToShortDateString() + "','" + DropDownList5.SelectedValue + "','" + TextBox10.Text + "')";
com.Connection=cn;
try
{com.CommandText=sql1;
com.ExecuteNonQuery();
com.CommandText=sql2;
com.ExecuteNonQuery();
com.CommandText = sql3;
com.ExecuteNonQuery();
Button1.Enabled = true;
Response.Write("<script language=javascript> alert('添加成功');</script>");
Response.Write ("<script language=javascript>window.location='javascript:history.go(-1)';</script>");
}
catch (SqlException ex)
{
Response.Write(ex.Message.ToString());
}
finally { cn.Close(); }
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("showexam.aspx");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?