ASP.NET学生信息管理系统

news2024/11/17 0:27:40

摘 要

    本文介绍了在ASP.net环境下采用“自上而下地总体规划,自下而上地应用开发”的策略开发一个管理信息系统的过程。通过分析某一学校学生管理的不足,创建了一套行之有效的计算机管理学生的方案。文章介绍了学生管理信息系统的系统分析部分,包括可行性分析、业务流程分析等;系统设计部分主要介绍了系统功能设计和数据库设计及代码设计;系统实现部分说明了几个主要模块的算法,   本系统界面友好,操作简单,比较实用。

【关键字】:管理信息系统、学生管理、ASP.net应用

3.3系统功能模块分析

SMS主要的功能包括以下几个方面:用户管理(管理员,老师管理和学生管理),课程管理,班级管理,成绩管理选课管理。设计图如5--3所示,除此之外,系统还包含了教师管理,班级管理等辅助功能模块,用于协调4个主模块。

用户管理模块:该模块由两个子模块构成,分别示管理员与教师管理模块和学生管理模块。主要负责管理员与教师以及学生信息的管理功能,具体参看管理员与教师管理子模块和学生管理子模块的模块功能描述。

管理员与教师管理子模块:该模块主要负责管理系统管理员的信息。它为用户管理模块的一个子模块。主要功能是将本校的教师权限设为管理员。管理员课添加新教师信息,每个教师有唯一的编号,之后通过把教师加为管理员,而令此教师具有管理员的权限,从而教师可以登陆系统进行管理员的相关操作。

学生管理子模块:该模块主要负责管理所有在校注册学生的个人信息。它为用户管理模块的一个子模块。主要功能包括添加,删除,修改,查找学生信息。每个学生有唯一的学号,管理员添加新生后,新生即可登陆此系统浏览个人信息,登陆此系统的用户名和密码默认都是此学生的学号。

课程管理模块:该模块负责管理本校所有的课程信息。主要功能包括添加,删除,修改,查找课程信息。只有管理员才具有对课程信息进行维护的权限,课程的类型分三种:公共课,专业课和选修课。课程管理模块是选课管理模块的基础,只有在课程管理中添有选修课的信息,学生才能进行选课。

选课管理模块:该模块负责选课的管理。主要功能包括删除,统计学生选课信息。它以在课程管理系统中维护号的信息作为基础,既可以对选修课程进行管理,也可以对统计选课人数,并根据学生选课时间先后决定最终选修此课的同学。

成绩管理模块:学生学的每一门课显然最后要有成绩,查询的内肉包括课程名称,学分,成绩等。只有管理员可以录入学生每一门课的成绩,并能进行修改,学生只能查询自己所学课程的成绩,并且可以查询每一学期学生所学课程所获总学分,前提是成绩必须及格,否则将没有此课的成绩。

班级管理模块:该模块负责班级的管理。主要功能包括添加,删除和修改班级信息,以及对班级信息的查询。只有管理员才具有对班级管理信息进行维护的权限。学生信息的添加是建立在班级信息维护的基础上,每个学生必然属于特定的班级。并且在管理员对学生成绩查询统计时,可以统计各个班级的平均分,最高分。

8.1学生管理系统首页

学生管理系统首页具有自动导航功能,不同用户登陆时将根据不同的身份进入不同的系统功能页。

代码入下

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    public class _default : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.TextBox Tbx_userid;

         protected System.Web.UI.WebControls.TextBox Tbx_userpwd;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_enter;

         private void Page_Load(object sender, System.EventArgs e)

         {

             // 在此处放置用户代码以初始化页面

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

         private void InitializeComponent()

         {   

             this.Btn_enter.Click += new System.EventHandler(this.Btn_enter_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_enter_Click(object sender, System.EventArgs e)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             SqlConnection cn=new SqlConnection(strconn); 

             cn.Open();

             string strsql="select * from users where User_id='"+Tbx_userid.Text+"'and User_password='"+Tbx_userpwd.Text+"'";

             SqlCommand cm=new SqlCommand(strsql,cn);

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {   Session["User_id"]=dr["User_id"];

                  Session["user_power"]=dr["User_power"];          

                  if((int)Session["User_power"]==0)

                  {

                      Response.Redirect("query.aspx");

                  }

                  else

                  {

                      Response.Redirect("student.aspx");

                  }

             }

             else

             {

                      Lbl_note.Text="对不起,登陆失败!";

               }

             cn.Close();

         }

        

    }

}

8.2学生信息维护页面

  学生信息维护模块时SMS重管理学生学籍的部分。页面采用DataGrid控件的Dgd_student与DataSet数据集的绑定返回所有学生信息,可以对学生信息进行修改和删除。

代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// student 的摘要说明。

    /// </summary>

    public class student : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.LinkButton Lbtn_course;

         protected System.Web.UI.WebControls.LinkButton Lbtn_sortcourse;

         protected System.Web.UI.WebControls.DataGrid Dgd_student;

         protected System.Web.UI.WebControls.Button Btn_all;

         protected System.Web.UI.WebControls.Panel Pnl_sort;

         protected System.Web.UI.WebControls.TextBox Tbx_sortid;

         protected System.Web.UI.WebControls.Button Btn_ok;

         SqlConnection cn;

         protected System.Web.UI.WebControls.Button Btn_search;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.LinkButton Lbtn_add;

         protected System.Web.UI.WebControls.TextBox Tbx_name;

         protected System.Web.UI.WebControls.Button Btn_exit;

         protected System.Web.UI.WebControls.LinkButton Lbtn_grade;

         protected System.Web.UI.WebControls.LinkButton Lbtn_addclass;

         protected System.Web.UI.WebControls.LinkButton Lbtn_addteacher;

         protected System.Web.UI.WebControls.LinkButton Lbtn_student;

         string strsql;

         private void Page_Load(object sender, System.EventArgs e)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn); 

             if(!IsPostBack)

             Bindgrid();

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             InitializeComponent();

             base.OnInit(e);

         }

        

         private void InitializeComponent()

         {   

             this.Lbtn_addclass.Click += new System.EventHandler(this.Lbtn_addclass_Click);

             this.Lbtn_addteacher.Click += new System.EventHandler(this.Lbtn_addteacher_Click);

             this.Lbtn_course.Click += new System.EventHandler(this.Lbtn_course_Click);

             this.Lbtn_sortcourse.Click += new System.EventHandler(this.Lbtn_sortcourse_Click);

             this.Lbtn_grade.Click += new System.EventHandler(this.Lbtn_grade_Click);

             this.Btn_search.Click += new System.EventHandler(this.Btn_search_Click);

             this.Btn_ok.Click += new System.EventHandler(this.Btn_ok_Click);

             this.Lbtn_add.Click += new System.EventHandler(this.Lbtn_add_Click);

             this.Btn_all.Click += new System.EventHandler(this.Btn_all_Click);

             this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_search_Click(object sender, System.EventArgs e)

         { 

             Pnl_sort.Visible=true;

         }

         private void Btn_all_Click(object sender, System.EventArgs e)

         { 

            

             Pnl_sort.Visible=false;

             Bindgrid();

            

    }

         public void DataGrid_Page(object sender,DataGridPageChangedEventArgs e)

         {

             Dgd_student.CurrentPageIndex=e.NewPageIndex;

             Bindgrid();

         }

         public void DataGrid_cancel(object sender,DataGridCommandEventArgs e)

         {

            

             Dgd_student.EditItemIndex=-1;

             Bindgrid();

            

         }

         public void DataGrid_edit(object sender,DataGridCommandEventArgs e)

         {

            

                  Dgd_student.EditItemIndex=(int)e.Item.ItemIndex;

        

                  Bindgrid();

            

         }

         public void DataGrid_update(object sender,DataGridCommandEventArgs e)

         {

             string strsql="update student set Student_name=@Student_name,Student_sex=@Student_sex,Student_nation=@Student_nation,Student_birthday=@Student_birthday,Student_time=@Student_time,Student_classid=@Student_classid,Student_home=@Student_home,Student_else=@Student_else where Student_id=@Student_id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             try

             {

             cm.Parameters.Add(new SqlParameter("@Student_name",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Student_sex",SqlDbType.Char,10));

             cm.Parameters.Add(new SqlParameter("@Student_nation",SqlDbType.Char,10));

             cm.Parameters.Add(new SqlParameter("@Student_birthday",SqlDbType.DateTime,8));

             cm.Parameters.Add(new SqlParameter("@Student_time",SqlDbType.DateTime,8));

             cm.Parameters.Add(new SqlParameter("@Student_classid",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Student_home",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Student_else",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));

             string colvalue=((TextBox)e.Item.Cells[1].Controls[0]).Text;

             cm.Parameters["@Student_name"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[2].Controls[0]).Text;

             cm.Parameters["@Student_sex"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[3].Controls[0]).Text;

             cm.Parameters["@Student_nation"].Value=colvalue;

         colvalue=((TextBox)e.Item.Cells[4].Controls[0]).Text;

             cm.Parameters["@Student_birthday"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[5].Controls[0]).Text;

             cm.Parameters["@Student_time"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[6].Controls[0]).Text;

             cm.Parameters["@Student_classid"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[7].Controls[0]).Text;

             cm.Parameters["@Student_home"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[8].Controls[0]).Text;

             cm.Parameters["@Student_else"].Value=colvalue;        

             cm.Parameters["@Student_id"].Value=Dgd_student.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();          

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="编辑成功";

                  Dgd_student.EditItemIndex=-1;

             }

             catch

             {

                  Lbl_note.Text="编辑失败,请检查输入!";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();    

             Bindgrid();

            

         }

                  public void DataGrid_delete(object sender,DataGridCommandEventArgs e)

         {

            

             string strsql="delete from student where Student_id=@userid";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@userid",SqlDbType.VarChar,50));

             cm.Parameters["@userid"].Value=Dgd_student.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="删除成功";

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="删除失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();         

             Bindgrid();

         }

         public void Bindgrid()

         {    strsql="select * from student";

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_student.DataSource=ds;

             Dgd_student.DataBind();

         }                

         private void Btn_ok_Click(object sender, System.EventArgs e)

         { 

            

             strsql="select * from student  where Student_id='"+Tbx_sortid.Text+"'or Student_name='"+Tbx_name.Text+"'";

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_student.DataSource=ds;

             Dgd_student.DataBind();

         }

         private void Lbtn_course_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("course.aspx");

         }

         private void Lbtn_sortcourse_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("student_course.aspx");

         }

         private void Lbtn_add_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("addstudent.aspx");

         }

         private void Btn_exit_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("default.aspx");

         }

         private void Lbtn_grade_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("grade_manage.aspx");

         }

         private void Lbtn_addclass_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("classes.aspx");

         }

         private void Lbtn_addteacher_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("teacher.aspx");

         }

         private void Lbtn_student_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("student.aspx");

         }

    }

}

8.3学生信息添加页面

学生信息添加页面主要负责往数据库里添加数据。后台支持事件主要为Btn_ok_Click()事件负责当用户单击“确定”按钮后的数据库添加操作。利用RequiredFieldValidator控件可以用来验证用户输入信息是否为空。若输入学号存在,利用CustomValidator验证控件,触发ServerValidator事件,判断是否存在此学号的学生。“重置”按钮的click事件将完成刷新此页面的功能。

代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// addstudent 的摘要说明。

    /// </summary>

    public class addstudent : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.TextBox Tbx_id;

         protected System.Web.UI.WebControls.TextBox Tbx_name;

         protected System.Web.UI.WebControls.TextBox Tbx_nation;

         protected System.Web.UI.WebControls.TextBox Tbx_birthday;

         protected System.Web.UI.WebControls.TextBox Tbx_time;

         protected System.Web.UI.WebControls.TextBox Tbx_home;

         protected System.Web.UI.WebControls.TextBox Tbx_else;

         protected System.Web.UI.WebControls.DropDownList Ddl_sex;

         protected System.Web.UI.WebControls.Button Btn_ok;

         protected System.Web.UI.WebControls.CustomValidator Cv_id;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_reset;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_name;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_id;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_nation;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_birthday;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_time;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_class;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_home;

         protected System.Web.UI.WebControls.DropDownList Ddl_class;

        SqlConnection cn;

         private void Page_Load(object sender, System.EventArgs e)

         {//班级名称下拉列表框绑定

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             SqlConnection cn0=new SqlConnection(strconn);

             if(!IsPostBack)

             {

                  cn0.Open ();

                  string mysql="select * from class";

                  SqlCommand cm1=new SqlCommand  (mysql,cn0);

                  SqlDataReader dr1=cm1.ExecuteReader ();

                  while(dr1.Read ())

                  {

                      Ddl_class.Items .Add (new ListItem(dr1["Class_name"].ToString() ,dr1["Class_id"].ToString()) );

                  }

                  cn0.Close ();

             }

             // 在此处放置用户代码以初始化页面

             cn=new SqlConnection(strconn); 

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

        private void InitializeComponent()

         {   

             this.Cv_id.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.Cv_id_ServerValidate);

             this.Btn_ok.Click += new System.EventHandler(this.Btn_ok_Click);

             this.Btn_reset.Click += new System.EventHandler(this.Btn_reset_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_ok_Click(object sender, System.EventArgs e)

         {

            

             SqlCommand cm=new SqlCommand("insert_student_1",cn);

             cm.CommandType=CommandType.StoredProcedure;

             try

             {

             cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));

             cm.Parameters["@Student_id"].Value=Tbx_id.Text;

             cm.Parameters.Add(new SqlParameter("@Student_name",SqlDbType.VarChar,50));

             cm.Parameters["@Student_name"].Value=Tbx_name.Text;

             cm.Parameters.Add(new SqlParameter("@Student_sex",SqlDbType.Char,10));

             cm.Parameters["@Student_sex"].Value=Ddl_sex.SelectedItem.Value;

             cm.Parameters.Add(new SqlParameter("@Student_nation",SqlDbType.Char,10));

             cm.Parameters["@Student_nation"].Value=Tbx_nation.Text;

             cm.Parameters.Add(new SqlParameter("@Student_birthday",SqlDbType.DateTime,8));

             cm.Parameters["@Student_birthday"].Value=Tbx_birthday.Text;

             cm.Parameters.Add(new SqlParameter("@Student_time",SqlDbType.DateTime,8));

             cm.Parameters["@Student_time"].Value=Tbx_time.Text;

             cm.Parameters.Add(new SqlParameter("@Student_classid",SqlDbType.VarChar,50));

             cm.Parameters["@Student_classid"].Value=Ddl_class.SelectedItem.Value;

             cm.Parameters.Add(new SqlParameter("@Student_home",SqlDbType.VarChar,50));

             cm.Parameters["@Student_home"].Value=Tbx_home.Text;

             cm.Parameters.Add(new SqlParameter("@Student_else",SqlDbType.VarChar,50));

             cm.Parameters["@Student_else"].Value=Tbx_else.Text;

             cm.Connection.Open();

             cm.ExecuteNonQuery();

             cm.Connection.Close();

             insert();

             }

             catch

             {

                  Lbl_note.Text="添加失败,请检查输入!";

                  Lbl_note.Style["color"]="red";

             }

         }

             public void insert()

             {

             string strsl="insert into users(User_id,User_password,User_power) values(@User_id,@User_pwd,0)";

             SqlCommand cm=new SqlCommand(strsl,cn);

             cm.Parameters.Add(new SqlParameter("@User_id",SqlDbType.VarChar,50));

             cm.Parameters["@User_id"].Value=Tbx_id.Text;

             cm.Parameters.Add(new SqlParameter("@User_pwd",SqlDbType.VarChar,50));

             cm.Parameters["@User_pwd"].Value=Tbx_id.Text;

             cm.Connection.Open();

                  try

                  {

                      cm.ExecuteNonQuery();

                      Response.Redirect("student.aspx");

                  }

                  catch(SqlException)

                  {

                      Lbl_note.Text="添加失败";

                      Lbl_note.Style["color"]="red";

                  }

             cm.Connection.Close();

         }

         private void Btn_reset_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("addstudent.aspx");

         }

         private void Cv_id_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn);

             cn.Open();

             SqlCommand cm=new SqlCommand("select_student_1",cn);

             cm.CommandType=CommandType.StoredProcedure;

             cm.Parameters.Add("@Student_id",SqlDbType.VarChar,50);

             cm.Parameters["@Student_id"].Value=Tbx_id.Text;

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {

                  args.IsValid=false;

             }

             else

             {

                  args.IsValid=true;

             }

             cn.Close();

         }

    }

}

8.4课程信息管理页面

课程信息管理页面与学生信息维护页面非常相似,进行DataGrid控件Dgd-course的绑定操作,管理员可以在此页面进行课程信息的编辑和删除。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// course 的摘要说明。

    /// </summary>

    public class course : System.Web.UI.Page

    {

        SqlConnection cn;

         protected System.Web.UI.WebControls.TextBox Tbx_name;

         protected System.Web.UI.WebControls.TextBox Tbx_id;

         protected System.Web.UI.WebControls.Button Btn_search;

         protected System.Web.UI.WebControls.DataGrid Dgd_course;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_exit;

         string strsql;

         private void Page_Load(object sender, System.EventArgs e)

         {

             // 在此处放置用户代码以初始化页面

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn); 

             if(!IsPostBack)

                  Bindgrid();

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Btn_search.Click += new System.EventHandler(this.Btn_search_Click);

             this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         public void DataGrid_Page(object sender,DataGridPageChangedEventArgs e)

         {

             Dgd_course.CurrentPageIndex=e.NewPageIndex;

             Bindgrid();

         }

         public void DataGrid_edit(object sender,DataGridCommandEventArgs e)

         {

            

             Dgd_course.EditItemIndex=(int)e.Item.ItemIndex;

             Bindgrid();

            

         }

         public void DataGrid_cancel(object sender,DataGridCommandEventArgs e)

         {

            

             Dgd_course.EditItemIndex=-1;

             Bindgrid();

            

         }

         public void DataGrid_delete(object sender,DataGridCommandEventArgs e)

         {

            

             string strsql="delete from course where Course_id=@course_id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@course_id",SqlDbType.VarChar,50));

             cm.Parameters["@course_id"].Value=Dgd_course.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="删除成功";

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="删除失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();         

             Bindgrid();

         }

         public void DataGrid_update(object sender,DataGridCommandEventArgs e)

         {

             string strsql="update course set Course_name=@Course_name,Course_period=@Course_period,Course_credit=@Course_credit,Course_kind=@Course_kind where Course_id=@Course_id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@Course_name",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Course_period",SqlDbType.Int,4));

             cm.Parameters.Add(new SqlParameter("@Course_credit",SqlDbType.Int,4));

             cm.Parameters.Add(new SqlParameter("@Course_kind",SqlDbType.Int,4));

             cm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50));

             string colvalue=((TextBox)e.Item.Cells[1].Controls[0]).Text;

             cm.Parameters["@Course_name"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[2].Controls[0]).Text;

             cm.Parameters["@Course_period"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[3].Controls[0]).Text;

             cm.Parameters["@Course_credit"].Value=colvalue;

             colvalue=((TextBox)e.Item.Cells[4].Controls[0]).Text;

             cm.Parameters["@Course_kind"].Value=colvalue;

             cm.Parameters["@Course_id"].Value=Dgd_course.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="编辑成功";

                  Dgd_course.EditItemIndex=-1;

             }

             catch(SqlException)

             {

                  Lbl_note.Text="编辑失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();    

             Bindgrid();

            

         }

         public void Bindgrid()

         {

             strsql="select * from course";

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_course.DataSource=ds;

             Dgd_course.DataBind();

         }

         private void Lbtn_addcourse_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("addcourse.aspx");

         }

         private void Btn_exit_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("default.aspx");

         }

        

         private void Btn_search_Click(object sender, System.EventArgs e)

         {

             strsql="select * from course  where Course_id='"+Tbx_id.Text+"'or Course_name='"+Tbx_name.Text+"'";

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_course.DataSource=ds;

             Dgd_course.DataBind();

         }

         private void Lbtn_assign_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("assigncourse.aspx");

         }

    }

}

8.5录入成绩页面

  在录入成绩页面的初始化事件Page_Load()事件对“课程”下拉列表框控件Ddl_course进行初始绑定,使其显示该学生已选的所有课程信息。“录入”按钮的Click事件调用数据库操作语句,对数据库中相应学生,成绩关系表中的成绩信息进行更新。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// addgrade 的摘要说明。

    /// </summary>

    public class addgrade : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.TextBox Tbx_studentid;

         protected System.Web.UI.WebControls.Button Btn_add;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_exit;

         protected System.Web.UI.WebControls.TextBox Tbx_term;

         protected System.Web.UI.WebControls.CustomValidator Cv_id;

         protected System.Web.UI.WebControls.DropDownList Ddl_course;

         protected System.Web.UI.WebControls.TextBox Tbx_grade;

        SqlConnection cn;

         private void Page_Load(object sender, System.EventArgs e)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             // 在此处放置用户代码以初始化页面

             cn=new SqlConnection(strconn); 

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Tbx_studentid.TextChanged += new System.EventHandler(this.Tbx_studentid_TextChanged);

             this.Cv_id.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.Cv_id_ServerValidate);

             this.Btn_add.Click += new System.EventHandler(this.Btn_add_Click);

             this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_add_Click(object sender, System.EventArgs e)

         {

             string strsql="update student_course set Student_grade=@Student_grade where Student_id=@Student_id and  Course_id=@Course_id and Course_year=@Course_year";

              SqlCommand cm=new SqlCommand(strsql,cn);

              cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));

              cm.Parameters["@Student_id"].Value=Tbx_studentid.Text;

              cm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50));

              cm.Parameters["@Course_id"].Value=Ddl_course.SelectedItem.Value;

              cm.Parameters.Add(new SqlParameter("@Course_year",SqlDbType.Char,10));

              cm.Parameters["@Course_year"].Value=Tbx_term.Text;

             cm.Parameters.Add(new SqlParameter("@Student_grade",SqlDbType.Int,4));

             cm.Parameters["@Student_grade"].Value=Tbx_grade.Text;

              cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                 Response.Redirect("grade_manage.aspx");

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="添加失败";

                  Lbl_note.Style["color"]="red";

             }

              cm.Connection.Close();        

            

         }

        

         private void Btn_exit_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("grade_manage.aspx");

         }

         private void Cv_id_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn);

             cn.Open();

             string strsql="select * from student where Student_id='"+Tbx_studentid.Text+"'";

             SqlCommand cm=new SqlCommand(strsql,cn);

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {

                  args.IsValid=true;

             }

             else

             {

                  args.IsValid=false;

             }

             cn.Close();

        

         }

         private void Tbx_studentid_TextChanged(object sender, System.EventArgs e)

         {        //课程名称下拉列表框绑定

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             SqlConnection cn0=new SqlConnection(strconn);

                  cn0.Open ();

                  string mysql1="select course.* from student_course,course where student_course.Student_id='"+Tbx_studentid.Text+"'and student_course.Course_id=course.Course_id";

                  SqlCommand cm1=new SqlCommand  (mysql1,cn0);

                  SqlDataReader dr1=cm1.ExecuteReader ();

                  while(dr1.Read ())

                  {

                      Ddl_course.Items .Add (new ListItem(dr1["Course_name"].ToString() ,dr1["Course_id"].ToString()) );

                  }

                  cn0.Close ();

            

         }

        

    }

}

8.6添加学生必修课页面

     在添加学生必修课页面初始化事件Page_Load事件中将数据库中的所有课程及班级信息分别绑定到DropDownList控件的Ddl_course和Ddl_class控件中,“确定”按钮Btn_ok控件的Click()事件完成往数据库学生-课程信息表中添加所选班级范围下所有学生的相应课程选课记录的任务。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace sms

{

    /// <summary>

    /// addstudentcourse 的摘要说明。

    /// </summary>

    public class addstudentcourse : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.DropDownList Ddl_course;

         protected System.Web.UI.WebControls.DropDownList Ddl_class;

         protected System.Web.UI.WebControls.TextBox Tbx_year;

         protected System.Web.UI.WebControls.Button Btn_ok;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_back;

       

         private void Page_Load(object sender, System.EventArgs e)

         {

             // 在此处放置用户代码以初始化页面

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             //连接本地计算机的sms数据库

             SqlConnection cn0= new SqlConnection (strconn);

             if(!IsPostBack)

             {

                  //课程名称下拉列表框绑定

                  cn0.Open ();

                  string mysql1="select * from course where Course_kind='0'or Course_kind='1'";

                  SqlCommand cm1=new SqlCommand  (mysql1,cn0);

                  SqlDataReader dr1=cm1.ExecuteReader ();

                  while(dr1.Read ())

                  {

                      Ddl_course.Items .Add (new ListItem(dr1["Course_name"].ToString() ,dr1["Course_id"].ToString()) );

                  }

                  cn0.Close ();

                  //班级名称下拉列表框绑定

                  cn0.Open ();

                  string mysql2="select * from class";

                  SqlCommand cm2=new SqlCommand  (mysql2,cn0);

                  SqlDataReader dr2=cm2.ExecuteReader ();               

                  while(dr2.Read ())

                  {

                      Ddl_class.Items .Add (new ListItem(dr2["Class_name"].ToString() ,dr2["Class_id"].ToString()) );

                  }

                  cn0.Close ();

             }

         }

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Btn_ok.Click += new System.EventHandler(this.Btn_ok_Click);

             this.Btn_back.Click += new System.EventHandler(this.Btn_back_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_ok_Click(object sender, System.EventArgs e)

         {

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             SqlConnection cn= new SqlConnection (strconn);

             cn.Open();

             string strsql="insert into student_course(Student_id,Course_id,Course_year) (select Student_id,@Course_id,@Course_year from student where Student_classid=@classid) ";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@classid",SqlDbType.VarChar,50));

             cm.Parameters["@classid"].Value=Ddl_class.SelectedItem.Value;

             cm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50));

             cm.Parameters["@Course_id"].Value=Ddl_course.SelectedItem.Value;

             cm.Parameters.Add(new SqlParameter("@Class_id",SqlDbType.VarChar,50));

             cm.Parameters["@Class_id"].Value=Ddl_class.SelectedItem.Value;

             cm.Parameters.Add(new SqlParameter("@Course_year",SqlDbType.VarChar,50));

             cm.Parameters["@Course_year"].Value=Tbx_year.Text;         

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="添加成功,请返回";

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="添加失败";

                  Lbl_note.Style["color"]="red";

             }  

             cn.Close();

         }

         private void Btn_back_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("course.aspx");

         }

    }

}

8.7成绩管理页面

成绩管理页面完成的功能比较多,包括按选定的条件进行限定条件的成绩查询。同时,也可以根据成绩范围对包含在该范围中的学生成绩作一统计,具体统计这门课的平均分,最高分,参加考试总人数以及优秀人数和不及格人数。此页面的关键就在于根据条件生成SQL语句。当“查询”“统计”操作被触发,系统将完成对数据库中多个表 的操作。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// grade_manage 的摘要说明。

    /// </summary>

    public class grade_manage : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.DropDownList Ddl_way;

         protected System.Web.UI.WebControls.TextBox Tbx_name;

         protected System.Web.UI.WebControls.Button Btn_search;

         protected System.Web.UI.WebControls.DataGrid Dgd_grade;

         protected System.Web.UI.WebControls.LinkButton Link_addgrade;

        SqlConnection cn;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.DropDownList Ddl_stat;

         protected System.Web.UI.WebControls.TextBox Tbx_area;

         protected System.Web.UI.WebControls.TextBox Tbx_classid;

         protected System.Web.UI.WebControls.DropDownList Ddl_content;

         protected System.Web.UI.WebControls.Button Btn_count;

         protected System.Web.UI.WebControls.TextBox Tbx_year;

         protected System.Web.UI.WebControls.Label Lbl_average;

         protected System.Web.UI.WebControls.Label Lbl_high;

         protected System.Web.UI.WebControls.Label Lbl_a;

         protected System.Web.UI.WebControls.Label Lbl_unpass;

         protected System.Web.UI.WebControls.Label Lbl_all;

         protected System.Web.UI.WebControls.TextBox Tbx_term;

         string strsql;

         private void Page_Load(object sender, System.EventArgs e)

         {

             // 在此处放置用户代码以初始化页面

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn); 

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Btn_count.Click += new System.EventHandler(this.Btn_count_Click);

             this.Btn_search.Click += new System.EventHandler(this.Btn_search_Click);

             this.Link_addgrade.Click += new System.EventHandler(this.Link_addgrade_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

        

         private void Link_addgrade_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("addgrade.aspx");

         }

         private void Btn_search_Click(object sender, System.EventArgs e)

         {

             Bindgrid();

         }

         public void DataGrid_Page(object sender,DataGridPageChangedEventArgs e)

         {

             Dgd_grade.CurrentPageIndex=e.NewPageIndex;

             Bindgrid();

         }

         public void Bindgrid()

         {

             if(Ddl_way.SelectedItem.Text=="按学号")

             {

                  if(Tbx_term.Text=="所有")

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student_course.Student_id='"+Tbx_name.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

                  else

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student_course.Student_id='"+Tbx_name.Text+"' and Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

             }

             else if(Ddl_way.SelectedItem.Text=="按课号")

             {

                  if(Tbx_term.Text=="所有")

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student_course.Course_id='"+Tbx_name.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

                  else

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student_course.Course_id='"+Tbx_name.Text+"' and student_course.Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

             }

             else if(Ddl_way.SelectedItem.Text=="按课程名")

             {

                  if(Tbx_term.Text=="所有")

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where course.Course_name='"+Tbx_name.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

            

                  }

                  else

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where course.Course_name='"+Tbx_name.Text+"' and student_course.Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

             }

             else if(Ddl_way.SelectedItem.Text=="按班级")

             {

                  if(Tbx_term.Text=="所有")

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student.Student_classid='"+Tbx_name.Text+"'and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

            

                  }

                  else

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where student.Student_classid='"+Tbx_name.Text+"' and student_course.Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

             }

             else if(Ddl_way.SelectedItem.Text=="按教师号")

             {

                  if(Tbx_term.Text=="所有")

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where teacher.Teacher_id='"+Tbx_name.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

            

                  }

                  else

                  {

                      strsql="select student_course.ID,student_course.Student_id,student.Student_name,student.Student_classid,student_course.Course_id,course.Course_name,teacher.Teacher_name,student_course.Student_grade from course,student,teacher,student_course,teacher_course where teacher.Teacher_id='"+Tbx_name.Text+"' and student_course.Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and student_course.Student_id=student.Student_id and student_course.Course_id=teacher_course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher_course.Class_id=student.Student_classid";

                  }

             }

            

             SqlCommand cm=new SqlCommand(strsql,cn);

             cn.Open();

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {

                  Dgd_grade.Visible=true;

                  cn.Close();

                  cn.Open();

                  SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

                  DataSet ds=new DataSet();

                  da.Fill(ds);

                  Dgd_grade.DataSource=ds;

                  Dgd_grade.DataBind();

             }

             else

             {

                  Dgd_grade.Visible=false;

                  Lbl_note.Text="无纪录!";

             }

             cn.Close();

         }

         public void DataGrid_cancel(object sender,DataGridCommandEventArgs e)

         {

            

             Dgd_grade.EditItemIndex=-1;

             Bindgrid();

            

         }

         public void DataGrid_edit(object sender,DataGridCommandEventArgs e)

         {

            

             Dgd_grade.EditItemIndex=(int)e.Item.ItemIndex;

             Bindgrid();

            

         }

         public void DataGrid_update(object sender,DataGridCommandEventArgs e)

         {

             string strsql="update student_course set Student_grade=@Student_grade where Student_id=@Student_id and Course_id=@Course_id and ID=@id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@Student_grade",SqlDbType.Int,4));

             cm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@id",SqlDbType.Char,10));

             string colvalue=((TextBox)e.Item.Cells[7].Controls[0]).Text;

             cm.Parameters["@Student_grade"].Value=colvalue;

             cm.Parameters["@Student_id"].Value=e.Item.Cells[1].Text;

             cm.Parameters["@Course_id"].Value=e.Item.Cells[4].Text;

             cm.Parameters["@Student_grade"].Value=colvalue;

             cm.Parameters["@id"].Value=Dgd_grade.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="编辑成功";

                  Dgd_grade.EditItemIndex=-1;

             }

             catch(SqlException)

             {

                  Lbl_note.Text="编辑失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();    

             Bindgrid();

            

         }

        

         public void DataGrid_delete(object sender,DataGridCommandEventArgs e)

         {

            

             string strsql="delete from student_course where ID=@id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@id",SqlDbType.Char,10));           

            cm.Parameters["@id"].Value=Dgd_grade.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="删除成功";

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="删除失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();         

             Bindgrid();

         }

         private void Btn_count_Click(object sender, System.EventArgs e)

         {

             if(Ddl_stat.SelectedItem.Value=="系别")

             {

                     

                if(Ddl_content.SelectedItem.Text=="总人数")

                {

                     strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_department='"+Tbx_area.Text+"' ";

                }

                else if(Ddl_content.SelectedItem.Text=="优秀人数")

                {

                     strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_department='"+Tbx_area.Text+"'and Student_grade>=85 ";

                }

                else if(Ddl_content.SelectedItem.Text=="不及格人数")

                {

                     strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_department='"+Tbx_area.Text+"'and Student_grade<60 ";

                }

                  else

                {

                   strsql="select AVG(Student_grade),MAX(Student_grade) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_department='"+Tbx_area.Text+"' ";

                }

             }

             else if(Ddl_stat.SelectedItem.Value=="学院")

             {

                  if(Ddl_content.SelectedItem.Text=="总人数")

                  {

                      strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_college='"+Tbx_area.Text+"' ";

                  }

                  else if(Ddl_content.SelectedItem.Text=="优秀人数")

                  {

                      strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_college='"+Tbx_area.Text+"'and Student_grade>=85 ";

                  }

                  else if(Ddl_content.SelectedItem.Text=="不及格人数")

                  {

                      strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_college='"+Tbx_area.Text+"'and Student_grade<60 ";

                  }

                  else

                  {

                          strsql="select AVG(Student_grade),MAX(Student_grade) from student_course,student,class where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"'and student_course.Student_id=student.Student_id and student.Student_classid=class.Class_id and class.Class_college='"+Tbx_area.Text+"' ";

                  }

                 

                 

             }

             else if(Ddl_stat.SelectedItem.Value=="班级")

             {

                  if(Ddl_content.SelectedItem.Text=="总人数")

                  {

                      strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"' and student_course.Student_id=student.Student_id and student.Student_classid='"+Tbx_area.Text+"'";

                  }

                  else if(Ddl_content.SelectedItem.Text=="优秀人数")

                  {

                  strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"' and student_course.Student_id=student.Student_id and student.Student_classid='"+Tbx_area.Text+"'and Student_grade>=85";

                  }

                  else if(Ddl_content.SelectedItem.Text=="不及格人数")

                   {strsql="select AVG(Student_grade),MAX(Student_grade),COUNT(*) from student_course,student where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"' and student_course.Student_id=student.Student_id and student.Student_classid='"+Tbx_area.Text+"'and Student_grade<60";

                  }

                  else

                  {

                    strsql="select AVG(Student_grade),MAX(Student_grade) from student_course,student where Course_id='"+Tbx_classid.Text+"' and student_course.Course_year='"+Tbx_year.Text+"' and student_course.Student_id=student.Student_id and student.Student_classid='"+Tbx_area.Text+"'";

                  }

                     

                 

             }

             SqlCommand cm=new SqlCommand(strsql,cn);

             cn.Open();

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {

                  if(Ddl_content.SelectedItem.Text=="均分")

                  {

                      Lbl_average.Visible=true;

                      Lbl_average.Text="平均分为:"+dr[0].ToString();

                  }

                  else if(Ddl_content.SelectedItem.Text=="最高分")

                  {

                      Lbl_high.Visible=true;

                      Lbl_high.Text="最高分为:"+dr[1].ToString();

                  }

                  else if(Ddl_content.SelectedItem.Text=="总人数")

                  {

                      Lbl_all.Visible=true;

                      Lbl_all.Text="总人数为:"+dr[2].ToString();

                  }

                  else if(Ddl_content.SelectedItem.Text=="优秀人数")

                  {

                      Lbl_a.Visible=true;

                      Lbl_a.Text="优秀人数为:"+dr[2].ToString();

                  }

                  else if(Ddl_content.SelectedItem.Text=="不及格人数")

                  {

                          Lbl_unpass.Visible=true;

                      Lbl_unpass.Text="不及格人数为:"+dr[2].ToString();

                  }

                  else

                  {Lbl_note.Text="无此信息";

                  }

                  cn.Close();

             }

              

         }

        

    }

}

8.8学生选课管理页面

学生选课管理页面窗体所示,学生选课后需要管理员进一步确认管理,来确定最终选课信息。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// student_course 的摘要说明。

    /// </summary>

    public class student_course : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.Button Btn_student;

         protected System.Web.UI.WebControls.DataGrid Dgd_sort;

         protected System.Web.UI.WebControls.Label Lbl_all;

         protected System.Web.UI.WebControls.TextBox Tbx_year;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_exit;

         protected System.Web.UI.WebControls.DropDownList Ddl_course;

         protected System.Web.UI.WebControls.DropDownList Ddl_teacher;

        SqlConnection cn;

         private void Page_Load(object sender, System.EventArgs e)

         {   //教师名称下拉列表框绑定

             string strconn= ConfigurationSettings.AppSettings["dsn"];

             //连接本地计算机的sms数据库

             SqlConnection cn0= new SqlConnection (strconn);

             if(!IsPostBack)

             {

                  cn0.Open ();

                  string mysql="select * from teacher";

                  SqlCommand cm0=new SqlCommand  (mysql,cn0);

                  SqlDataReader dr0=cm0.ExecuteReader ();

                  while(dr0.Read ())

                  {

                      Ddl_teacher.Items .Add (new ListItem(dr0["Teacher_name"].ToString(),dr0["Teacher_id"].ToString()) );

                  }

                  cn0.Close ();

                  //课程名称下拉列表框绑定

                  cn0.Open ();

                  string mysql1="select * from course";

                  SqlCommand cm1=new SqlCommand  (mysql1,cn0);

                  SqlDataReader dr1=cm1.ExecuteReader ();

                  while(dr1.Read ())

                  {

                      Ddl_course.Items .Add (new ListItem(dr1["Course_name"].ToString() ,dr1["Course_id"].ToString()) );

                  }

                  cn0.Close ();

             }

             // 在此处放置用户代码以初始化页面

             cn=new SqlConnection(strconn);

            

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Btn_student.Click += new System.EventHandler(this.Btn_student_Click);

             this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_student_Click(object sender, System.EventArgs e)

         { Bindgrid();      

         }

         public void DataGrid_delete(object sender,DataGridCommandEventArgs e)

         {

            

             string strsql="delete from student_course where ID=@id";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@ID",SqlDbType.BigInt,8));

             cm.Parameters["@id"].Value=Dgd_sort.DataKeys[(int)e.Item.ItemIndex];

             cm.Connection.Open();

             try

             {

                  cm.ExecuteNonQuery();

                  Lbl_note.Text="删除成功";

                 

             }

             catch(SqlException)

             {

                  Lbl_note.Text="删除失败";

                  Lbl_note.Style["color"]="red";

             }

             cm.Connection.Close();         

             Bindgrid();

         }

        

         public void Bindgrid()

         {

            string strsql="select student_course.ID,student.Student_id,student.Student_classid from student_course,student,teacher_course where student_course.Course_id='"+Ddl_course.SelectedItem.Value+"' and student_course.Course_year=teacher_course.Course_year and student_course.Course_year='"+Tbx_year.Text+"'and teacher_course.Teacher_id='"+Ddl_teacher.SelectedItem.Value+"'and student_course.Course_id=teacher_course.Course_id and student.Student_id=student_course.Student_id";

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_sort.DataSource=ds;

             Dgd_sort.DataBind();

             string strsq="select COUNT(*) from student_course,student,teacher_course where student_course.Course_id='"+Ddl_course.SelectedItem.Value+"' and  student_course.Course_year=teacher_course.Course_year and student_course.Course_year='"+Tbx_year.Text+"'and teacher_course.Teacher_id='"+Ddl_teacher.SelectedItem.Value+"'and student_course.Course_id=teacher_course.Course_id and student.Student_id=student_course.Student_id";

             SqlCommand cm1=new SqlCommand(strsq,cn);     

             cn.Open();

             SqlDataReader dr=cm1.ExecuteReader();

             if(dr.Read())

             {

                      Lbl_all.Text="选课总人数为:"+dr[0].ToString();

             }

             else

             {

                  Lbl_all.Text="无人选此课";

             }

             cn.Close();

         }

         private void Btn_exit_Click(object sender, System.EventArgs e)

         {

             Response.Redirect("default.aspx");

         }

        

    }

}

8.9学生选课页面

学生可进入学生选课页面浏览本学期待选课程的信息,可以设定查询条件,可以根据选此课的人数,教师等情况来确定是否选择此课。

主要相关代码如下:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

namespace sms

{

    /// <summary>

    /// sortcourse 的摘要说明。

    /// </summary>

    public class sortcourse : System.Web.UI.Page

    {

         protected System.Web.UI.WebControls.DataGrid Dgd_sort;

         protected System.Web.UI.WebControls.TextBox Tbx_courseid;

         protected System.Web.UI.WebControls.TextBox Tbx_year;

         protected System.Web.UI.WebControls.Button Btn_look;

         protected System.Web.UI.WebControls.TextBox Tbx_teacher;

         protected System.Web.UI.WebControls.TextBox Tbx_term;

         protected System.Web.UI.WebControls.Button Btn_sort;

         protected System.Web.UI.WebControls.Label Lbl_all;

         protected System.Web.UI.WebControls.Label Lbl_note;

         protected System.Web.UI.WebControls.Button Btn_yes;

         protected System.Web.UI.WebControls.Button Btn_no;

         protected System.Web.UI.WebControls.Panel Pn_yes;

         protected System.Web.UI.WebControls.CustomValidator Cv_course;

         protected System.Web.UI.WebControls.RequiredFieldValidator Rfv_year;

         SqlConnection cn;

         protected System.Web.UI.WebControls.DropDownList Ddl_course;string strsql;

         private void Page_Load(object sender, System.EventArgs e)

         {   string strconn= ConfigurationSettings.AppSettings["dsn"];

             cn=new SqlConnection(strconn); 

             if(!IsPostBack)

             {

                  //课程名称下拉列表框绑定

                 

                  SqlConnection cn0=new SqlConnection(strconn);

                  cn0.Open ();

                  string mysql1="select * from course where Course_kind='2'";

                  SqlCommand cm1=new SqlCommand (mysql1,cn0);

                  SqlDataReader dr1=cm1.ExecuteReader ();

                  Ddl_course.Items .Add (new ListItem("","") );

                  while(dr1.Read ())

                  {

                      Ddl_course.Items .Add (new ListItem(dr1["Course_name"].ToString() ,dr1["Course_id"].ToString()) );

                  }

                  cn0.Close ();

                 

             }

         }

         #region Web Form Designer generated code

         override protected void OnInit(EventArgs e)

         {

             //

             // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

             //

             InitializeComponent();

             base.OnInit(e);

         }        /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

             this.Btn_sort.Click += new System.EventHandler(this.Btn_sort_Click);

             this.Cv_course.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.Cv_course_ServerValidate);

             this.Btn_yes.Click += new System.EventHandler(this.Btn_yes_Click);

             this.Btn_no.Click += new System.EventHandler(this.Btn_no_Click);

             this.Btn_look.Click += new System.EventHandler(this.Btn_look_Click);

             this.Load += new System.EventHandler(this.Page_Load);

         }

         #endregion

         private void Btn_sort_Click(object sender, System.EventArgs e)

         {

            

             string strsq="select COUNT(Student_id) from student_course where Course_id='"+Tbx_courseid.Text+"' and Course_year='"+Tbx_year.Text+"'";

             SqlCommand cm1=new SqlCommand(strsq,cn);     

             cn.Open();

             SqlDataReader dr=cm1.ExecuteReader();

             if(dr.Read())

             {

                  Lbl_all.Text="选此课总人数为:"+dr[0].ToString();

            }

             else

             {

                  Lbl_all.Text="无人选此课";

             }

             Pn_yes.Visible=true;

             cn.Close();

        

         }

     

         private void Btn_yes_Click(object sender, System.EventArgs e)

         {

             strsql="insert into student_course(Student_id,Course_id,Course_year) values(@Student_id,@Course_id,@Course_year)";

             SqlCommand cm=new SqlCommand(strsql,cn);

             cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Course_id",SqlDbType.VarChar,50));

             cm.Parameters.Add(new SqlParameter("@Course_year",SqlDbType.VarChar,50));

             cm.Parameters["@Student_id"].Value=Session["User_id"].ToString();

             cm.Parameters["@Course_id"].Value=Tbx_courseid.Text;

             cm.Parameters["@Course_year"].Value=Tbx_year.Text;

             cn.Open();

             try

             {

                  cm.ExecuteNonQuery();

             }

             catch(SqlException)

             {

                  Lbl_note.Text="添加失败!";

             }

           

             cn.Close();

        

         }

         private void Btn_no_Click(object sender, System.EventArgs e)

         {

          Lbl_all.Text="请重新选择";

         }

         private void Cv_course_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)

         {           

             cn.Open();

             strsql="select * from course where Course_id='"+Tbx_courseid.Text+"'";

             SqlCommand cm=new SqlCommand(strsql,cn);

             SqlDataReader dr=cm.ExecuteReader();

             if(dr.Read())

             {

                  args.IsValid=true;

             }

             else

             {

                  args.IsValid=false;

             }

             cn.Close();

         }

         private void Btn_look_Click(object sender, System.EventArgs e)

         {

             if(Ddl_course.SelectedItem.Text=="")

             {

                  if(Tbx_teacher.Text=="")

                  {strsql="select course.Course_name,course.Course_id,teacher.Teacher_name,course.Course_credit,course.Course_period from course,teacher,teacher_course where teacher_course.Course_year='"+Tbx_term.Text+"' and teacher_course.Course_id=course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id";

                  }

                  else

                  {

                  strsql="select course.Course_name,course.Course_id,teacher.Teacher_name,course.Course_credit,course.Course_period from course,teacher,teacher_course where teacher_course.Course_year='"+Tbx_term.Text+"' and teacher_course.Course_id=course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and teacher.Teacher_name='"+Tbx_teacher.Text+"'";

            

                  }

             }

             else

             {

                  if(Tbx_teacher.Text=="")

                  {

                  strsql="select course.Course_name,course.Course_id,teacher.Teacher_name,course.Course_credit,course.Course_period from course,teacher,teacher_course where teacher_course.Course_year='"+Tbx_term.Text+"' and teacher_course.Course_id=course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and course.Course_name='"+Ddl_course.SelectedItem.Text+"'";

            

                  }

                  else

                  {

                      strsql="select course.Course_name,course.Course_id,teacher.Teacher_name,course.Course_credit,course.Course_period from course,teacher,teacher_course where teacher_course.Course_year='"+Tbx_term.Text+"' and teacher_course.Course_id=course.Course_id and teacher_course.Teacher_id=teacher.Teacher_id and course.Course_name='"+Ddl_course.SelectedItem.Text+"' and teacher.Teacher_name='"+Tbx_teacher.Text+"'";

            

                  }

             }

             SqlDataAdapter da=new SqlDataAdapter(strsql,cn);

             DataSet ds=new DataSet();

             da.Fill(ds);

             Dgd_sort.DataSource=ds;

             Dgd_sort.DataBind();

         }

        

    }

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1664783.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【C++ | 函数】默认参数、哑元参数、函数重载、内联函数

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; ⏰发布时间⏰&#xff1a;2024-05-04 1…

Linux —— 信号(4)

Linux —— 信号&#xff08;4&#xff09; 信号的处理用户态和内核态 信号的捕捉sigaction sa_mask字段volatileSIGCHLD信号 我们今天接着来看信号&#xff1a; 信号的处理 信号的处理简单一句话就是在内核态处理的。 用户态和内核态 用户态和内核态是操作系统和计组中的概…

MySQL系列之索引

&#x1f339;作者主页&#xff1a;青花锁 &#x1f339;简介&#xff1a;Java领域优质创作者&#x1f3c6;、Java微服务架构公号作者&#x1f604; &#x1f339;简历模板、学习资料、面试题库、技术互助 &#x1f339;文末获取联系方式 &#x1f4dd; 往期热门专栏回顾 专栏…

【声呐仿真】学习记录2-运行ROV(带camera、sonar、dvl等传感器)例程

【声呐仿真】学习记录2-运行ROV&#xff08;带camera、sonar、dvl等传感器&#xff09;例程 前言第一阶段-学习Gazebo第二阶段-学习URDF、xacro第三阶段-寻找例程跑一个rexrov示例程序1.uuvsimulator quick_start2.能键盘控制的示例程序&#xff08;失败&#xff09;3.能键盘控…

[初阶数据结构】单链表

前言 &#x1f4da;作者简介&#xff1a;爱编程的小马&#xff0c;正在学习C/C&#xff0c;Linux及MySQL。 &#x1f4da;本文收录于初阶数据结构系列&#xff0c;本专栏主要是针对时间、空间复杂度&#xff0c;顺序表和链表、栈和队列、二叉树以及各类排序算法&#xff0c;持…

【Python系列】字节串与字典字节串

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

【高校科研前沿】北师大陈晋教授团队在遥感顶刊发表最新成果:ClearSCD模型:在高空间分辨率遥感影像中综合利用语义和变化关系进行语义变化检测

01文章简介 论文名称&#xff1a;The ClearSCD model: Comprehensively leveraging semantics and change relationships for semantic change detection in high spatial resolution remote sensing imagery&#xff08;ClearSCD模型&#xff1a;在高空间分辨率遥感影像中综合…

Nextcloud私有云盘-重新定义云存储体验

Nextcloud私有云盘-重新定义云存储体验 1. 什么是Nextcloud ​ Nextcloud是一个开源的云存储和协作平台&#xff0c;旨在为个人用户、企业和团队提供安全、隐私保护的数据存储和共享解决方案。它允许您在不同设备之间同步、共享文件&#xff0c;提供了强大的协作工具和应用生…

VSCode:设置顶部文件标签页滚动条的宽度

使用VSCode打开多个文件后&#xff0c;顶部的文件标签可以通过滚动条进行滚动&#xff0c;但是缺点是该滚动条太窄了&#xff0c;不好选择。 可以通过如下方法修改改滚动条的宽度&#xff1a; 1.点击设置 2.选择工作台->编辑管理->Title Scrollbar Sizing->Large 3.可…

MSP430环境搭建

1.下载ccs编译器 注意&#xff1a;安装路径和工作路径不能出现中文&#xff01; 没有说明的步骤就点next即可&#xff01; 1.1下载适合自己电脑的压缩包。 下载好压缩包后解压&#xff0c;点击有图标进行安装。 1.2创建一个文件夹用于安装编译器位置 选择安装地址&#xff0…

FFmpeg常用API与示例(四)——过滤器实战

1.filter 在多媒体处理中&#xff0c;filter 的意思是被编码到输出文件之前用来修改输入文件内容的一个软件工具。如&#xff1a;视频翻转&#xff0c;旋转&#xff0c;缩放等。 语法&#xff1a;[input_link_label1]… filter_nameparameters [output_link_label1]… 1、视…

Mybatis操作数据库的两种方式:原生API

mybatis操作数据的两种方式&#xff1a;原生api和mapper代理对象 1.mybatis的api提供的方法 insert() 增加 delete() 删除 update() 更新 selectOne() 返回一个数据 selectList() 返回多个数据&#xff0c;结果类型为List selectMap() 返回多个数据&…

YOLOv5-7.0改进(四)添加EMA注意力机制

前言 关于网络中注意力机制的改进有很多种&#xff0c;本篇内容从EMA注意力机制开始&#xff01; 往期回顾 YOLOv5-7.0改进&#xff08;一&#xff09;MobileNetv3替换主干网络 YOLOv5-7.0改进&#xff08;二&#xff09;BiFPN替换Neck网络 YOLOv5-7.0改进&#xff08;三&…

net 7部署到Linux并开启https

1.修改代码设置后台服务运行 安装nuget包 Install-Package Microsoft.Extensions.Hosting.WindowsServices Install-Package Microsoft.Extensions.Hosting.Systemd在Program代码中设置服务后台运行 var builder WebApplication.CreateBuilder(args);if (System.OperatingS…

x6.js bug记录-流程图json数据导入进来之后拖拽节点,节点直接飞走了

添加josn数据进来之后虽然能正常渲染&#xff0c;但是只要一拖拽&#xff0c;则节点就直接飞走了&#xff0c;看不到了。 找了一下午的问题&#xff0c;最后发现。保存的json坐标位置是字符串类型&#xff0c;而这边的位置必须是数字类型。如下&#xff1a; {position: { x: &…

词令蚂蚁新村今日答案:微信小程序怎么查看蚂蚁新村今天问题的正确答案?

微信小程序怎么查看蚂蚁新村今天问题的正确答案&#xff1f; 1、打开微信&#xff0c;点击搜索框&#xff1b; 2、打开搜索页面&#xff0c;选择小程序搜索&#xff1b; 3、在搜索框&#xff0c;输入词令搜索点击进入词令微信小程序&#xff1b; 4、打开词令微信小程序关键词口…

基于Matplotlib的模型性能可视化工作

一、项目简介 本项目是科技考古墓葬识别工作的中间过程&#xff0c;因为需要大量复用所以另起一章好了。 主要涉及到数据读取、数据可视化和少量的数据处理过程。 二、相关知识 PandasMatplotlib 三、实验过程 1. 数据探索性分析 1.1 准备工作–导入模块 import pandas…

考研入门55问---基础知识篇

考研入门55问---基础知识篇 01 &#xff1e;什么是研究生入学考试&#xff1f; 研究生是指大专和本科之后的深造课程。以研究生为最高学历, 研究生毕业后&#xff0c;也可称研究生&#xff0c;含义为研究生学历的人。在中国大陆地区&#xff0c;普通民众一般也将硕士毕业生称…

JavaSE基础小知识Ⅱ(很容易错!!!)

1. 变量被final修饰后不能再指向其他对象&#xff0c;但可以重写 如果是引用变量被final修饰&#xff0c;那么的确如此&#xff1b; 基本变量不能重写 2. 下列代码的输出结果是&#xff1f; public class Test {static {int x 5; }static int x,y; public static void ma…

conan2 基础入门(01)-介绍

conan2 基础入门(01)-介绍 文章目录 conan2 基础入门(01)-介绍⭐什么是conan官网Why use Conan? ⭐使用现状版本情况个人知名开源企业 ⭐ConanCenter包中心github ⭐说明文档END ⭐什么是conan 官网 官网&#xff1a;Conan 2.0: C and C Open Source Package Manager 一句话来…