[b][/b]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Manager_addstudent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int i;
CommDB mydb = new CommDB();
string mysql, sn = "";
mysql = "SELECT*FROM student WHERE sno='" + TextBox1.Text + "'";
i = mydb.Rownum(mysql, "student", ref sn);
if (i > 0)
Response.Redirect("~/dispinfo.aspx?into=学号重复,不能添加该学生记录!");
else
{
string xb;
if (RadioButton1.Checked)
xb = "男";
else if (RadioButton2.Checked)
xb = "女";
else
xb = "";
mysql="INSERT INTO student(sID,sname,ssex,sclass,spwd)" +
"VALUES('TextBox1.Text + "','" + TextBox2.Text + "','" + xb +"','"+
TextBox3.Text + "','"+TextBox1.Text + "')";
mydb.ExecuteNonQuery(mysql); ;
Response.Redirect("~/dispinfo.aspx?into=学生记录已添加成功!");
}
}
}