예제 #1
0
        // 座號排序
        private static int SortStudSeatNo(StudentSCAtendScore x, StudentSCAtendScore y)
        {
            /* 小郭, 2013/12/27, 排序方法改成跟"成績輸入"的一樣
             * int intX, intY;
             * if (x.SeatNo == null)
             *  intX = 999;
             * else
             *  intX = x.SeatNo;
             * if (y.SeatNo == null)
             *  intY = 999;
             * else
             *  intY = y.SeatNo;
             *
             * return intX.CompareTo(intY);
             */

            if (x.ClassId != null && y.ClassId != null)
            {
                if (x.ClassId == y.ClassId)
                {
                    if (x.SeatNo != null && y.SeatNo != null)
                    {
                        if (x.SeatNo == y.SeatNo)
                        {
                            return(x.StudentNumber.CompareTo(y.StudentNumber));
                        }
                        return(x.SeatNo.CompareTo(y.SeatNo));
                    }
                    else if (x.SeatNo != null)
                    {
                        return(-1);
                    }
                    else if (y.SeatNo != null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(x.StudentNumber.CompareTo(y.StudentNumber));
                    }
                }
                else
                {
                    return(x.ClassName.CompareTo(y.ClassName));
                }
            }
            else if (x.ClassId != null && y.ClassId == null)
            {
                return(-1);
            }
            else if (x.ClassId == null && y.ClassId != null)
            {
                return(1);
            }
            else
            {
                return(x.StudentNumber.CompareTo(y.StudentNumber));
            }
        }
예제 #2
0
        // 載入修課學生與成績到畫面
        private void LoadSCAttendScoreToDGV()
        {
            // 取得修課成績
            foreach (JHSCAttendRecord rec in JHSCAttend.SelectByCourseIDs(CIDs))
            {
                if (!_SCAttendListDic.ContainsKey(rec.RefStudentID))
                {
                    _SCAttendListDic.Add(rec.RefStudentID, rec);
                }
            }

            // 組成學生課程成績
            foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(_SCAttendListDic.Keys))
            {
                // 過濾非一般生
                if (studRec.Status != K12.Data.StudentRecord.StudentStatus.一般)
                {
                    continue;
                }

                StudentSCAtendScore sscas = new StudentSCAtendScore();
                sscas.StudentID = studRec.ID;
                if (studRec.Class != null)
                {
                    sscas.ClassName = studRec.Class.Name;
                    // 小郭, 2012/12/27
                    sscas.ClassId = studRec.Class.ID;
                }
                if (studRec.SeatNo.HasValue)
                {
                    sscas.SeatNo = studRec.SeatNo.Value;
                }
                sscas.Name          = studRec.Name;
                sscas.StudentNumber = studRec.StudentNumber;
                if (_SCAttendListDic.ContainsKey(studRec.ID))
                {
                    sscas.SCAtendRec = _SCAttendListDic[studRec.ID];
                }
                _StudentSCAtendScoreList.Add(sscas);
            }

            // 排序
            _StudentSCAtendScoreList.Sort(new Comparison <StudentSCAtendScore>(SortStudSeatNo));

            // 載入值
            dgv.SuspendLayout();
            dgv.Rows.Clear();

            int dgRowIdx = 0;

            foreach (StudentSCAtendScore sscas in _StudentSCAtendScoreList)
            {
                dgv.Rows.Add();
                dgv.Rows[dgRowIdx].Cells[colClassName.Index].Value     = sscas.ClassName;
                dgv.Rows[dgRowIdx].Cells[colSeatNo.Index].Value        = sscas.SeatNo;
                dgv.Rows[dgRowIdx].Cells[colName.Index].Value          = sscas.Name;
                dgv.Rows[dgRowIdx].Cells[colStudentNumber.Index].Value = sscas.StudentNumber;
                dgv.Rows[dgRowIdx].Cells[colInputScore.Index].Value    = sscas.GetOrdinarilyScore();
                dgv.Rows[dgRowIdx].Cells[colInputEffort.Index].Value   = sscas.GetOrdinarilyEffort();
                dgv.Rows[dgRowIdx].Tag = sscas.StudentID;
                dgRowIdx++;
            }
            dgv.ResumeLayout();
        }