Example #1
0
        //upadte student placements
        public static void WriteUpdateStatements(int year)
        {
            Dictionary <int, String[]> placements = Placements.GetPlacements();
            Dictionary <int, Student>  report     = StudentReader.GetStudentReportList();
            List <Student>             students   = (from student in report where student.Value.Grade == year select student.Value).ToList();

            String eng  = "";
            String hist = "";
            String sci  = "";

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\sqlUpdate.txt"))
            {
                foreach (var student in students)
                {
                    if (placements.ContainsKey(student.ID))
                    {
                        hist = placements[student.ID][0];
                        sci  = placements[student.ID][2];
                        eng  = placements[student.ID][1];
                    }


                    file.WriteLine(String.Format("UPDATE registration SET english='{0}',science='{1}',history='{2}' WHERE id={3};", eng, sci, hist, student.ID));
                }
            }
        }
Example #2
0
        public static void PrintScheduleToExcel()
        {
            Array.Sort(CourseHandler.ElectiveChoices);
            object misValue = System.Reflection.Missing.Value;

            // Specify a "currently active folder"
            string activeDir = @"c:\";

            //Create a newPath - the Path to Excel file

            string newFileName = "schedule.xlsx";
            string newPath     = System.IO.Path.Combine(activeDir, newFileName);

            Microsoft.Office.Interop.Excel.Application xlApp      = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook    xlWorkBook = xlApp.Workbooks.Open(newPath, 0, true, 5, "", "", true,
                                                                                         Microsoft.Office.Interop.Excel.
                                                                                         XlPlatform.xlWindows, "\t", false,
                                                                                         false, 0, true, 1, 0);

            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet =
                (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            Dictionary <int, Student> report = StudentReader.GetStudentReportList();



            //WRITES ALL CLASSES AND STUDENTS FOR EACH PERIOD TO A SEPARATE SHEET
            for (int i = 1; i <= 6; i++)
            {
                WritePeriodGrades((Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(i), i,
                                  report);
            }


            //   xlWorkBook.Worksheets.Add();
            Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(7); //get the 7th sheet

            sheet.Name = "Tally";
            //print course counts
            int row = 1;

            foreach (KeyValuePair <String, int> c in courseCounts)
            {
                sheet.Cells[row, 1]   = c.Key.ToString();
                sheet.Cells[row++, 2] = c.Value.ToString();
            }

            // if (File.Exists("c:\\schedule.xlsx")) File.Delete("c:\\schedule.xlsx");
            // xlWorkBook.SaveAs("c:\\schedule.xlsx", XlFileFormat.xlWorkbookDefault, misValue, misValue, true, false, XlSaveAsAccessMode.xlExclusive, XlSaveConflictResolution.xlLocalSessionChanges, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);

            xlApp.Workbooks.Close();
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }
Example #3
0
        public static void WriteCurrentCourseAndPlacement(Dictionary <int, Student> studentPlacements)
        {
            Dictionary <int, Student> currentPlacements = StudentReader.GetStudentReportList();

            Dictionary <CourseHandler.COURSENAME, List <Student> > courses = new Dictionary <CourseHandler.COURSENAME, List <Student> >();
            List <int> notShceduled = new List <int>();

            foreach (KeyValuePair <int, Student> entry in currentPlacements)
            {
                foreach (Class_ c in entry.Value.classes)
                {
                    if (c != null && c.GetCourse() != CourseHandler.COURSENAME.None && c.GetType() == typeof(Science))
                    {
                        if (!courses.ContainsKey(c.course))
                        {
                            courses[c.course] = new List <Student>();
                        }

                        try
                        {
                            courses[c.course].Add(studentPlacements[entry.Key]);
                        }
                        catch (KeyNotFoundException exception)
                        {
                            notShceduled.Add(entry.Key);
                        }
                    }
                }
            }

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\courses.txt"))
            {
                foreach (var course in courses)
                {
                    file.WriteLine(course.Key.ToString());

                    foreach (Student s in course.Value)
                    {
                        foreach (Class_ c in s.classes)
                        {
                            if (c != null && c.GetCourse() != CourseHandler.COURSENAME.None && c.GetType() == typeof(Science))
                            {
                                file.WriteLine(String.Format("{0}, {1} {2} - {3}: {4}", s.LastName, s.FirstName, s.Grade, s.ID, c.GetCourse().ToString()));
                            }
                        }
                    }
                    file.WriteLine();
                }

                foreach (var i in notShceduled)
                {
                    if (currentPlacements[i].Grade < 12)
                    {
                        file.WriteLine(String.Format("{0} - {1}, {2}", currentPlacements[i].ID, currentPlacements[i].LastName, currentPlacements[i].FirstName));
                    }
                }
            }
        }
Example #4
0
        public static void WriteSqlStatements() //create sql update statements for all placements
        {
            Dictionary <int, Student>  report     = StudentReader.GetStudentReportList();
            Dictionary <int, String[]> placements = Placements.GetPlacements();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\sqlStatements.txt"))
            {
                file.WriteLine("INSERT INTO registration (id,math,glang,history,science,english) VALUES");

                String math = "";
                String lang = "";
                String eng  = "";
                String hist = "";
                String sci  = "";

                for (int grade = 7; grade < 12; grade++)
                {
                    List <Student> students =
                        (from student in report where student.Value.Grade == grade select student.Value).ToList();


                    foreach (var student in students)
                    {
                        if (student.classes[0] != null) //math
                        {
                            math = student.GetMathPlacement(grade);
                        }

                        if (student.classes[1] != null) //foreign lang
                        {
                            lang = student.GetForeignLangPlacement(grade);
                        }

                        if (placements.ContainsKey(student.ID))
                        {
                            hist = placements[student.ID][0];
                            sci  = placements[student.ID][2];
                            eng  = placements[student.ID][1];
                        }



                        file.WriteLine(String.Format("({0},'{1}', '{2}','{3}','{4}','{5}'),", student.ID, math, lang, hist, sci, eng));
                        //   file.WriteLine(String.Format("({0}, {1} - {2}th math: {3} lang: {4}),", student.LastName,student.FirstName, student.Grade, math, lang));
                    }
                }
                file.Write(";");
            }
        }