public static void LoadData()
 {
     AccessHelper ah = new AccessHelper();
     foreach (UDT_ClassRoomLayout udtLayout in ah.Select<UDT_ClassRoomLayout>())
     {
         ClassRoomLayout layout = new ClassRoomLayout(udtLayout);
         layouts.Add(layout);
         dicLayouts.Add(layout.UID, layout);
     }
 }
        private void frmSeatTable_Load(object sender, EventArgs e)
        {
            this.MaximizeBox = true;

            if (K12.Presentation.NLDPanels.Course.SelectedSource.Count < 1)
            {
                MessageBox.Show("請選擇課程");
                return;
            }

            //1. 取得目前選取的課程
            AccessHelper ah = new AccessHelper();
            this.currentCourseID = K12.Presentation.NLDPanels.Course.SelectedSource[0];
            K12.Data.CourseRecord rec = K12.Data.Course.SelectByID(this.currentCourseID);
            this.expandablePanel1.TitleText = rec.Name;

            List<UDT.CourseExt> course_exts = ah.Select<UDT.CourseExt>("ref_course_id=" + this.currentCourseID);
            if (course_exts.Count == 0)
                this.currentCourseExt = null;
            else
            {
                this.currentCourseExt = course_exts[0];
                this.expandablePanel1.TitleText = rec.Name + " ( " + this.currentCourseExt.SubjectCode + " )";
            }

            //2. 取得所有的座位表樣版
            this.allLayouts = new List<ClassRoomLayout>();
            List<UDT_ClassRoomLayout> udtLayouts =(new AccessHelper()).Select<UDT_ClassRoomLayout>();
            foreach(UDT_ClassRoomLayout udtL in udtLayouts)
            {
                ClassRoomLayout lt = new ClassRoomLayout(udtL);
                this.allLayouts.Add(lt);
                this.cboLayouts.Items.Add(lt);
                //this.cboLayouts.SelectedIndex = 0;
            }

            //3. 取得此課程的座位表樣版
             this.layout = this.allLayouts[0];  //預設 layout
            List<UDT.CourseExt> course_ext = ah.Select<UDT.CourseExt>("ref_course_id=" + this.currentCourseID );
            if ((course_ext.Count ==0) || (course_ext[0].ClassroomLayoutID == null)) {
                //採預設 layout,所以不作任何事。
            }
            else {
                foreach(ClassRoomLayout crl in this.allLayouts) {
                    if (this.currentCourseExt.ClassroomLayoutID.ToString() ==  crl.UID ) {
                        this.layout = crl ;
                        break ;
                    }
                }
            }
            this.currentCourseExt.ClassroomLayoutID = int.Parse(this.layout.UID);

            //4. 取得修課學生
            this.GetSCAttendExt();

            //5. 指定課程的座位樣版
            this.cboLayouts.SelectedItem = this.layout ; //會觸發 selectedindex_change 事件
        }
        private void cboLayouts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboLayouts.SelectedItem == null)
                return ;

            this.layout = (ClassRoomLayout)cboLayouts.SelectedItem;
            this.pnlContainer.Text = this.layout.ClassRoomName;

            //畫出課程教室座位分佈圖
            DrawClassroomLayout();

            //將修課學生的座位資訊填入座位樣版中
            this.fillStudentSeatPosition();

            //填入修課學生
            this.fillListBox();
        }