Ejemplo n.º 1
0
 public Request(Student requestingStudent, DateTime requestTime, string requestOne, string requestTwo, string requestThree, string requestFour, string requestFive)
 {
     this.requestingStudent = requestingStudent;
     this.requestTime = requestTime;
     this.requestOne = requestOne;
     this.requestTwo = requestTwo;
     this.requestThree = requestThree;
     this.requestFour = requestFour;
     this.requestFive = requestFive;
 }
        /// <summary>
        /// Creates the linked student and request sheets
        /// </summary>
        /// <param name="requestSheet">Extracted Excel 2007+ data</param>
        private void createStudentAndRequestList(ExcelWorksheet requestSheet)
        {
            string firstName, lastName, requestOne, requestTwo, requestThree, requestFour, requestFive, studentGradeLevel, studentTeacher, studentNumber, errorStudent;
            int studentID;
            DateTime studentTime;
            errorStudent = "";
            studentList = new List<Student>();
            requestList = new List<Request>();

            try
            {
                for (int row = 2; row <= requestSheet.Dimension.End.Row; row++)
                {
                    studentID = row - 1;

                    double serialDate = double.Parse(requestSheet.Cells[row, 1].Value.ToString());
                    studentTime = DateTime.FromOADate(serialDate);
                    firstName = (String)requestSheet.Cells[row, 2].Value.ToString();
                    lastName = (String)requestSheet.Cells[row, 3].Value.ToString();
                    requestOne = (String)requestSheet.Cells[row, 4].Value.ToString();
                    requestTwo = (String)requestSheet.Cells[row, 5].Value.ToString();
                    requestThree = (String)requestSheet.Cells[row, 6].Value.ToString();
                    requestFour = (String)requestSheet.Cells[row, 7].Value.ToString();
                    requestFive = (String)requestSheet.Cells[row, 8].Value.ToString();
                    studentGradeLevel = (String)requestSheet.Cells[row, 9].Value.ToString();
                    studentNumber = (String)requestSheet.Cells[row, 10].Value.ToString();
                    studentTeacher = (String)requestSheet.Cells[row, 11].Value.ToString();

                    errorStudent = lastName + ", " + firstName;

                    Request currentRequest;
                    Student currentStudent = new Student(firstName, lastName, studentNumber, studentTeacher,  studentGradeLevel);
                    currentRequest = new Request(currentStudent, studentTime, requestOne, requestTwo, requestThree, requestFour, requestFive);
                    currentStudent.StudentRequest = currentRequest;

                    requestList.Add(currentRequest);
                    studentList.Add(currentStudent);

                }

            }
            catch (Exception currentException)
            {
                MessageBox.Show("last successful student was: " + errorStudent + " check the .XLSX file");
                Application.Exit();
            }
        }