📄 deleteclass.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.SqlClient;
public partial class deleteclass : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
int class_ID = Convert.ToInt32(this.TextBox1.Text);
SqlConnection con = DB.createconnection();
con.Open();
string commandstring = "delete all from class where class_ID=" + class_ID;
SqlCommand command = new SqlCommand(commandstring, con);
string commandstring1 = "delete from student where class_ID=" + class_ID;
SqlCommand command1 = new SqlCommand(commandstring1, con);
string commandstring2 = "delete from student where class_ID=" + class_ID;
SqlCommand command2 = new SqlCommand(commandstring2, con);
try
{
command.ExecuteNonQuery();
command1.ExecuteNonQuery();
command2.ExecuteNonQuery();
command.ExecuteReader();
command1.ExecuteReader();
command2.ExecuteReader();
con.Close();
Response.Write("<script '>alert('删除成功!');</script>");
}
catch { Response.Write("<script >alert('删除失败!');</script>"); }
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect(".aspx");
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
try
{
SqlConnection con = new SqlConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from class where class_ID ='" + TextBox1.Text + "'", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
catch { }
}
protected void Button3_Click(object sender, EventArgs e)
{
this.TextBox1.Text = "";
Response.Write("<script>alert('请重新输入!');</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -