Ejemplo n.º 1
0
        /// <summary>
        /// Overrides own Prioritys from the Prioritys from Parameter student
        /// </summary>
        /// <param name="student">Student what shall override</param>
        public void addPrioritys(Student student)
        {
            for(int i = 0; i < student.Prioritys.Count; i++){
                if (student.Prioritys[i] != null && student.Prioritys[i].Value.Length > 0 && student.Prioritys[i].Value != "Noch nicht abgestimmt")
                {
                    if (this.Prioritys.Count >= student.Prioritys[i].Prio)
                    {
                        this.Prioritys.Add(student.Prioritys[i]);
                    }
                    else
                    {
                        this.Prioritys[student.Prioritys[i].Prio] = student.Prioritys[i];
                    }

                }
            }
        }
Ejemplo n.º 2
0
 public bool addStudent(Student objStudent)
 {
     if (!this.findStudent(objStudent) && objStudent.countCourses > 0)
     {
         if (this.objStudents.Count >= iMaxPlaces)//Course full
         {
             return false;
         }
         else
         {
             this.objStudents.Add(objStudent);
             return true;
         }
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 3
0
 public bool Equals(Student tmpStudent)
 {
     if (tmpStudent != null && tmpStudent.ID == this.ID)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 4
0
        public static void readExcelData(object objFile, string sStudentXMLPath)
        {
            String sFile = objFile.ToString();//Parameter to String
            Excel.Application xlApp;
            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            Excel.Range range;

            int rCnt = 0;
            xlApp = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(sFile, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            range = xlWorkSheet.UsedRange;

            List<Student> objStudents = new List<Student>();
            int iStudentsIndex = 0;

            #region getPriority from PathName
            string[] tmpPathSplits = sFile.Split(' ');

            int priotity = -1;
            bool bCountCourses = false;

            try
            {
                priotity = Convert.ToInt32(Regex.Match(tmpPathSplits[(tmpPathSplits.Length - 2)], @"\d+").Value) - 1;
            }
            catch (FormatException)
            {
                bCountCourses = true;
            }

            #endregion

            //Gehe das ganze Tabellenblatt durch
            for (rCnt = 2; rCnt <= range.Rows.Count; rCnt++)//Startet von 2. Zeile wegen Überschriften
            {
                //Hier haben wir Zugriff auf jede Zeile
                if ((range.Cells[rCnt, 1] as Excel.Range).Value2 != null)
                {
                    string sName = (string)(range.Cells[rCnt, 1] as Excel.Range).Value2;
                    string sSurname = (string)(range.Cells[rCnt, 2] as Excel.Range).Value2;
                    string sID = (string)(range.Cells[rCnt, 3] as Excel.Range).Value2;
                    string sGroup = (string)(range.Cells[rCnt, 4] as Excel.Range).Value2;
                    string sAnswer = Convert.ToString((range.Cells[rCnt, 5] as Excel.Range).Value2);

                    //Calculation of new ID
                    if(sID.Length > 30){
                        sID = sID.Substring(sID.Length - 28, 27);
                    }

                    if (sID == null || sID.Length < 2)
                    {
                        sID = "ID" + sName + "x" + sSurname;
                    }

                    Student tmpStudent = new Student(sName, sSurname, sID, sGroup);
                    tmpStudent.setChoose(priotity, sAnswer, bCountCourses);

                    objStudents.Add(tmpStudent);
                    ++iStudentsIndex;
                }
            }

            StudentsList objStudentsList = StudentsList.getListFromXML(sStudentXMLPath);
            objStudentsList.setStudents(objStudents);//Set/Merges Students, Overrides existing Prioritys (if necesarry)
            objStudentsList.saveList(sStudentXMLPath);

            xlWorkBook.Close(true, null, null);
            xlApp.Quit();
        }
Ejemplo n.º 5
0
        private bool findStudent(Student objStudent)
        {
            foreach (Student tmpStudent in this.objStudents)
            {
                if (objStudent.Equals(tmpStudent))
                {
                    return true;
                }
            }

            return false;
        }