您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->某大学学生管理系统(毕业设计)源码>>ST_addstudentcourse.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某大学学生管理系统(毕业设计)源码
当前文件:文件类型 StudentsInfo/ST_addstudentcourse.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.ComponentModel; 4using System.Data; 5using System.Data.SqlClient; 6using System.Configuration; 7using System.Drawing; 8using System.Web; 9using System.Web.SessionState; 10using System.Web.UI; 11using System.Web.UI.WebControls; 12using System.Web.UI.HtmlControls; 13 14namespace STGROUP 15{ 16 /// <summary> 17 /// ST_addstudentcourse 的摘要说明。 18 /// </summary> 19 public class ST_addstudentcourse : System.Web.UI.Page 20 { 21 protected System.Web.UI.WebControls.DropDownList st_ddl_course; 22 protected System.Web.UI.WebControls.DropDownList st_ddl_class; 23 protected System.Web.UI.WebControls.TextBox st_tbx_year; 24 protected System.Web.UI.WebControls.Button st_btn_ok; 25 protected System.Web.UI.WebControls.Label st_lbl_note; 26 27 private void Page_Load(object sender, System.EventArgs e) 28 { 29 // 在此处放置用户代码以初始化页面 30 string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 31 //连接本地计算机的sms数据库 32 SqlConnection st_conn0= new SqlConnection (st_connstr); 33 if(!IsPostBack) 34 { 35 //课程名称下拉列表框绑定 36 st_conn0.Open (); 37 string mysql1="select * from ST_course where ST_Course_kind='0'or ST_Course_kind='1'"; 38 SqlCommand st_comm1=new SqlCommand (mysql1,st_conn0); 39 SqlDataReader st_dr1=st_comm1.ExecuteReader (); 40 while(st_dr1.Read ()) 41 { 42 st_ddl_course.Items .Add (new ListItem(st_dr1["ST_Course_name"].ToString() ,st_dr1["ST_Course_id"].ToString()) ); 43 } 44 st_conn0.Close (); 45 //班级名称下拉列表框绑定 46 st_conn0.Open (); 47 string st_sql2="select * from ST_class"; 48 SqlCommand st_comm2=new SqlCommand (st_sql2,st_conn0); 49 SqlDataReader st_dr2=st_comm2.ExecuteReader (); 50 while(st_dr2.Read ()) 51 { 52 st_ddl_class.Items .Add (new ListItem(st_dr2["ST_Class_name"].ToString() ,st_dr2["ST_Class_id"].ToString()) ); 53 } 54 st_conn0.Close (); 55 } 56 } 57 58 Web Form Designer generated code 79 80 private void st_btn_ok_Click(object sender, System.EventArgs e) 81 { 82 string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 83 SqlConnection st_conn= new SqlConnection (st_connstr); 84 st_conn.Open(); 85 string st_sqlstr="insert into ST_student_course(ST_Student_id,ST_Course_id,ST_Course_year) (select ST_Student_id,@Course_id,@Course_year from ST_student where ST_Student_classid=@classid) "; 86 SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn); 87 st_comm.Parameters.Add(new SqlParameter("@classid",SqlDbType.VarChar,50)); 88 st_comm.Parameters["@classid"].Value=st_ddl_class.SelectedItem.Value; 89 st_comm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50)); 90 st_comm.Parameters["@Course_id"].Value=st_ddl_course.SelectedItem.Value; 91 st_comm.Parameters.Add(new SqlParameter("@Class_id",SqlDbType.VarChar,50)); 92 st_comm.Parameters["@Class_id"].Value=st_ddl_class.SelectedItem.Value; 93 st_comm.Parameters.Add(new SqlParameter("@Course_year",SqlDbType.VarChar,50)); 94 st_comm.Parameters["@Course_year"].Value=st_tbx_year.Text; 95 try 96 { 97 st_comm.ExecuteNonQuery(); 98 st_lbl_note.Text="添加成功,请返回"; 99 100 } 101 catch(SqlException) 102 { 103 st_lbl_note.Text="添加失败"; 104 st_lbl_note.Style["color"]="red"; 105 } 106 st_conn.Close(); 107 108 } 109 110 } 111} 112
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:某大学学生管理系统(毕业设计)源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号