Admin/AddStudent.aspx.cs

(完整代码) 2KB

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 Admin_AddStudent : System.Web.UI.Page
{

    Alert alert = new Alert();
    data data = new data();
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList2.DataSource = data.GetDataReader("select * from  Xueyuan");
            DropDownList2.DataTextField = "Name";
            DropDownList2.DataValueField = "id";
            DropDownList2.DataBind();
            DropDownList3.DataSource = data.GetDataReader("select * from  zhuanye");
            DropDownList3.DataTextField = "name";
            DropDownList3.DataValueField = "id";
            DropDownList3.DataBind();

      
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        SqlDataReader dr = data.GetDataReader("select * from Student where xuehao='" + txtxuehao.Text + "' ");
        if (dr.Read())
        {
            Label1.Text = "学号重复了请更换";
            return;
        }
        else
        {
            data.RunSql("insert into Student(emal,UserName,Sex,xuehao,chushengriqi,Ds,pwd,xueyuanId,XueyuanName,zhuanyeId,ZhuanyeName)values('" + txtemal.Text + "','" + txtname.Text + "','" + DropDownList1.SelectedItem.Text + "','" + txtxuehao.Text + "','" + txttime1.Value + "','" + txtds.Text + "','" + TextBox1.Text + "','" + DropDownList2.SelectedValue + "','" + DropDownList2.SelectedItem.Text + "','" + DropDownList3.SelectedValue + "','" + DropDownList3.SelectedItem.Text + "')");
            Label1.Text = "";
            Alert.AlertAndRedirect("添加成功!", "Students.aspx");
        }
    }
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList3.DataSource = data.GetDataReader("select * from  zhuanye where xueyuanid='" + DropDownList2.SelectedValue + "'");
        DropDownList3.DataTextField = "name";
        DropDownList3.DataValueField = "id";
        DropDownList3.DataBind();
    }

}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。