private TableRow addRow(KeyValuePair <string, List <Student> > community) { TableRow newRow = new TableRow(); TableCell nameCell = new TableCell(); TableCell valueCell = new TableCell(); StringBuilder toolTip = new StringBuilder(); foreach (Student student in community.Value) { toolTip.Append(student.getStudentID() + " " + student.getDisplayName() + " (" + student.getSchoolName() + ")<br> "); } nameCell.Text = community.Key; nameCell.VerticalAlign = VerticalAlign.Top; string divName = LSKYCommon.removeSpaces(community.Key) + "_" + random.Next(1000, 9999); valueCell.Text = "<a style=\"color: blue; text-decoration: underline; cursor:pointer;\" onclick=\"toggleVisible('" + divName + "');\">" + community.Value.Count.ToString() + "</a><div id=\"" + divName + "\" style=\"display: none;\">" + toolTip.ToString() + "</div>"; valueCell.VerticalAlign = VerticalAlign.Top; newRow.Cells.Add(nameCell); newRow.Cells.Add(valueCell); return(newRow); }
protected void Page_Load(object sender, EventArgs e) { int SelectedSchoolID = -1; if (int.TryParse(Request.QueryString["schoolid"], out SelectedSchoolID)) { using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { School selectedSchool = School.loadThisSchool(connection, SelectedSchoolID); if (selectedSchool != null) { List <Student> schoolStudents = Student.loadStudentsFromThisSchool(connection, selectedSchool.getGovID()); schoolStudents.Sort( delegate(Student first, Student next) { return(first.getLastName().CompareTo(next.getLastName())); } ); sendPDF(GeneratePDF(selectedSchool, schoolStudents, false), LSKYCommon.removeSpaces(selectedSchool.getName()) + "_StudentsByGrade"); } else { DisplayError("School not found"); } } } else { DisplayError("Invalid school"); } }
private void createSession(string username, string remoteIP, string useragent, bool is_admin) { string newSessionID = getNewSessionID(Request.ServerVariables["ALL_RAW"]); /* Create a session in the database */ String dbConnectionString = ConfigurationManager.ConnectionStrings["DataExplorerDatabase"].ConnectionString; /* Set a limit on how long this login session will last, based on time of day */ /* If logging in during the work day, make a session last 7 hours */ /* If logging in after hours, make the session only last 2 hours */ TimeSpan workDayStart = new TimeSpan(7, 0, 0); TimeSpan workDayEnd = new TimeSpan(15, 00, 0); TimeSpan now = DateTime.Now.TimeOfDay; TimeSpan sessionDuration; if ((now >= workDayStart) && (now <= workDayEnd)) { sessionDuration = new TimeSpan(8, 0, 0); } else { sessionDuration = new TimeSpan(2, 0, 0); } using (SqlConnection dbConnection = new SqlConnection(dbConnectionString)) { using (SqlCommand sqlCommand = new SqlCommand()) { sqlCommand.Connection = dbConnection; sqlCommand.CommandType = CommandType.Text; //sqlCommand.CommandText = "INSERT INTO sessions(id_hash,username,ip,useragent,sessionstarts,sessionends,is_admin) VALUES('" + newSessionID + "','" + username + "','" + remoteIP + "','" + useragent + "','" + DateTime.Now.ToString() + "','" + DateTime.Now.Add(sessionDuration).ToString() + "');"; sqlCommand.CommandText = "INSERT INTO sessions(id_hash,username,ip,useragent,sessionstarts,sessionends) VALUES(@ID, @USERNAME, @IP, @USERAGENT, @SESSIONSTART, @SESSIONEND);"; sqlCommand.Parameters.AddWithValue("@ID", newSessionID); sqlCommand.Parameters.AddWithValue("@USERNAME", username); sqlCommand.Parameters.AddWithValue("@IP", remoteIP); sqlCommand.Parameters.AddWithValue("@USERAGENT", useragent); sqlCommand.Parameters.AddWithValue("@SESSIONSTART", DateTime.Now); sqlCommand.Parameters.AddWithValue("@SESSIONEND", DateTime.Now.Add(sessionDuration)); sqlCommand.Connection.Open(); sqlCommand.ExecuteNonQuery(); sqlCommand.Connection.Close(); } } /* Create a cookie with the hashed ID */ HttpCookie newCookie = new HttpCookie("lskyDataExplorer"); newCookie.Value = newSessionID; newCookie.Expires = DateTime.Now.Add(sessionDuration); newCookie.Domain = LSKYCommon.getServerName(Request); newCookie.Secure = true; Response.Cookies.Add(newCookie); }
protected void Page_Load(object sender, EventArgs e) { List <Student> AllStudents; using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { AllStudents = Student.loadAllStudents(connection); } sendCSV(GenerateCSV(AllStudents), "LSKY_EnrollmentCounts_" + LSKYCommon.getCurrentTimeStampForFilename()); }
protected void Page_Load(object sender, EventArgs e) { List <Outcome> outcomes = new List <Outcome>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { outcomes = Outcome.loadAllObjectives(connection); } sendCSV(GenerateCSV(outcomes), "LSKY_OUTCOMES_" + LSKYCommon.getCurrentTimeStampForFilename()); }
protected void Page_Load(object sender, EventArgs e) { /* Load all courses */ List <Course> allCourses = new List <Course>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allCourses = Course.loadAllCourses(connection); } sendCSV(GenerateCSV(allCourses), "LSKY_COURSES_" + LSKYCommon.getCurrentTimeStampForFilename()); }
private TableRow addAbsenceRow(Absence abs) { TableRow newRow = new TableRow(); TableCell dateCell = new TableCell(); dateCell.Text = abs.getDate().ToLongDateString(); newRow.Cells.Add(dateCell); TableCell blockCell = new TableCell(); blockCell.Text = abs.getBlock().ToString(); newRow.Cells.Add(blockCell); TableCell statusCell = new TableCell(); string status = abs.getStatus(); if (abs.getStatus().ToLower() == "late") { status = status + " (" + abs.getMinutes() + " min)"; } statusCell.Text = status; newRow.Cells.Add(statusCell); TableCell reasonCell = new TableCell(); reasonCell.Text = abs.getReason(); newRow.Cells.Add(reasonCell); TableCell excusedCell = new TableCell(); excusedCell.Text = LSKYCommon.boolToYesOrNoHTML(abs.excused); newRow.Cells.Add(excusedCell); TableCell commentCell = new TableCell(); commentCell.Text = abs.getComment(); newRow.Cells.Add(commentCell); return(newRow); }
private TableRow addCourseTableRow(Course course) { TableRow newRow = new TableRow(); newRow.CssClass = "datatable_row"; TableCell newCell = null; newCell = new TableCell(); newCell.Text = course.name; newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = course.courseCode; newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = course.governmentCode; newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = course.governmentCourseID.ToString(); newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = course.id.ToString(); newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = course.school; newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = LSKYCommon.boolToYesOrNoHTML(course.offeredInSchool); newRow.Cells.Add(newCell); newCell = new TableCell(); newCell.Text = LSKYCommon.boolToYesOrNoHTML(course.schoolExam); newRow.Cells.Add(newCell); return(newRow); }
protected void btnLogin_Click(object sender, EventArgs e) { string givenUsername = txtUsername.Text; string givenPassword = txtPassword.Text; List <string> groupMembers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.userGroupName); List <string> adminGroupMembers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.adminGroupName); if (!((string.IsNullOrEmpty(givenUsername)) || (string.IsNullOrEmpty(givenPassword)))) { if (validate("lskysd", givenUsername, givenPassword)) { if (adminGroupMembers.Contains(givenUsername)) { logLoginAttempt(txtUsername.Text, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], "SUCCESS", "User is administrator"); createSession(givenUsername, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], true); Response.Redirect("/SLReports/"); } else if (groupMembers.Contains(givenUsername)) { logLoginAttempt(txtUsername.Text, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], "SUCCESS", ""); createSession(givenUsername, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], false); Response.Redirect("/SLReports/"); } else { displayError("<b style=\"color: red\">Access denied:</b> Your credentials worked, but your account does not have the required permissions to access this site.<br><br> To request access to this site, please create a ticket in our <a href=\"https://helpdesk.lskysd.ca\">Help Desk system</a>."); logLoginAttempt(txtUsername.Text, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], "DENIED", "User is not in security group"); } } else { displayError("<b style=\"color: red\">Access denied:</b> Invalid username or password"); logLoginAttempt(txtUsername.Text, Request.ServerVariables["REMOTE_ADDR"], Request.ServerVariables["HTTP_USER_AGENT"], "DENIED", "Incorrect username or password"); } } }
protected void Page_Load(object sender, EventArgs e) { //lblAdminGroup.Text = LSKYCommon.adminGroupName; //lblUserGroup.Text = LSKYCommon.userGroupName; // Get a list of users from security groups - recursively List <string> groupMembers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.userGroupName); List <string> adminGroupMembers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.adminGroupName); groupMembers.Sort(); adminGroupMembers.Sort(); foreach (string user in adminGroupMembers) { tblAdministrators.Rows.Add(addUserRow(user)); } foreach (string user in groupMembers) { tblUsers.Rows.Add(addUserRow(user)); } }
protected void Page_Load(object sender, EventArgs e) { String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { /* Load students */ List <Student> displayedStudents = new List <Student>(); displayedStudents = Student.loadAllStudents(connection); /* Create the CSV */ if (displayedStudents.Count > 0) { sendCSV(GenerateCSV(displayedStudents), "STUDENTS_ALLSCHOOLS_" + LSKYCommon.removeSpaces(LSKYCommon.getCurrentTimeStampForFilename())); } else { displayError("No students were found at this school"); } } }
protected MemoryStream GenerateCSV(List <Course> courses) { MemoryStream csvFile = new MemoryStream(); StreamWriter writer = new StreamWriter(csvFile, Encoding.UTF8); /* Headings */ StringBuilder headingLine = new StringBuilder(); headingLine.Append("CourseName, CourseCode, GovernmentCourseCode, GovernmentCourseID, DatabaseID, School, OfferedInSchool, SchoolExam"); writer.WriteLine(headingLine.ToString()); /* Data */ foreach (Course course in courses) { StringBuilder studentLine = new StringBuilder(); studentLine.Append(course.name); studentLine.Append(","); studentLine.Append(course.courseCode); studentLine.Append(","); studentLine.Append(course.governmentCode); studentLine.Append(","); studentLine.Append(course.governmentCourseID); studentLine.Append(","); studentLine.Append(course.id); studentLine.Append(","); studentLine.Append(course.school); studentLine.Append(","); studentLine.Append(LSKYCommon.boolToYesOrNo(course.offeredInSchool)); studentLine.Append(","); studentLine.Append(LSKYCommon.boolToYesOrNo(course.schoolExam)); writer.WriteLine(studentLine.ToString()); } writer.Flush(); csvFile.Flush(); return(csvFile); }
protected void btnGenerate_Click(object sender, EventArgs e) { // Parse the selected school ID int schoolID = -1; if (int.TryParse(drpSchools.SelectedValue, out schoolID)) { School selectedSchool = null; using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { // Load the school selectedSchool = School.loadThisSchool(connection, schoolID); if (selectedSchool != null) { // Load the selected student Student selectedStudent = Student.loadThisStudent(connection, drpStudents.SelectedValue); if (selectedStudent != null) { List <Student> selectedStudents = new List <Student>(); selectedStudents.Add(selectedStudent); // Load checked report periods List <int> selectedReportPeriodIDs = new List <int>(); List <ReportPeriod> selectedReportPeriods = new List <ReportPeriod>(); foreach (ListItem item in chkReportPeriods.Items) { if (item.Selected) { int parsedValue = -1; if (int.TryParse(item.Value, out parsedValue)) { if (!selectedReportPeriodIDs.Contains(parsedValue)) { selectedReportPeriodIDs.Add(parsedValue); } } } } if (selectedReportPeriodIDs.Count > 0) { foreach (int reportPeriodID in selectedReportPeriodIDs) { ReportPeriod loadedReportPeriod = ReportPeriod.loadThisReportPeriod(connection, reportPeriodID); if (loadedReportPeriod != null) { selectedReportPeriods.Add(loadedReportPeriod); } } // Load student mark data List <Student> studentsWithMarks = new List <Student>(); foreach (Student student in selectedStudents) { studentsWithMarks.Add(LSKYCommon.loadStudentMarkData(connection, student, selectedReportPeriods)); } // Options bool doubleSidedMode = false; if (chkDoubleSidedMode.Checked) { doubleSidedMode = true; } bool anonymize = false; if (chkAnonymize.Checked) { anonymize = true; } bool showPhotos = false; if (chkShowPhotos.Checked) { showPhotos = true; } bool showClassAttendance = false; if (chkClassAttendance.Checked) { showClassAttendance = true; } bool showLegends = true; bool showAttendanceSummary = false; if (chkShowAttendanceSummary.Checked) { showAttendanceSummary = true; } string adminComment = txtAdminComment.Text; // Send the report card String fileName = "ReportCards_" + selectedStudent.getStudentID() + "_" + DateTime.Today.Year + "_" + DateTime.Today.Month + "_" + DateTime.Today.Day + ".pdf"; if ((selectedReportPeriods.Count > 0) && (selectedStudents.Count > 0)) { sendPDF(PDFReportCardParts.GeneratePDF(selectedStudents, selectedReportPeriods, anonymize, showPhotos, doubleSidedMode, showClassAttendance, showLegends, showAttendanceSummary, adminComment), fileName); } } else { // No report periods were selected - should display some kind of error here } } } } } }
protected void Page_Load(object sender, EventArgs e) { List <Student> students = new List <Student>(); List <Student> displayedStudents = new List <Student>(); List <ReportPeriod> selectedReportPeriods = new List <ReportPeriod>(); bool anonymize = false; if (!string.IsNullOrEmpty(Request.QueryString["anon"])) { anonymize = true; } using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { // Parse student IDs if (!string.IsNullOrEmpty(Request.QueryString["students"])) { foreach (string student in Request.QueryString["students"].Split(';')) { if (!string.IsNullOrEmpty(student)) { int student_id = -1; if (int.TryParse(student, out student_id)) { students.Add(Student.loadThisStudent(connection, student_id.ToString())); } } } foreach (string rp in Request.QueryString["reportperiods"].Split(';')) { if (!string.IsNullOrEmpty(rp)) { int rp_id = -1; if (int.TryParse(rp, out rp_id)) { selectedReportPeriods.Add(ReportPeriod.loadThisReportPeriod(connection, rp_id)); } } } } } selectedReportPeriods.Sort(); using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { foreach (Student student in students) { if (student != null) { Stopwatch studentStopWatch = new Stopwatch(); studentStopWatch.Start(); displayedStudents.Add(LSKYCommon.loadStudentMarkData(connection, student, selectedReportPeriods)); studentStopWatch.Stop(); } } students.Clear(); } // Display data Response.Write("<BR><B>DEBUG DATA</b>"); foreach (Student student in displayedStudents) { Response.Write("<BR><hr><BR><b>" + student + "</B>"); Response.Write("<BR><b>Absense entries: </b>" + student.absences.Count); Response.Write("<BR> <b>Track:</b> " + student.track); foreach (Term term in student.track.terms) { Response.Write("<BR> <b>Term:</b> " + term); foreach (ReportPeriod rp in term.ReportPeriods) { Response.Write("<BR> <b>Report Period:</b> " + rp); Response.Write("<BR> <b>Marks: </b> " + rp.marks.Count); foreach (Mark mark in rp.marks) { Response.Write("<BR> <b>Mark: </b> " + mark); } } Response.Write("<BR><BR> <b>Classes:</b> " + term.Courses.Count); foreach (SchoolClass c in term.Courses) { Response.Write("<BR><BR> <b>Class:</b> " + c); Response.Write("<BR> <b>Teacher:</b> " + c.teacherName); Response.Write("<BR> <b>Marks:</b> " + c.Marks.Count); Response.Write("<BR> <b>Outcomes:</b> " + c.Outcomes.Count); Response.Write("<BR> <b>Outcome Marks:</b> " + c.OutcomeMarks.Count); Response.Write("<BR> <b>Life Skills:</b> " + c.LifeSkills.Count); Response.Write("<BR> <b>Life Skills Marks:</b> " + c.LifeSkillMarks.Count); foreach (ReportPeriod rp in term.ReportPeriods) { Response.Write("<BR> <b>Report Period:</b> " + rp); foreach (Mark m in c.Marks) { if (m.reportPeriodID == rp.ID) { Response.Write("<BR> <b>Mark</b> " + m); } } foreach (OutcomeMark om in c.OutcomeMarks) { if (om.reportPeriodID == rp.ID) { Response.Write("<BR> <b>OutcomeMark:</b> " + om); } } } Response.Write("<BR> <b>Outcomes:</b> " + c.Outcomes.Count); foreach (Outcome o in c.Outcomes) { Response.Write("<BR> <b>Outcome:</b> " + o); foreach (OutcomeMark om in o.marks) { Response.Write("<BR> <b>OutcomeMark:</b> " + om); } } Response.Write("<BR> <b>Life Skills / SLBs:</b> " + c.LifeSkills.Count); foreach (Outcome o in c.LifeSkills) { Response.Write("<BR> <b>Outcome</b> " + o); foreach (OutcomeMark om in o.marks) { Response.Write("<BR> <b>OutcomeMark:</b> " + om); } } } } } }
protected void Page_Load(object sender, EventArgs e) { List <Student> allStudents = new List <Student>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allStudents = Student.loadAllStudents(connection); } Dictionary <string, Student> workspace_govid = new Dictionary <string, Student>(); Dictionary <string, Student> workspace_names = new Dictionary <string, Student>(); Dictionary <Student, string> allDupesWithReason = new Dictionary <Student, string>(); foreach (Student student in allStudents) { if (!string.IsNullOrEmpty(student.getGovernmentID())) { if (!workspace_govid.ContainsKey(student.getGovernmentID())) { workspace_govid.Add(student.getGovernmentID(), student); } else { allDupesWithReason.Add(student, "Same government ID as " + workspace_govid[student.getGovernmentID()].getStudentID() + " (" + workspace_govid[student.getGovernmentID()].getDisplayName() + ")"); allDupesWithReason.Add(workspace_govid[student.getGovernmentID()], "Same government ID as " + student.getStudentID() + " (" + student.getDisplayName() + ")"); } } String condensedName = student.getDisplayName().ToLower().Replace(" ", string.Empty).Replace("-", string.Empty); if (!workspace_names.ContainsKey(condensedName)) { workspace_names.Add(condensedName, student); } else { if (student.getDateOfBirth().ToShortDateString() == workspace_names[condensedName].getDateOfBirth().ToShortDateString()) { if (!allDupesWithReason.ContainsKey(student)) { allDupesWithReason.Add(student, "Same name and date of birth as " + workspace_names[condensedName].getStudentID() + " (" + workspace_names[condensedName].getDisplayName() + ")"); } if (!allDupesWithReason.ContainsKey(workspace_names[condensedName])) { allDupesWithReason.Add(workspace_names[condensedName], "Same name and date of birth as " + student.getStudentID() + " (" + student.getDisplayName() + ")"); } } else { if (!allDupesWithReason.ContainsKey(student)) { allDupesWithReason.Add(student, "Same name as " + workspace_names[condensedName].getStudentID() + " (" + workspace_names[condensedName].getDisplayName() + ")"); } if (!allDupesWithReason.ContainsKey(workspace_names[condensedName])) { allDupesWithReason.Add(workspace_names[condensedName], "Same name as " + student.getStudentID() + " (" + student.getDisplayName() + ")"); } } } } sendCSV(GenerateCSV(allDupesWithReason), "LSKY_DUPLICATES_" + LSKYCommon.getCurrentTimeStampForFilename()); }
protected void Page_Load(object sender, EventArgs e) { List <Student> students = new List <Student>(); List <Student> displayedStudents = new List <Student>(); List <ReportPeriod> selectedReportPeriods = new List <ReportPeriod>(); bool anonymize = false; if (!string.IsNullOrEmpty(Request.QueryString["anon"])) { anonymize = true; } bool showPhoto = false; if ((!string.IsNullOrEmpty(Request.QueryString["showphoto"])) || (!string.IsNullOrEmpty(Request.QueryString["showphotos"]))) { showPhoto = true; } bool doubleSided = false; if (!string.IsNullOrEmpty(Request.QueryString["doublesided"])) { doubleSided = true; } bool showClassAttendance = false; if (!string.IsNullOrEmpty(Request.QueryString["showclassattendance"])) { showClassAttendance = true; } bool showLegends = false; if ((!string.IsNullOrEmpty(Request.QueryString["showlegends"])) || (!string.IsNullOrEmpty(Request.QueryString["showlegend"]))) { showLegends = true; } bool showAttendanceSummary = false; if ((!string.IsNullOrEmpty(Request.QueryString["showattendancesummary"])) || (!string.IsNullOrEmpty(Request.QueryString["showattendancesummaries"]))) { showAttendanceSummary = true; } using (SqlConnection connection = new SqlConnection(dbConnectionString)) { // Parse student IDs if (!string.IsNullOrEmpty(Request.QueryString["students"])) { foreach (string student in Request.QueryString["students"].Split(';')) { if (!string.IsNullOrEmpty(student)) { int student_id = -1; if (int.TryParse(student, out student_id)) { students.Add(Student.loadThisStudent(connection, student_id.ToString())); } } } foreach (string rp in Request.QueryString["reportperiods"].Split(';')) { if (!string.IsNullOrEmpty(rp)) { int rp_id = -1; if (int.TryParse(rp, out rp_id)) { selectedReportPeriods.Add(ReportPeriod.loadThisReportPeriod(connection, rp_id)); } } } } } selectedReportPeriods.Sort(); using (SqlConnection connection = new SqlConnection(dbConnectionString)) { foreach (Student student in students) { if (student != null) { Stopwatch studentStopWatch = new Stopwatch(); studentStopWatch.Start(); displayedStudents.Add(LSKYCommon.loadStudentMarkData(connection, student, selectedReportPeriods)); studentStopWatch.Stop(); } } students.Clear(); } String fileName = "ReportCards_" + DateTime.Today.Year + "_" + DateTime.Today.Month + "_" + DateTime.Today.Day + ".pdf"; if ((selectedReportPeriods.Count > 0) && (displayedStudents.Count > 0)) { sendPDF(PDFReportCardParts.GeneratePDF(displayedStudents, selectedReportPeriods, anonymize, showPhoto, doubleSided, showClassAttendance, showLegends, showAttendanceSummary, string.Empty), fileName); } }
protected void Page_Load(object sender, EventArgs e) { DateTime startDate = DateTime.Today; DateTime endDate = DateTime.Today; if (!IsPostBack) { AllSchools = new List <School>(); selectedSchool = null; #region set up date picker fields #region Year for (int x = DateTime.Now.Year - 10; x <= DateTime.Now.Year + 10; x++) { ListItem newLI_From = new ListItem(x.ToString(), x.ToString()); if (!IsPostBack) { if (x == DateTime.Now.Year) { newLI_From.Selected = true; } } ListItem newLI_To = new ListItem(x.ToString(), x.ToString()); if (!IsPostBack) { if (x == DateTime.Now.Year) { newLI_To.Selected = true; } } from_year.Items.Add(newLI_From); to_year.Items.Add(newLI_To); } #endregion #region Month for (int x = 1; x <= 12; x++) { ListItem newLI_From = new ListItem(LSKYCommon.getMonthName(x), x.ToString()); ListItem newLI_To = new ListItem(LSKYCommon.getMonthName(x), x.ToString()); if (!IsPostBack) { if (x == (DateTime.Now.Month)) { newLI_From.Selected = true; } } if (!IsPostBack) { if (x == DateTime.Now.Month) { newLI_To.Selected = true; } } from_month.Items.Add(newLI_From); to_month.Items.Add(newLI_To); } #endregion #region Day ListItem firstDay_From = new ListItem("First Day", "1"); if (!IsPostBack) { firstDay_From.Selected = true; } ListItem firstDay_To = new ListItem("First Day", "1"); from_day.Items.Add(firstDay_From); to_day.Items.Add(firstDay_To); for (int x = 1; x <= 31; x++) { ListItem newLI_From = new ListItem(x.ToString(), x.ToString()); ListItem newLI_To = new ListItem(x.ToString(), x.ToString()); //if (!IsPostBack) //{ // if (x == (DateTime.Now.Day)) // newLI_From.Selected = true; //} //if (!IsPostBack) //{ // if (x == DateTime.Now.Day) // newLI_To.Selected = true; //} from_day.Items.Add(newLI_From); to_day.Items.Add(newLI_To); } ListItem lastDay_From = new ListItem("Last Day", "31"); ListItem lastDay_To = new ListItem("Last Day", "31"); if (!IsPostBack) { lastDay_To.Selected = true; } from_day.Items.Add(lastDay_From); to_day.Items.Add(lastDay_To); #endregion #endregion #region Set up list of all schools using (SqlConnection connection = new SqlConnection(dbConnectionString)) { AllSchools = School.loadAllSchools(connection); } foreach (School school in AllSchools) { ListItem newLI = new ListItem(); newLI.Text = school.getName(); newLI.Value = school.getGovIDAsString(); lstSchoolList.Items.Add(newLI); } #endregion } }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["studentid"])) { int studentID = 0; if (int.TryParse(Request.QueryString["studentid"], out studentID)) { // Parse the date DateTime Date_From = DateTime.Parse(Request.QueryString["from_date"]); DateTime Date_To = DateTime.Parse(Request.QueryString["to_date"]); // Load student Student selectedStudent = null; using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { selectedStudent = Student.loadThisStudent(connection, studentID.ToString()); if (selectedStudent != null) { // Load attendnace for the student selectedStudent.absences = Absence.loadAbsencesForThisStudentAndTimePeriod(connection, selectedStudent, Date_From, Date_To); // Load contacts for the student selectedStudent.contacts = Contact.loadContactsForStudent(connection, selectedStudent); sendPDF(GeneratePDF(Date_From, Date_To, selectedStudent), "Attendance_" + LSKYCommon.removeSpaces(selectedStudent.getDisplayName()) + "_" + Date_From.Year + "_" + Date_From.Month + "_" + Date_From.Day + "_to_" + Date_To.Year + "_" + Date_To.Month + "_" + Date_To.Day); } else { Response.Write("Invalid student"); } } } else { Response.Write("Invalid student ID"); } } else { Response.Write("Missing student ID"); } }
protected void Page_Load(object sender, EventArgs e) { DateTime startDate = DateTime.Today; DateTime endDate = DateTime.Today; /* Get data from the query string */ if (!String.IsNullOrEmpty(Request.QueryString["schoolid"])) { if ((!String.IsNullOrEmpty(Request.QueryString["from_year"])) || (!String.IsNullOrEmpty(Request.QueryString["from_month"])) || (!String.IsNullOrEmpty(Request.QueryString["from_day"]))) { if ((!String.IsNullOrEmpty(Request.QueryString["to_year"])) || (!String.IsNullOrEmpty(Request.QueryString["to_month"])) || (!String.IsNullOrEmpty(Request.QueryString["to_day"]))) { // Parse school int selectedSchoolID = -1; if (int.TryParse(Request.QueryString["schoolid"], out selectedSchoolID)) { // Parse from date int startYear = -1; int startMonth = -1; int startDay = -1; int.TryParse(Request.QueryString["from_year"], out startYear); int.TryParse(Request.QueryString["from_month"], out startMonth); int.TryParse(Request.QueryString["from_day"], out startDay); // Parse to date int endYear = -1; int endMonth = -1; int endDay = -1; int.TryParse(Request.QueryString["to_year"], out endYear); int.TryParse(Request.QueryString["to_month"], out endMonth); int.TryParse(Request.QueryString["to_day"], out endDay); if ( !( (startYear == -1) || (startMonth == -1) || (startDay == -1) || (endYear == -1) || (endMonth == -1) || (endDay == -1) ) ) { if (startDay > DateTime.DaysInMonth(startYear, startMonth)) { startDay = DateTime.DaysInMonth(startYear, startMonth); } if (endDay > DateTime.DaysInMonth(endYear, endMonth)) { endDay = DateTime.DaysInMonth(endYear, endMonth); } startDate = new DateTime(startYear, startMonth, startDay); endDate = new DateTime(endYear, endMonth, endDay); // Grab data using (SqlConnection connection = new SqlConnection(dbConnectionString)) { School selectedSchool = School.loadThisSchool(connection, selectedSchoolID); if (selectedSchool != null) { List <Student> DisplayedStudents = LSKY_INAC.loadStudentData(connection, selectedSchool, startDate, endDate); // Output a CSV file sendCSV(GenerateCSV(DisplayedStudents), "INAC_" + LSKYCommon.removeSpaces(selectedSchool.getName()) + "_" + startDate.Year + "-" + startDate.Month + "-" + startDate.Day + "_" + endDate.Year + "-" + endDate.Month + "-" + endDate.Day); } else { Response.Write("Invalid school specified"); } } } else { Response.Write("Invalid date specified<br>"); Response.Write(" From Year: " + startYear + "<br>"); Response.Write(" From Month: " + startMonth + "<br>"); Response.Write(" From Day: " + startDay + "<br>"); Response.Write(" To Year: " + endYear + "<br>"); Response.Write(" To Month: " + endMonth + "<br>"); Response.Write(" To Day: " + endDay + "<br>"); } } else { Response.Write("Invalid school ID"); } } else { Response.Write("\"To\" data not valid"); } } else { Response.Write("\"From\" data not valid"); } } else { Response.Write("School ID not specified"); } Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["termid"])) { if (!String.IsNullOrEmpty(Request.QueryString["schoolid"])) { if (!String.IsNullOrEmpty(Request.QueryString["trackid"])) { int termID = -1; int trackID = -1; int schoolID = -1; if (int.TryParse(Request.QueryString["schoolid"], out schoolID)) { if (int.TryParse(Request.QueryString["termid"], out termID)) { if (int.TryParse(Request.QueryString["trackid"], out trackID)) { using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { // Load school School selectedSchool = School.loadThisSchool(connection, schoolID); if (selectedSchool != null) { // Load term Term selectedTerm = Term.loadThisTerm(connection, termID); // Load track if (selectedTerm != null) { Track selectedTrack = Track.loadThisTrack(connection, trackID); // Load students if (selectedTrack != null) { List <Student> selectedStudents = Student.loadStudentsFromThisTrack(connection, selectedTrack.ID); // Load timetable data List <SchoolDay> schoolDays = SchoolDay.loadDaysFromThisTrack(connection, selectedTrack); foreach (Student student in selectedStudents) { student.TimeTable = TimeTableEntry.loadStudentTimeTable(connection, student, selectedTerm); } string filename = "FirstClassOfDay_" + LSKYCommon.removeSpaces(selectedSchool.getName()) + "_" + LSKYCommon.removeSpaces(selectedTerm.name); sendCSV(GenerateCSV(selectedStudents, schoolDays), filename); } else { DisplayError("Track not found"); } } else { DisplayError("Term not found"); } } else { DisplayError("School not found"); } } } else { DisplayError("Invalid track"); } } else { DisplayError("Invalid term"); } } else { DisplayError("Invalid school"); } } else { DisplayError("Track must be specified"); } } else { DisplayError("School must be specified"); } } else { DisplayError("Term must be specified"); } }
protected void btnReportPeriod_Click(object sender, EventArgs e) { string selectedGrade = drpGrades.SelectedValue; // Parse the selected school ID int schoolID = -1; if (int.TryParse(drpSchools.SelectedValue, out schoolID)) { School selectedSchool = null; using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { // Load the school selectedSchool = School.loadThisSchool(connection, schoolID); if (selectedSchool != null) { // Load all students List <Student> schoolStudents = new List <Student>(); schoolStudents = Student.loadStudentsFromThisSchool(connection, schoolID); // Filter out the ones for that grade List <Student> selectedStudents = new List <Student>(); foreach (Student student in schoolStudents) { if (student != null) { if (student.getGrade() == selectedGrade) { selectedStudents.Add(student); } } } // Load checked report periods List <int> selectedReportPeriodIDs = new List <int>(); List <ReportPeriod> selectedReportPeriods = new List <ReportPeriod>(); foreach (ListItem item in chkReportPeriods.Items) { if (item.Selected) { int parsedValue = -1; if (int.TryParse(item.Value, out parsedValue)) { if (!selectedReportPeriodIDs.Contains(parsedValue)) { selectedReportPeriodIDs.Add(parsedValue); } } } } foreach (int reportPeriodID in selectedReportPeriodIDs) { ReportPeriod loadedReportPeriod = ReportPeriod.loadThisReportPeriod(connection, reportPeriodID); if (loadedReportPeriod != null) { selectedReportPeriods.Add(loadedReportPeriod); } } // Load student mark data List <Student> studentsWithMarks = new List <Student>(); foreach (Student student in selectedStudents) { studentsWithMarks.Add(LSKYCommon.loadStudentMarkData(connection, student, selectedReportPeriods)); } // Sort students List <Student> reportcardStudents = new List <Student>(); if (chkSortByHomeRoom.Checked) { reportcardStudents = studentsWithMarks.OrderBy(c => c.getHomeRoom()).ThenBy(c => c.getLastName()).ToList <Student>(); } else { reportcardStudents = studentsWithMarks.OrderBy(c => c.getLastName()).ToList <Student>(); } // Options bool doubleSidedMode = false; if (chkDoubleSidedMode.Checked) { doubleSidedMode = true; } bool anonymize = false; if (chkAnonymize.Checked) { anonymize = true; } bool showPhotos = false; if (chkShowPhotos.Checked) { showPhotos = true; } bool showClassAttendance = false; if (chkClassAttendance.Checked) { showClassAttendance = true; } bool showLegends = true; bool showAttendanceSummary = false; if (chkShowAttendanceSummary.Checked) { showAttendanceSummary = true; } string adminComment = txtAdminComment.Text; // Send the report card String fileName = "ReportCards_" + LSKYCommon.removeSpaces(selectedSchool.getName()) + "_Grade" + selectedGrade + "_" + DateTime.Today.Year + "_" + DateTime.Today.Month + "_" + DateTime.Today.Day + ".pdf"; if ((selectedReportPeriods.Count > 0) && (reportcardStudents.Count > 0)) { sendPDF(PDFReportCardParts.GeneratePDF(reportcardStudents, selectedReportPeriods, anonymize, showPhotos, doubleSidedMode, showClassAttendance, showLegends, showAttendanceSummary, adminComment), fileName); } } } } }
protected void Page_Load(object sender, EventArgs e) { String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; /* Get school ID from query string */ if (!String.IsNullOrEmpty(Request.QueryString["schoolid"])) { int SelectedSchoolID = -1; if (int.TryParse(Request.QueryString["schoolid"], out SelectedSchoolID)) { using (SqlConnection connection = new SqlConnection(dbConnectionString)) { School selectedSchool = School.loadThisSchool(connection, SelectedSchoolID); if (selectedSchool != null) { /* Load students */ List <Student> displayedStudents = new List <Student>(); displayedStudents = Student.loadStudentsFromThisSchool(connection, int.Parse(selectedSchool.getGovIDAsString())); /* Create the CSV */ if (displayedStudents.Count > 0) { sendCSV(GenerateCSV(displayedStudents), "STUDENTS_" + LSKYCommon.removeSpaces(selectedSchool.getName()) + "_" + LSKYCommon.getCurrentTimeStampForFilename()); } else { displayError("No students were found at this school"); } } else { displayError("Invalid school ID"); } } } else { displayError("Invalid school ID"); } } else { displayError("SchoolID is required"); } }