您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->某大学学生管理系统(毕业设计)源码>>ST_addgrade.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某大学学生管理系统(毕业设计)源码
当前文件:文件类型 StudentsInfo/ST_addgrade.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.ComponentModel; 4using System.Data; 5using System.Data.SqlClient; 6using System.Drawing; 7using System.Web; 8using System.Web.SessionState; 9using System.Web.UI; 10using System.Web.UI.WebControls; 11using System.Web.UI.HtmlControls; 12using System.Configuration; 13 14namespace STGROUP 15{ 16 /// <summary> 17 /// ST_addgrade 的摘要说明。 18 /// </summary> 19 public class ST_addgrade : System.Web.UI.Page 20 { 21 protected System.Web.UI.WebControls.TextBox st_tbx_studentid; 22 protected System.Web.UI.WebControls.Button st_btn_add; 23 protected System.Web.UI.WebControls.Label st_lbl_note; 24 protected System.Web.UI.WebControls.TextBox st_tbx_term; 25 protected System.Web.UI.WebControls.CustomValidator st_cv_id; 26 protected System.Web.UI.WebControls.DropDownList st_ddl_course; 27 protected System.Web.UI.WebControls.TextBox st_tbx_grade; 28 SqlConnection st_conn; 29 private void Page_Load(object sender, System.EventArgs e) 30 { 31 string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 32 // 在此处放置用户代码以初始化页面 33 st_conn=new SqlConnection(st_connstr); 34 } 35 36 Web Form Designer generated code 59 60 private void st_btn_add_Click(object sender, System.EventArgs e) 61 { 62 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"; 63 SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn); 64 st_comm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50)); 65 st_comm.Parameters["@Student_id"].Value=st_tbx_studentid.Text; 66 st_comm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50)); 67 st_comm.Parameters["@Course_id"].Value=st_ddl_course.SelectedItem.Value; 68 st_comm.Parameters.Add(new SqlParameter("@Course_year",SqlDbType.Char,10)); 69 st_comm.Parameters["@Course_year"].Value=st_tbx_term.Text; 70 st_comm.Parameters.Add(new SqlParameter("@Student_grade",SqlDbType.Int,4)); 71 st_comm.Parameters["@Student_grade"].Value=st_tbx_grade.Text; 72 st_comm.Connection.Open(); 73 try 74 { 75 st_comm.ExecuteNonQuery(); 76 Response.Redirect("ST_grade_manage.aspx"); 77 78 } 79 catch(SqlException) 80 { 81 st_lbl_note.Text="添加失败"; 82 st_lbl_note.Style["color"]="red"; 83 } 84 st_comm.Connection.Close(); 85 86 } 87 88 89 private void st_cv_id_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) 90 { 91 string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 92 st_conn=new SqlConnection(st_connstr); 93 st_conn.Open(); 94 string st_sqlstr="select * from ST_student where ST_Student_id='"+st_tbx_studentid.Text+"'"; 95 SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn); 96 SqlDataReader st_dr=st_comm.ExecuteReader(); 97 if(st_dr.Read()) 98 { 99 args.IsValid=true; 100 } 101 else 102 { 103 args.IsValid=false; 104 } 105 st_conn.Close(); 106 107 } 108 109 110 111 private void st_tbx_studentid_TextChanged(object sender, System.EventArgs e) 112 { 113 //课程名称下拉列表框绑定 114 string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 115 SqlConnection st_conn0=new SqlConnection(st_connstr); 116 st_conn0.Open (); 117 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"; 118 SqlCommand st_comm1=new SqlCommand (st_sql1,st_conn0); 119 SqlDataReader st_dr1=st_comm1.ExecuteReader (); 120 while(st_dr1.Read ()) 121 { 122 st_ddl_course.Items .Add (new ListItem(st_dr1["ST_Course_name"].ToString() ,st_dr1["ST_Course_id"].ToString()) ); 123 } 124 st_conn0.Close (); 125 126 } 127 128 129 } 130} 131
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:某大学学生管理系统(毕业设计)源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号