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

源码截图

源码目录树

当前路径:addgrade.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 addgrade : System.Web.UI.Page
{
    SqlConnection sms_conn;
    string sms_sqlstr;
    protected void Page_Load(object sender, EventArgs e)
    {
      // 在此处放置用户代码以初始化页面
      string sms_connstr = ConfigurationSettings.AppSettings["SMS_dbconn"];
      sms_conn = new SqlConnection(sms_connstr);
      if (!IsPostBack)
      { SMS_Databind(); }
    }
    public void SMS_Databind()
    {
     
        sms_sqlstr = "select * from [course]";
        SqlDataAdapter sms_da = new SqlDataAdapter(sms_sqlstr, sms_conn);
        DataSet sms_ds = new DataSet();
        sms_da.Fill(sms_ds, "T");

        for (int i = 0; i < sms_ds.Tables["T"].Rows.Count; i++)
        {
           DropDownList2.Items.Add(new ListItem(sms_ds.Tables["T"].Rows[i]["coursename"].ToString(), sms_ds.Tables["T"].Rows[i]["courseid"].ToString()));
        }
        Label4.Text = DropDownList2.SelectedValue.ToString();
     }
    
    protected void Button1_Click(object sender, EventArgs e)
    {
        sms_sqlstr = "insert into grade(courseid,grade.studentid,grade) values('"+ Label4.Text +"','"+ Label5.Text +"','"+TextBox2.Text +"')";
        SqlCommand sms_comm = new SqlCommand(sms_sqlstr, sms_conn);
        sms_comm.Connection.Open();
        try
        {
            sms_comm.ExecuteNonQuery();
            Response.Redirect("grade.aspx");

        }
        catch (SqlException)
        {
            sms_lbl_note.Text = "编辑失败";
            sms_lbl_note.Style["color"] = "red";
        }
        sms_comm.Connection.Close();

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("grade.aspx");
    }
    protected void LBox2_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        Label4.Text = DropDownList2.SelectedValue.ToString();
    }
    protected void validate_Click(object sender, EventArgs e)
    {
        sms_sqlstr = "select * from student where studentname='"+TextBox1.Text+"'";
        SqlCommand sms_comm = new SqlCommand(sms_sqlstr, sms_conn);
        sms_comm.Connection.Open();      
        SqlDataAdapter sms_adp = new SqlDataAdapter(sms_comm);
        DataSet sms_ds = new DataSet();
       
        sms_adp.Fill(sms_ds, "table1");         
        Label5.Text = sms_ds.Tables["table1"].Rows[0]["studentid"].ToString();
        Label6.Text = sms_ds.Tables["table1"].Rows[0]["credithour"].ToString();      
        sms_comm.Connection.Close();

        //SqlDataAdapter sms_adp = new SqlDataAdapter(sms_sqlstr, sms_conn);
        //DataSet sms_ds = new DataSet();
       // sms_adp.Fill(sms_ds,"table1");
        //Label5.Text = sms_ds.Tables["table1"].Rows[0]["studentid"].ToString()
    }
}

关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(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号
在线客服
分享该页面
关闭侧边栏