点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 尚未分类>> Asp.net学生信息管理系统源码>> 源文件浏览
[免费版 Free] WebForm,下载次数:28215 次 | 关键字: 学生信息 存储过程 课程设计

源码截图

源码目录树

当前路径:addstu.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 addstu : System.Web.UI.Page
{

    SqlConnection sms_conn;

    // protected System.Web.UI.WebControls.DataGrid sms_teacher;
    //  protected System.Web.UI.WebControls.Label sms_lbl_note;

    string sms_sqlstr, sms_sqlstr2;
    private void Page_Load(object sender, System.EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        string sms_connstr = ConfigurationSettings.AppSettings["SMS_dbconn"];
        sms_conn = new SqlConnection(sms_connstr);
        for (int i = 2000; i <= 2020; i++)
        {
            DropDownList2.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
        //string x = sms_ds.Tables["table1"].Rows[0]["ru_date"].ToString();
        //DropDownList2.Items.FindByValue(x).Selected = true;
        //绑定Dropdownlist2;
        
        sms_sqlstr2 = "select * from [class]";
        SqlDataAdapter sms_da2 = new SqlDataAdapter(sms_sqlstr2, sms_conn);
        DataSet sms_ds2 = new DataSet();
        sms_da2.Fill(sms_ds2, "T");

        for (int i = 0; i < sms_ds2.Tables["T"].Rows.Count; i++)
        {
            DropDownList1.Items.Add(new ListItem(sms_ds2.Tables["T"].Rows[i]["classname"].ToString(), sms_ds2.Tables["T"].Rows[i]["classid"].ToString()));
        }
        //x = sms_ds.Tables["table1"].Rows[0]["classname"].ToString();
        //DropDownList1.Items.FindByText(x).Selected = true;
        //DropDownList1.DataSource = sms_ds2.Tables["T"];DropDownList1.DataTextField = "departmentname";
        //DropDownList1.DataValueField = "departmentname";
        //DropDownList1.DataBind();
        sms_conn.Close();
        sms_ds2.Clear();
        sms_ds2.Dispose();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sms_sqlstr = "insert into student (studentname,sex,classid,telephone,address,pwd,remark,ru_date,studentid,birthday,credithour) values('" + TextBox2.Text + "','" + RadioButtonList1.SelectedItem.Text + "','" + DropDownList1.SelectedValue.ToString() + "','" + TextBox8.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox6.Text + "','" + DropDownList2.SelectedValue.ToString() + "','" + TextBox1.Text + "','"+TextBox5.Text +"','"+TextBox7.Text +"')";
        SqlCommand sms_comm = new SqlCommand(sms_sqlstr, sms_conn);
        sms_comm.Connection.Open();
        try
        {
            sms_comm.ExecuteNonQuery();
            sms_lbl_note.Text = "编辑成功";

        }
        catch (SqlException)
        {
            sms_lbl_note.Text = "编辑失败";
            sms_lbl_note.Style["color"] = "red";
        }
        sms_comm.Connection.Close();
        Response.Redirect("student.aspx");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("student.aspx");
    }

    protected void Button6_Click(object sender, EventArgs e)
    {
        Response.Redirect("addstu.aspx");
    }
}
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:4000410510
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
在线客服
分享该页面
关闭侧边栏