Ejemplo n.º 1
0
        public Enrollment(Activity activity, Student student, string cell)
        {
            if (cell == null) {
                throw new ArgumentNullException();
            }
            if (cell.Length > 2) {
                throw new ArgumentException("Cell data too long");
            }
            if (!(cell[0] == 'P' || (cell[0] >= '0' && cell[0] <= '9'))) {
                throw new ArgumentException("Priority not valid");
            }
            if (cell.Length > 1 && cell[1] != 'A') {
                throw new ArgumentException("Status not valid");
            }

            activity.Quota[student.Class].AddEnroll(this); // do this first, so we may throw KeyNotFoundException
            student.Quota.AddEnroll(this);

            Activity = activity;
            Student = student;

            Id = _globalIdCount++;
            PriorityI = (cell[0] == 'P') ? -1 : (cell[0] - '0');

            bool status = cell.Length > 1 && cell[1] == 'A';
            if (core.EnrollStatus == null)
                core.EnrollStatus = new State();
            core.EnrollStatus = core.EnrollStatus.Set(Id, status);
        }
Ejemplo n.º 2
0
        internal void LoadStudents()
        {
            if (Book == null)
            {
                throw new ApplicationException("Workbook not loaded");
            }

            var wsStu = (Worksheet)Book.Sheets["1.學生名單"];
            Range usedRange = wsStu.UsedRange;

            // stuArr is an one-based array
            var stuArr = (object[,])usedRange.Value;

            int count = stuArr.GetLength(0);
            StuList = new List<Student>(count);
            for (int i = 2; i <= count; i++)
            {
                try
                {
                    var s = new Student(
                        this,
                        i - 2,
                        stuArr[i, 1].ToString(),
                        int.Parse(stuArr[i, 2].ToString()),
                        stuArr[i, 3].ToString());

                    Debug.Print("Loaded -> " + i + ":" + s);
                    StuList.Add(s);
                }
                catch (NullReferenceException) { }
                catch (IndexOutOfRangeException) { }
                catch (ArgumentException) { }
            }
        }