Ejemplo n.º 1
0
        void p_OnAssignStudent(object sender, AssignStudentEventArgs e)
        {
            //1. 檢查目地端是否有指定學生,
            ucContentCell targetCell = this.dicLayoutCells[e.Coordinate];
            if (targetCell.Student != null)
            {
                string msg = string.Format("是否將此座位從『{0}』換成『{1}』?", targetCell.Student.Name, e.Student.Name );
                if (MessageBox.Show(msg, "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.No)
                    return;
                else  //清除位置上原本的學生
                {
                    string origStudID = targetCell.Student.ID;
                    targetCell.Student.SeatX = "";
                    targetCell.Student.SeatY = "";
                    targetCell.ClearData();

                    if (!updatedStudentIDs.Contains(origStudID))
                        updatedStudentIDs.Add(origStudID);    //把有修改的學生ID紀錄起來,以備儲存時候用。

                    this.stud_coords.Remove(origStudID);
                }
            }

            //2. 檢查此學生是否有排過座位,如果是,則把原來的座位資訊清除,然後指定到新座位。
            string studID = e.Student.ID;
            if (this.stud_coords.ContainsKey(studID))
            {
                //清除這位學生原來座位的資訊。
                CellCoordinate old_coord = this.stud_coords[studID];
                ucContentCell oldCell = this.dicLayoutCells[old_coord];
                if (oldCell.Student != null)
                {
                    string oldStudID = oldCell.Student.ID;
                    oldCell.Student.SeatX = "";
                    oldCell.Student.SeatY = "";
                    oldCell.ClearData();

                    if (!updatedStudentIDs.Contains(oldStudID))
                        updatedStudentIDs.Add(oldStudID);    //把刪除位置的學生ID紀錄起來,以備儲存時候用。

                    if (this.stud_coords.ContainsKey(oldStudID))
                        this.stud_coords.Remove(oldStudID);
                }
            }

            //3. 指定到新位置
            ucContentCell newCell = this.dicLayoutCells[e.Coordinate];
            newCell.Student = e.Student;
            e.Student.SeatX = e.Coordinate.X.ToString();
            e.Student.SeatY = e.Coordinate.Y.ToString();
            this.stud_coords.Add(studID, e.Coordinate);
            if (!updatedStudentIDs.Contains(e.Student.ID))
                updatedStudentIDs.Add(e.Student.ID);    //把刪除位置的學生ID紀錄起來,以備儲存時候用。

            //4. Refresh Listbox
            this.fillListBox();
        }
Ejemplo n.º 2
0
        private void ucTransparentPanel1_DragDrop(object sender, DragEventArgs e)
        {
            SeatTableStudent student = (SeatTableStudent)e.Data.GetData("EMBACore.Forms.SeatTable.SeatTableStudent");

            if (this.OnAssignStudent != null)
            {
                AssignStudentEventArgs args = new AssignStudentEventArgs();
                args.Student = student;
                args.Coordinate = Coordinate;
                this.OnAssignStudent(this, args);
            }

            //this.Student = student;
            //MessageBox.Show(this.Student.Name);
        }