private void AddTeachSection(String time_slot_id)//把dataGridView本学期可教课程中选中行的课加入已教课程
 //为什么要把这个过程移出来呢?因为解决时间冲突要用到
 //这个过程很难复用,学生选课的话请自行处理DataGridView与DataTable关系,注意表第几列对应section主码
 {
     #region 把可教课程中选中的行复制到已教课程里
     DataRow newRow = dataTable本学期已教课程.NewRow();
     for (int i = 0; i < dataGridView本学期可教课程.CurrentRow.Cells.Count - 1; i++)//考虑到id是数字,不输入id
     {
         newRow[i] = dataGridView本学期可教课程.CurrentRow.Cells[i].Value.ToString();
     }
     newRow[7] = Convert.ToInt32(textBoxLoginName.Text);
     dataTable本学期已教课程.Rows.Add(newRow);
     #endregion 把可教课程中选中的行复制到已教课程里
     #region 把后台表中刚才那行的id改为textBoxLoginName.Text
     DataRow[] TargetBackgroundRow = dataTableBackground.Select(
         String.Format("course_id = '{0}' AND sec_id = '{1}' AND semester = '{2}' AND year = {3}",
                       dataGridView本学期可教课程.CurrentRow.Cells[0].Value.ToString(),
                       dataGridView本学期可教课程.CurrentRow.Cells[1].Value.ToString(),
                       dataGridView本学期可教课程.CurrentRow.Cells[2].Value.ToString(),
                       dataGridView本学期可教课程.CurrentRow.Cells[3].Value.ToString()));
     if (TargetBackgroundRow.Length == 1 && TargetBackgroundRow[0].IsNull(7))
     {
         TargetBackgroundRow[0][7] = this.textBoxLoginName.Text;
     }
     #endregion 把后台表中刚才那行的id改为textBoxLoginName.Text
     #region 填充课程表为有课
     TimeTableCell tableCell = new TimeTableCell();
     tableCell.SetCourseOccupied();
     tableCell.course_id = dataGridView本学期可教课程.CurrentRow.Cells[0].Value.ToString();
     tableCell.sec_id    = dataGridView本学期可教课程.CurrentRow.Cells[1].Value.ToString();
     tableCell.semester  = dataGridView本学期可教课程.CurrentRow.Cells[2].Value.ToString();
     tableCell.year      = dataGridView本学期可教课程.CurrentRow.Cells[3].Value.ToString();
     tableCell.id        = dataGridView本学期可教课程.CurrentRow.Cells[7].Value.ToString();
     SetTimeTableOccupied(time_slot_id, tableCell);
     #endregion 填充课程表为有课
     #region 把可教课程中选中的行删除掉
     dataTable本学期可教课程.Rows[dataGridView本学期可教课程.CurrentRow.Index].Delete();//可教课程选中那一行标为删除
     dataTable本学期可教课程.AcceptChanges();
     #endregion 把可教课程中选中的行删除掉
 }
        //如果在数据库中选择出了time_slot,使用以下方法可以将数据库中的文字转化为下标:
        //ItemArray[0]为id列,可用ToString()方法得到值
        //int day = (int)Enum.Parse(typeof(星期枚举), (string)TimeSlotRow.ItemArray[1]);//得到课程表第二维坐标
        //int start_wk = Convert.ToInt32(TimeSlotRow.ItemArray[2]) - 1;//得到课程表第一维循环开始值
        //int end_wk = Convert.ToInt32(TimeSlotRow.ItemArray[3]) - 1;//得到课程表第一维循环结束值
        //int start_tm = Convert.ToInt32(TimeSlotRow.ItemArray[4]) - 1;//得到课程表第三维循环开始值
        //int end_tm = Convert.ToInt32(TimeSlotRow.ItemArray[5]) - 1;//得到课程表第三维循环结束值
        #endregion 枚举说明

        private void SetTimeTableOccupied(String time_slot_id, TimeTableCell result)
        //给定一个time_slot_id,把课程表上所有这个时间段填充上result课程
        {
            DataRow[] rows = dataTableTimeSlot.Select(
                String.Format("time_slot_id = '{0}'", time_slot_id));
            foreach (DataRow TimeSlotRow in rows)
            {
                int day      = (int)Enum.Parse(typeof(星期枚举), (string)TimeSlotRow.ItemArray[1]); //得到课程表第二维坐标
                int start_wk = Convert.ToInt32(TimeSlotRow.ItemArray[2]) - 1;                   //得到课程表第一维循环开始值
                int end_wk   = Convert.ToInt32(TimeSlotRow.ItemArray[3]) - 1;                   //得到课程表第一维循环结束值
                int start_tm = Convert.ToInt32(TimeSlotRow.ItemArray[4]) - 1;                   //得到课程表第三维循环开始值
                int end_tm   = Convert.ToInt32(TimeSlotRow.ItemArray[5]) - 1;                   //得到课程表第三维循环结束值
                for (int i = start_wk; i <= end_wk; i++)
                {
                    for (int j = start_tm; j <= end_tm; j++)
                    {
                        TimeTable[i, day, j] = result;
                        TimeTable[i, day, j].SetCourseOccupied(result);
                    }
                }
            }
        }
 //true代表有课,false代表无课
 //课程信息啥的也往这塞
 public void SetCourseOccupied(TimeTableCell cell)
 {
     this = cell;
     this.IsCourseOccupied = true;
 }