Пример #1
0
        private void btQuery_Click(object sender, EventArgs e)
        {
            string sql = "SELECT dname 系名称, cspec 专业名称, sname 学生名字" +
                         " FROM students s, classes c, departments d" +
                         " WHERE s.cno = c.cno AND c.dno = d.dno";

            if (checkBox1.Checked)
            {
                string dname = comboBox1.SelectedItem.ToString();
                sql += " AND dname = '" + dname + "'";
            }
            if (checkBox2.Checked)
            {
                string cspec = comboBox2.SelectedItem.ToString();
                sql += " AND cspec = '" + cspec + "'";
                //string.Format("'{0}' ", comboBox2.SelectedItem.ToString());
            }
            if (checkBox3.Checked)
            {
                string sname = textBox1.Text.Trim();
                sql += " AND sname LIKE '%" + sname + "%'";
            }
            sql += " ORDER BY d.dno desc, c.cno, s.sno desc";
            //MessageBox.Show(sql);
            //Console.WriteLine(sql);
            DBUtil.fillListView(lvShow, sql);
        }
Пример #2
0
        private void btQuery_Click(object sender, EventArgs e)
        {
            string sql = "SELECT dname 系名称, COUNT(*) 人数" +
                         " FROM departments d, classes c, students s" +
                         " WHERE d.dno = c.dno AND s.cno = c.cno" +
                         " GROUP BY dname";

            if (radioButton2.Checked)
            {
                sql = "SELECT cyear 入学年份, COUNT(*) 人数" +
                      " FROM classes c, students s" +
                      " WHERE s.cno = c.cno" +
                      " GROUP BY cyear";
            }
            DBUtil.fillListView(lvShow, sql);
        }
Пример #3
0
        void reLoad()
        {
            string sql = "SELECT sno AS 学号, sname AS 姓名, sdate AS 出生日期, cno AS 班号 FROM students";

            DBUtil.fillListView(lvShow, sql);
        }