using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }
        Mydatabase DB = new Mydatabase();
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form4_Load(object sender, EventArgs e)
        {
            //班级选择
            string sql1 = "select bno,bname from class";
            DataSet ds1 = DB.GetDataSet(sql1);
            comboBox1.DataSource = ds1.Tables[0].DefaultView;
            comboBox1.DisplayMember = "bname";
            comboBox1.ValueMember = "bno";

            string sql2 = "select cno,cname from course";
            DataSet ds2 = DB.GetDataSet(sql2);
            comboBox2.DataSource = ds2.Tables[0].DefaultView;
            comboBox2.DisplayMember = "cname";
            comboBox2.ValueMember = "cno";
        }
        /// <summary>
        /// 准备打开水晶报表文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            object bno = this.comboBox1.SelectedValue;
            object cno = this.comboBox2.SelectedValue;
            string s = "select scno from sc where cno=" + cno.ToString() + " and bno=" + bno.ToString();
            //查询是否选择的课程编号和班级编号有成绩信息
            if (DB.GetdataRow("select scno from sc where cno=" + cno.ToString() + " and bno=" + bno.ToString()) > 0)
            {
                
                Form1 f = new Form1(cno, bno);
                //重载Show方法，打开form1时候，传递cno 课程号和 bno 班级号参数过去
                f.Show();
            }
            else
            {
                MessageBox.Show("该班级该课程无成绩信息！");
            }
            
        }
        
               
    }
}