⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentinf.aspx.cs

📁 本套软件适用于各大高校、中小学、幼儿园、培训机构等单位的教学管理软件。
💻 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;
using jianke;
public partial class studentinf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Dept_Bind();
            Profession_Bind();
        }
    }
    public void Dept_Bind()
    {
        SqlConnection Conn = DB.creatconnection();
        Conn.Open();
        SqlCommand cmd = new SqlCommand("select  dept_name,dept_id from Dept", Conn);

        SqlDataReader sdr = cmd.ExecuteReader();
        this.DropDownList1.DataSource = sdr;
        this.DropDownList1.DataTextField = "dept_name";
        this.DropDownList1.DataValueField = "dept_id";
        this.DropDownList1.DataBind();

        sdr.Close();
        Conn.Close();
    }
    public void Profession_Bind()
    {
        SqlConnection Conn = DB.creatconnection();
        Conn.Open();
        SqlCommand cmd = new SqlCommand("select  profession_name,profession_id from Profession where dept_id='"+this.DropDownList1.SelectedValue+"'", Conn);

        SqlDataReader sdr = cmd.ExecuteReader();
        this.DropDownList2.DataSource = sdr;
        this.DropDownList2.DataTextField = "profession_name";
        this.DropDownList2.DataValueField = "profession_id";
        this.DropDownList2.DataBind();

        sdr.Close();
        Conn.Close();
    }



    protected void Button1_Click(object sender, EventArgs e)
    {
           SqlConnection Conn = DB.creatconnection();
           Conn.Open();

           string str = "insert into Student(student_sno,student_name,student_sex,student_dept,student_profession,student_birth,student_enter_time)values('" + this.TextBox1.Text + "', '" + this.TextBox2.Text + "', '" + this.RadioButtonList1.SelectedValue + "' ,  '" + this.DropDownList1.SelectedItem.Text + "', '" + this.DropDownList2.SelectedItem.Text + "',   '" + this.TextBox4.Text + "','" + this.TextBox5.Text + "')";
           SqlCommand cmd = new SqlCommand(str, Conn);
           cmd.ExecuteNonQuery();

           string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5");
           string str1 = "insert into Users(Users_id,Users_password,Users_class)values('" + this.TextBox1.Text + "','" + password + "'," + 3 + ")";
           SqlCommand cmd1=new SqlCommand(str1,Conn);
           cmd1.ExecuteNonQuery();

           Conn.Close();
           Response.Write("<script>alert('录入成功!');</script>");
         // this.TextBox1.Text = "";
          
          
    }
    protected void dept_profession(object sender, EventArgs e)
    {
        Profession_Bind();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        this.TextBox1.Text = "";
        this.TextBox2.Text = "";
        this.TextBox4.Text = "";
        this.TextBox5.Text = "";
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -