gradeall.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace LoginFrame
{
    public partial class gradeall : Form
    {
        public gradeall()
        {
            InitializeComponent();
            // sql1-7 使用 嵌套查询语句选取该字段最大值的人
            string sql1 = string.Format("select name from stuinfo where 总分 = (select max(总分) from stuinfo);");
            string sql2 = string.Format("select name from stuinfo where 数学 = (select max(数学) from stuinfo);");
            string sql3 = string.Format("select name from stuinfo where 语文 = (select max(语文) from stuinfo);");
            string sql4 = string.Format("select name from stuinfo where 英语 = (select max(英语) from stuinfo);");
            string sql5 = string.Format("select name from stuinfo where 物理 = (select max(物理) from stuinfo);");
            string sql6 = string.Format("select name from stuinfo where 化学 = (select max(化学) from stuinfo);");
            string sql7 = string.Format("select name from stuinfo where 生物 = (select max(生物) from stuinfo);");
            // command对象实例化
            SqlCommand command1 = new SqlCommand(sql1, DbHelper.connection);
            SqlCommand command2 = new SqlCommand(sql2, DbHelper.connection);
            SqlCommand command3 = new SqlCommand(sql3, DbHelper.connection);
            SqlCommand command4 = new SqlCommand(sql4, DbHelper.connection);
            SqlCommand command5 = new SqlCommand(sql5, DbHelper.connection);
            SqlCommand command6 = new SqlCommand(sql6, DbHelper.connection);
            SqlCommand command7 = new SqlCommand(sql7, DbHelper.connection);
            DbHelper.connection.Open();
            // 返回各个查询结果
            string all1 = Convert.ToString(command1.ExecuteScalar());
            string all2 = Convert.ToString(command2.ExecuteScalar());
            string all3 = Convert.ToString(command3.ExecuteScalar());
            string all4 = Convert.ToString(command4.ExecuteScalar());
            string all5 = Convert.ToString(command5.ExecuteScalar());
            string all6 = Convert.ToString(command6.ExecuteScalar());
            string all7 = Convert.ToString(command7.ExecuteScalar());
            // 将查询结果赋值给 label 显示
            label1.Text = all1;
            label2.Text = all2;
            label3.Text = all3;
            label4.Text = all4;
            label5.Text = all5;
            label6.Text = all6;
            label7.Text = all7;
            DbHelper.connection.Close();

        }

        private void gradeall_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“zhanghuDataSet3.stuinfo”中。您可以根据需要移动或删除它。
            this.stuinfoTableAdapter1.Fill(this.zhanghuDataSet3.stuinfo);
            // TODO: 这行代码将数据加载到表“zhanghuDataSet2.stuinfo”中。您可以根据需要移动或删除它。
后面还有 70 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。