Пример #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string sql = "select sno as '学号',sname as '姓名',ssex as '性别',sage as '年龄',sdept as '所属院系' from dbo.student";

            //绑定到datagridview中显示
            this.dataGridView1.DataSource = linkSql.QuerySQL(sql);
        }
Пример #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string sql = "select cno as '课程代号',cname as '课程名',chours as '课时数',ctype as '课程类型',credit as '学分' from dbo.class";

            //绑定到datagridview中显示
            this.dataGridView1.DataSource = linkSql.QuerySQL(sql);
        }
Пример #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string sql = "select dno as '院系编号',dname as '院系名',principal as '负责人' from dbo.depart";

            //绑定到datagridview中显示
            this.dataGridView1.DataSource = linkSql.QuerySQL(sql);
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            string sql = string.Format("select dbo.sc.sno as '学号',sname as '姓名',grade as '成绩' from dbo.student,dbo.sc where dbo.student.sno = dbo.sc.sno and cno = '{0}'", comboBox2.SelectedValue);

            dt1 = linkSQL.QuerySQL(sql);
            this.dataGridView1.DataSource = dt1;
        }
Пример #5
0
        private void GradeStatistics_Load(object sender, EventArgs e)
        {
            string sql = "select cno,cname from class";

            dt = linkSql.QuerySQL(sql);
            comboBox2.DataSource    = dt;      //将表绑定到控件
            comboBox2.DisplayMember = "cname"; //定义要显示的内容为列名为x的内容
            comboBox2.ValueMember   = "cno";   //定义要映射的值为y的值
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Пример #6
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string sql;

            if (Program.isTeacher)
            {
                sql = "select tno as '工号',tname as '姓名',tsex as '性别',tdept as '所属院系',title as '职称',tage as '年龄',wage as '基本工资' from dbo.teacher";
            }
            else
            {
                sql = "select tname as '姓名',tsex as '性别',tdept as '所属院系',title as '职称' from dbo.teacher";
            }
            //绑定到datagridview中显示
            this.dataGridView1.DataSource = linkSql.QuerySQL(sql);
        }
Пример #7
0
        private void WorkloadStatistics_Load(object sender, EventArgs e)
        {
            linkSql = new LinkSQL();
            string sql = "select teacher.tno as '工号',tname as '姓名',t_workload as '工作量(课时)' from t_workload_view, teacher where t_workload_view.tno = teacher.tno";

            this.dataGridView1.DataSource          = linkSql.QuerySQL(sql);
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Пример #8
0
        private void QueryGrade_Load(object sender, EventArgs e)
        {
            linkSql = new LinkSQL();
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            string sql = string.Format("select sno as '学号',cno as '课程',grade as '成绩' from dbo.sc where sno = '{0}'", Program.loginId);

            this.dataGridView1.DataSource = linkSql.QuerySQL(sql);

            //学分统计
            string sql2 = string.Format("select SUM(credit) from class where cno in (select cno from sc where sno = '{0}' and grade >= 60)", Program.loginId);

            dt = linkSql.QuerySQL(sql2);
            int loginCredit = 0;

            try
            {
                loginCredit = Convert.ToInt32(dt.Rows[0][0].ToString());
            }
            catch
            {
            }
            label1.Text = string.Format("您已选修学分为{0}学分,最高可选修120学分", loginCredit);
        }
        private void ElectiveCourse_Load(object sender, EventArgs e)
        {
            //获取全部课程
            string sql1 = "select * from class";

            dt1 = linkSql.QuerySQL(sql1);

            //创建表头
            this.listView1.Columns.Clear(); //先清除再添加保证数据的一致性
            this.listView1.Columns.Add("", 60, HorizontalAlignment.Left);
            this.listView1.Columns.Add("课程号", 60, HorizontalAlignment.Left);
            this.listView1.Columns.Add("课程名称", 150, HorizontalAlignment.Left);
            this.listView1.Columns.Add("学时", 60, HorizontalAlignment.Left);
            this.listView1.Columns.Add("课程类型", 150, HorizontalAlignment.Left);
            this.listView1.Columns.Add("学分", 60, HorizontalAlignment.Left);

            //绑定数据
            foreach (DataRow row in dt1.Rows)
            {
                ListViewItem item = new ListViewItem();
                item.SubItems.Add(row["cno"].ToString());
                item.SubItems.Add(row["cname"].ToString());
                item.SubItems.Add(row["chours"].ToString());
                item.SubItems.Add(row["ctype"].ToString());
                item.SubItems.Add(row["credit"].ToString());
                listView1.Items.Add(item);
            }

            //查询已选课程
            string sql2;

            sql2 = string.Format("select cno from sc where sno = '{0}'", Program.loginId);
            dt2  = linkSql.QuerySQL(sql2);

            //移除已选课程
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                for (int j = 0; j < dt2.Rows.Count; j++)
                {
                    if (listView1.Items[i].SubItems[1].Text == dt2.Rows[j]["cno"].ToString())
                    {
                        listView1.Items.RemoveAt(i);
                    }
                }
            }

            //学分统计
            string sql3 = string.Format("select SUM(credit) from class where cno in (select cno from sc where sno = '{0}' and grade >= 60)", Program.loginId);

            dt3 = linkSql.QuerySQL(sql3);
            int loginCredit = 0;

            try
            {
                loginCredit = Convert.ToInt32(dt3.Rows[0][0].ToString());
            }
            catch
            {
            }
            label1.Text = string.Format("您已选修学分为{0}学分,最高可选修120学分", loginCredit);
            //如果学分大于120,则不能选课
            if (loginCredit > 120)
            {
                //将复选框关闭
                listView1.CheckBoxes = false;
            }

            //选课人数统计
            string sql4 = "select sc.cno,count(distinct sno) as snoCount,count(distinct tno) as tnoCount from sc,tc where sc.cno = tc.cno group by sc.cno";

            dt4 = linkSql.QuerySQL(sql4);
            foreach (DataRow dr in dt4.Rows)
            {
                //选课人数小于教师数*15,不开课
                if (Convert.ToInt32(dr["snoCount"].ToString()) < 15 * Convert.ToInt32(dr["tnoCount"].ToString()))
                {
                    Program.startClass = false;
                }
                //选课人数大于教师数*50,无法选课
                else if (Convert.ToInt32(dr["snoCount"].ToString()) > 50 * Convert.ToInt32(dr["tnoCount"].ToString()))
                {
                    cnoList.Add(dr["cno"].ToString()); //记录下课程号
                }
                //正常选课,开课
                else
                {
                    Program.startClass = true;
                }
            }
            //移除选课人数已满的课程
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                for (int j = 0; j < cnoList.Count; j++)
                {
                    if (listView1.Items[i].SubItems[1].Text == cnoList[j])
                    {
                        listView1.Items.RemoveAt(i);
                    }
                }
            }
        }