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

📄 default4.aspx.cs

📁 学生管理系统 功能不是很强大 但是很实用
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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;

public partial class Default4 : System.Web.UI.Page
{
    string student;
    protected void Page_Load(object sender, EventArgs e)
    {
        student = this.Session["name"].ToString();
        if (DropDownList1.Text == "")
        {
            string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
            SqlConnection myConn = new SqlConnection(myConnstr);
            string sql = "select 课程名 from 课程表 ";
            myConn.Open();
            SqlCommand myComm = new SqlCommand(sql, myConn);
            SqlDataReader myDataReader = myComm.ExecuteReader();
            while (myDataReader.Read())
                this.DropDownList1.Items.Add(myDataReader.GetValue(0).ToString());
            myConn.Close();
        }
        if (DropDownList2.Text == "")
        {
            string myConnstr1 = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
            SqlConnection myConn1 = new SqlConnection(myConnstr1);
            string sql1 = "select distinct 成绩表.日期 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号='" + student + "' and 学生表.学号='" + student + "'";
            myConn1.Open();
            SqlCommand myComm1 = new SqlCommand(sql1, myConn1);
            SqlDataReader myDataReader1 = myComm1.ExecuteReader();
            while (myDataReader1.Read())
                    this.DropDownList2.Items.Add(myDataReader1.GetValue(0).ToString());
            myConn1.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int n = 1;
        string stu2;
        float stu1, stu3=0,stu4;
        string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
        SqlConnection myConn = new SqlConnection(myConnstr);
        string sql = "select 成绩表.成绩 from 课程表,成绩表 where 课程表.课程名='" + DropDownList1.Text + "'and 成绩表.学号='" + student + "' and 课程表.课程号 = 成绩表.课程号";
        myConn.Open();
        SqlCommand myComm = new SqlCommand(sql, myConn);
        SqlDataReader myDataReader = myComm.ExecuteReader();
        Label2.Text = DropDownList1.Text;
        while (myDataReader.Read())
        {
            stu3 = float.Parse(myDataReader.GetValue(0).ToString());
        }
        myConn.Close();
        sql = "select 成绩表.成绩,成绩表.学号 from 课程表,成绩表 where 课程表.课程名=" + "'"+DropDownList1.Text+"'"+"and 课程表.课程号 = 成绩表.课程号";
        myConn.Open();
        myComm = new SqlCommand(sql, myConn);
        myDataReader = myComm.ExecuteReader();
        Label2.Text = DropDownList1.Text;
        while (myDataReader.Read())
        {
           stu1 = float.Parse(myDataReader.GetValue(0).ToString());
           stu2 = myDataReader.GetValue(1).ToString();
           stu2=stu2.Trim();
           if (stu1 > stu3 && stu2 != student)
           {
                n++;
           }
           if (stu2 == student)
           {
               stu4 = stu3;
               Label6.Text = Convert.ToString(stu4);
           }
        }
        Label4.Text=Convert.ToString(n);
        myConn.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        int x1 = 0,stux=0,stux1=0;
        int c=0,v=1;
        float[] stu = new float[100];
        DateTime st;
        st = DateTime.Parse(DropDownList2.Text);
        string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
        SqlConnection myConn = new SqlConnection(myConnstr);
        string sql = "select 成绩表.学号,成绩表.成绩,课程表.课程名,成绩表.日期,课程表.学分 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号 = 学生表.学号 and 课程表.课程号=成绩表.课程号 and 成绩表.日期='" +st+ "'";
        myConn.Open();
        SqlCommand myComm = new SqlCommand(sql, myConn);
        SqlDataReader myDataReader = myComm.ExecuteReader();
        while (myDataReader.Read())
        {
            stux = int.Parse(myDataReader.GetValue(0).ToString());
            stu[stux] += float.Parse(myDataReader.GetValue(1).ToString());
            if (int.Parse(myDataReader.GetValue(1).ToString()) >= 60 && myDataReader.GetValue(0).ToString().Trim() == student)
            {
                x1 += int.Parse(myDataReader.GetValue(4).ToString());
            }
        }
        stux1 = int.Parse(student);
        Label13.Text = Convert.ToString(stu[stux1]);
        Label14.Text = Convert.ToString(x1);
        for (c = 0; c < 100; c++)
        {

            if (stu[c] > stu[stux1])
            {
                v++;
            }
        }
        Label15.Text = Convert.ToString(v);
        myConn.Close();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("登陆页面.aspx");
    }
}

⌨️ 快捷键说明

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