public void testAddAttendance() { Student st = new Student(); Period ps = new Period(); Attendance at = new Attendance(); st.StudentID = "11"; st.FirstName = "asdf"; ps.PeriodID = 11; ps.PeriodName = "First"; at.DaysPresent = 11; at.DaysTardy = 100; contoller.addOrUpdateStudent(st); contoller.addOrUpdatePeriod(st, ps); contoller.addOrUpdateAttendance(st, at, ps); //Assert.AreEqual(contoller.getPeriod(st, 11).PeriodAttendance.DaysPresent, at.DaysPresent); //Assert.AreEqual(contoller.getPeriod(st, 11).PeriodAttendance.DaysTardy, at.DaysTardy); //Assert.AreEqual(contoller.getPeriod(st, 11).PeriodAttendance, at.DaysPresent); }
private static void addAttendanceFromXML(IStudentController controller, String doc) { #region codes //try //{ // XmlNodeList primelist = doc.SelectNodes("easygradepro/class"); // foreach (XmlNode primenode in primelist) // { // XmlNodeList peroidlist = primenode.SelectNodes("classrecord"); // XmlNodeList studentinfo = primenode.SelectNodes("student"); // foreach (XmlNode student in studentinfo) // { // Student idgeter = new Student(); // idgeter.StudentID = student.ChildNodes[0].ChildNodes[0].InnerText; // //String idgeter = ""; // //idgeter = student.ChildNodes[0].ChildNodes[0].InnerText; // XmlNodeList attend = student.SelectNodes("stud_attendance/stud_att_totals/stud_att_mastercat"); // foreach (XmlNode period in peroidlist) // { // Attendance a = new Attendance(); // Period p = new Period(); // p.PeriodID = Int32.Parse(period.ChildNodes[1].InnerText); // p.PeriodName = period.ChildNodes[2].InnerText; // Double exabsent = 0; // Double absent = 0; // Double total = 0; // Double tardy = 0; // foreach (XmlNode attendance in attend) // { // if (attendance.Attributes["cat"].Value == "Excused Absence") // { // //change "" to 0 // if (attendance.InnerText != "") // { // exabsent = Convert.ToDouble(attendance.InnerText); // } // else // { exabsent = 0; } // } // if (attendance.Attributes["cat"].Value == "Unexcused Absence") // { // //change "" to 0 // if (attendance.InnerText != "") // { // absent = Convert.ToDouble(attendance.InnerText); // } // else // { // absent = 0; // } // } // total = exabsent + absent; // a.DaysAbsent = total; // if (attendance.Attributes["cat"].Value == "Tardy") // { // //change "" to 0 // if (attendance.InnerText != "") // { // tardy = Convert.ToDouble(attendance.InnerText); // } // else { tardy = 0; } // } // a.DaysTardy = tardy; // controller.addOrUpdateAttendance(controller.getStudent(idgeter.StudentID), a, p); // } // } // } // } //} //catch (Exception er) //{ // System.Windows.Forms.MessageBox.Show(er.Message,"Attendance catcher!!!"); //} #endregion double ab = 0; double ex = 0; double tardy = 0; try { myReader = new StreamReader(doc); String loadedString = null; while ((loadedString = myReader.ReadLine()) != null) { Student stud = new Student(); Attendance att = new Attendance(); Period p = new Period(); String[] studentDetails = loadedString.Split('\t'); stud.StudentID = studentDetails[0]; stud.FirstName = studentDetails[1]; stud.LastName = studentDetails[2]; if (studentDetails[3].ToString() != "") ex = Convert.ToDouble(studentDetails[3]); else ex = 0; if (studentDetails[4].ToString() != "") ab = Convert.ToDouble(studentDetails[4]); else ab = 0; if (studentDetails[5].ToString() != "") tardy = Convert.ToDouble(studentDetails[5]); else tardy = 0; p.PeriodID = 1; p.PeriodName = "Term 1"; att.DaysAbsent = ex + ab; att.DaysTardy = tardy; controller.addOrUpdateAttendance(controller.getStudent(stud.StudentID), att, p); } myReader.Close(); } catch (Exception er) { System.Windows.Forms.MessageBox.Show(er.Message, "Unable to run the File"); } }
private static void addAttendanceFromXML(IStudentController controller, String doc) { #region codes //try //{ // XmlNodeList primelist = doc.SelectNodes("easygradepro/class"); // foreach (XmlNode primenode in primelist) // { // XmlNodeList peroidlist = primenode.SelectNodes("classrecord"); // XmlNodeList studentinfo = primenode.SelectNodes("student"); // foreach (XmlNode student in studentinfo) // { // Student idgeter = new Student(); // idgeter.StudentID = student.ChildNodes[0].ChildNodes[0].InnerText; // //String idgeter = ""; // //idgeter = student.ChildNodes[0].ChildNodes[0].InnerText; // XmlNodeList attend = student.SelectNodes("stud_attendance/stud_att_totals/stud_att_mastercat"); // foreach (XmlNode period in peroidlist) // { // Attendance a = new Attendance(); // Period p = new Period(); // p.PeriodID = Int32.Parse(period.ChildNodes[1].InnerText); // p.PeriodName = period.ChildNodes[2].InnerText; // Double exabsent = 0; // Double absent = 0; // Double total = 0; // Double tardy = 0; // foreach (XmlNode attendance in attend) // { // if (attendance.Attributes["cat"].Value == "Excused Absence") // { // //change "" to 0 // if (attendance.InnerText != "") // { // exabsent = Convert.ToDouble(attendance.InnerText); // } // else // { exabsent = 0; } // } // if (attendance.Attributes["cat"].Value == "Unexcused Absence") // { // //change "" to 0 // if (attendance.InnerText != "") // { // absent = Convert.ToDouble(attendance.InnerText); // } // else // { // absent = 0; // } // } // total = exabsent + absent; // a.DaysAbsent = total; // if (attendance.Attributes["cat"].Value == "Tardy") // { // //change "" to 0 // if (attendance.InnerText != "") // { // tardy = Convert.ToDouble(attendance.InnerText); // } // else { tardy = 0; } // } // a.DaysTardy = tardy; // controller.addOrUpdateAttendance(controller.getStudent(idgeter.StudentID), a, p); // } // } // } // } //} //catch (Exception er) //{ // System.Windows.Forms.MessageBox.Show(er.Message,"Attendance catcher!!!"); //} #endregion double ab = 0; double ex = 0; double tardy = 0; try { myReader = new StreamReader(doc); String loadedString = null; while ((loadedString = myReader.ReadLine()) != null) { Student stud = new Student(); Attendance att = new Attendance(); Period p = new Period(); String[] studentDetails = loadedString.Split('\t'); stud.StudentID = studentDetails[0]; stud.FirstName = studentDetails[1]; stud.LastName = studentDetails[2]; if (studentDetails[3].ToString() != "") { ex = Convert.ToDouble(studentDetails[3]); } else { ex = 0; } if (studentDetails[4].ToString() != "") { ab = Convert.ToDouble(studentDetails[4]); } else { ab = 0; } if (studentDetails[5].ToString() != "") { tardy = Convert.ToDouble(studentDetails[5]); } else { tardy = 0; } p.PeriodID = 1; p.PeriodName = "Term 1"; att.DaysAbsent = ex + ab; att.DaysTardy = tardy; controller.addOrUpdateAttendance(controller.getStudent(stud.StudentID), att, p); } myReader.Close(); } catch (Exception er) { System.Windows.Forms.MessageBox.Show(er.Message, "Unable to run the File"); } }