📄 grade_query.aspx.cs
字号:
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_query 的摘要说明。
/// </summary>
public class grade_query : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Btn_ok;
protected System.Web.UI.WebControls.DataGrid Dgd_grade;
protected System.Web.UI.WebControls.TextBox Tbx_course;
protected System.Web.UI.WebControls.Button Btn_information;
protected System.Web.UI.WebControls.Label Lbl_note;
protected System.Web.UI.WebControls.Button Btn_exit;
protected System.Web.UI.WebControls.Label Lbl_must;
protected System.Web.UI.WebControls.Label Lbl_sort;
string strsql;
protected System.Web.UI.WebControls.TextBox Tbx_term;
protected System.Web.UI.WebControls.Button Btn_look;
protected System.Web.UI.WebControls.Button Btn_see;
protected System.Web.UI.WebControls.Button Btn_personnel;
protected System.Web.UI.WebControls.Button Btn_course;
protected System.Web.UI.WebControls.Button Btn_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.Btn_information.Click += new System.EventHandler(this.Btn_information_Click);
this.Btn_see.Click += new System.EventHandler(this.Btn_see_Click);
this.Btn_personnel.Click += new System.EventHandler(this.Btn_personnel_Click);
this.Btn_course.Click += new System.EventHandler(this.Btn_course_Click);
this.Btn_grade.Click += new System.EventHandler(this.Btn_grade_Click);
this.Btn_ok.Click += new System.EventHandler(this.Btn_ok_Click);
this.Btn_exit.Click += new System.EventHandler(this.Btn_exit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Btn_information_Click(object sender, System.EventArgs e)
{
Response.Redirect("query.aspx");
}
private void Btn_ok_Click(object sender, System.EventArgs e)
{
if(Tbx_course.Text=="")
{
strsql="select course.Course_name,student_course.Course_id,Course_year,Student_grade,Course_credit,Course_kind from student_course,course where Course_year='"+Tbx_term.Text+"' and student_course.Course_id=course.Course_id and Student_id='"+Session["User_id"].ToString()+"'";
}
else
{
strsql="select course.Course_name,student_course.Course_id,Course_year,Student_grade,Course_credit,Course_kind from student_course,course where Course_year='"+Tbx_term.Text+"'and course.Course_id=student_course.Course_id and course.Course_name='"+Tbx_course.Text+"'and Student_id='"+Session["User_id"].ToString()+"'";
}
cn.Open();
SqlDataAdapter da=new SqlDataAdapter(strsql,cn);
DataSet ds=new DataSet();
da.Fill(ds);
Dgd_grade.DataSource=ds;
Dgd_grade.DataBind();
cn.Close();
Lbl_note.Visible=true;
display();
}
public void display()
{strsql="select SUM(Course_credit) from course,student_course where Course_year='"+Tbx_term.Text+"' and Student_id=@Student_id and student_course.Course_id=course.Course_id and Course_kind=2 and Student_grade>=60";
SqlCommand cm=new SqlCommand(strsql,cn);
cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));
cm.Parameters["@Student_id"].Value=Session["User_id"].ToString();
cn.Open();
SqlDataReader dr=cm.ExecuteReader();
if(dr.Read())
{
Lbl_sort.Text="本学期选修课的总学分为:"+dr[0].ToString();
}
else
{
Lbl_sort.Text="本学期选修课的总学分为:0";
}
cn.Close();
strsql="select SUM(Course_credit) from course,student_course where Course_year='"+Tbx_term.Text+"' and Student_id=@Student_id and student_course.Course_id=course.Course_id and Course_kind<2 and Student_grade>=60";
cm=new SqlCommand(strsql,cn);
cm.Parameters.Add(new SqlParameter("@Student_id",SqlDbType.VarChar,50));
cm.Parameters["@Student_id"].Value=Session["User_id"].ToString();
cn.Open();
dr=cm.ExecuteReader();
if(dr.Read())
{
Lbl_must.Text="本学期必修课的总学分为:"+dr[0].ToString();
}
else
{
Lbl_must.Text="本学期必修课的总学分为:0";
}
cn.Close();
}
private void Btn_exit_Click(object sender, System.EventArgs e)
{
Response.Redirect("query.aspx");
}
private void Btn_see_Click(object sender, System.EventArgs e)
{
Response.Redirect("sortcourse.aspx");
}
private void Btn_personnel_Click(object sender, System.EventArgs e)
{
Response.Redirect("updatepwd.aspx");
}
private void Btn_course_Click(object sender, System.EventArgs e)
{
Response.Redirect("course_student.aspx");
}
private void Btn_grade_Click(object sender, System.EventArgs e)
{
Response.Redirect("grade_query.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -