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

📄 st_addgrade.aspx.cs

📁 学生管理系统。C#开发。偏重与数据库的应用。
💻 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 ST_addgrade : System.Web.UI.Page
{
    SqlConnection st_conn;
    protected void Page_Load(object sender, EventArgs e)
    {
        string st_connstr = ConfigurationManager.AppSettings["st_dbconn"];
        // 在此处放置用户代码以初始化页面
        st_conn = new SqlConnection(st_connstr);
    }
    protected void st_btn_add_Click(object sender, EventArgs e)
    {
        string st_sqlstr = "update ST_student_course set ST_Student_grade=@Student_grade where ST_Student_id=@Student_id and  ST_Course_id=@Course_id and ST_Course_year=@Course_year";
        SqlCommand st_comm = new SqlCommand(st_sqlstr, st_conn);
        st_comm.Parameters.Add(new SqlParameter("@Student_id", SqlDbType.VarChar, 50));
        st_comm.Parameters["@Student_id"].Value = st_tbx_studentid.Text;
        st_comm.Parameters.Add(new SqlParameter("@Course_id", SqlDbType.VarChar, 50));
        st_comm.Parameters["@Course_id"].Value = st_ddl_course.SelectedItem.Value;
        st_comm.Parameters.Add(new SqlParameter("@Course_year", SqlDbType.Char, 10));
        st_comm.Parameters["@Course_year"].Value = st_tbx_term.Text;
        st_comm.Parameters.Add(new SqlParameter("@Student_grade", SqlDbType.Int, 4));
        st_comm.Parameters["@Student_grade"].Value = st_tbx_grade.Text;
        st_comm.Connection.Open();
        try
        {
            st_comm.ExecuteNonQuery();
            Response.Redirect("ST_grade_manage.aspx");

        }
        catch (SqlException)
        {
            st_lbl_note.Text = "添加失败";
            st_lbl_note.Style["color"] = "red";
        }
        st_comm.Connection.Close();	
    }
    private void st_cv_id_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
    {
        string st_connstr = ConfigurationManager.AppSettings["st_dbconn"];
        st_conn = new SqlConnection(st_connstr);
        st_conn.Open();
        string st_sqlstr = "select * from ST_student where ST_Student_id='" + st_tbx_studentid.Text + "'";
        SqlCommand st_comm = new SqlCommand(st_sqlstr, st_conn);
        SqlDataReader st_dr = st_comm.ExecuteReader();
        if (st_dr.Read())
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
        st_conn.Close();

    }
    protected void st_tbx_studentid_TextChanged(object sender, EventArgs e)
    {
        //课程名称下拉列表框绑定
        string st_connstr = ConfigurationManager.AppSettings["st_dbconn"];
        SqlConnection st_conn0 = new SqlConnection(st_connstr);
        st_conn0.Open();
        string st_sql1 = "select ST_course.* from ST_student_course,ST_course where ST_student_course.ST_Student_id='" + st_tbx_studentid.Text + "'and ST_student_course.ST_Course_id=ST_course.ST_Course_id";
        SqlCommand st_comm1 = new SqlCommand(st_sql1, st_conn0);
        SqlDataReader st_dr1 = st_comm1.ExecuteReader();
        while (st_dr1.Read())
        {
            st_ddl_course.Items.Add(new ListItem(st_dr1["ST_Course_name"].ToString(), st_dr1["ST_Course_id"].ToString()));
        }
        st_conn0.Close();
    }
}

⌨️ 快捷键说明

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