예제 #1
0
        /*
         * NAME
         *
         *       Conference_Form::Refresh_Notes - refreshes the notes window.
         *
         * DESCRIPTION
         *
         *      This function refreshes the notes window by clearing it, and then reloading from the database.
         */
        private void Refresh_Notes()
        {
            notes.Items.Clear();
            List <Note> student_notes = Database_Interface.Query_Note(current_student_id);

            //Display in listview
            foreach (Note n in student_notes)
            {
                ListViewItem item = new ListViewItem(new string[] { Convert.ToString(n.id), Convert.ToString(n.student_id), n.date, n.note, n.category });
                notes.Items.Add(item);
            }
        }
예제 #2
0
        /*
         *   NAME
         *
         *        IO::Students_To_File - Exports students to individual files
         *
         *   SYNOPSIS
         *
         *        void Students_To_File (List<Student> students);
         *
         *             students       --> a list of student objects to be exported.
         *
         *   DESCRIPTION
         *
         *        This function takes each student and saves their data to a unique file.
         */
        //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-write-to-a-text-file
        public static void Students_To_File(List <Student> students)
        {
            try
            {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\HomeroomHelper\";
                foreach (Student s in students)
                {
                    string filename = path + s.FirstName + s.LastName + Generate_File_Date() + ".csv";

                    string line = "";
                    line += s.ID + ",";
                    line += s.FirstName + ",";
                    line += s.LastName + ",";
                    line += s.StartLevel + ",";
                    line += s.CurrentLevel + ",";
                    line += s.GoalLevel + Environment.NewLine;

                    System.IO.File.WriteAllText(filename, line);

                    List <Note> notes = Database_Interface.Query_Note(s.ID);
                    foreach (Note n in notes)
                    {
                        string note_line = "note,";
                        note_line += n.id + ",";
                        note_line += n.student_id + ",";
                        note_line += n.date + ",";
                        note_line += n.note + ",";
                        note_line += n.category + Environment.NewLine;

                        System.IO.File.AppendAllText(filename, note_line);
                    }

                    List <History_Entry> entries = Database_Interface.Query_History_Entries(s.ID);
                    foreach (History_Entry h in entries)
                    {
                        string entry_line = "entry,";
                        entry_line += h.id + ",";
                        entry_line += h.student_id + ",";
                        entry_line += h.date + ",";
                        entry_line += h.current_lvl + Environment.NewLine;

                        System.IO.File.AppendAllText(filename, entry_line);
                    }
                }
            }
            catch (Exception e)
            {
                new Log(e, "IO.cs: Students_To_File", "Failed to save student data to file.");
            }
        }