Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            var          ds          = new DataStore();
            ProgramIndex programData = ds.LoadData();

            StudentsListView = programData.FindAllStudents();

            this.StudentListView.Items.Clear();
            this.StudentListView.View = View.Details;
            this.StudentListView.Columns.Add("Name");
            this.StudentListView.Columns[0].Width = this.StudentListView.Width -
                                                    4;
            this.StudentListView.HeaderStyle = ColumnHeaderStyle.None;
            List <string> StudentList = StudentsListView.ListViewStudentNames;

            foreach (string sStudent in StudentList)
            {
                StudentListView.Items.Add(sStudent);
            }
            this.CoursesListView.Items.Clear();
            this.CoursesListView.View = View.Details;
            this.CoursesListView.Columns.Add("Name");
            this.CoursesListView.Columns[0].Width = this.StudentListView.Width -
                                                    4;
            this.CoursesListView.HeaderStyle = ColumnHeaderStyle.None;
        }
Esempio n. 2
0
        public override byte[] ToBytes()
        {
            // 1. (1 byte)      - is: const (0), var (1) or instruction (2)
            // 2. (3 bytes)     - Instruction number
            // 3. (3 bytes)     - Instrcution index
            // 3. (3 * n byte)	- Arguments: 1st byte - (1) or (2): constant or variable
            //					- 2st and 3d bytes: index of constant of variable
            List <byte> bytes = new List <byte>();

            bytes.Add(Element_Instruction);                             //Its a instrucion
            bytes.AddRange(InstructionNumber.ToBytes());                //Instrucion number
            if (Parameters == null)
            {
                return(bytes.ToArray());
            }

            bytes.AddRange(ProgramIndex.ToBytes());                     //Instrucion index

            foreach (var item in Parameters)
            {
                bytes.Add(item.Type == ReferenceType.Constant ? Parameter_Const : Parameter_Var); //Const or variable
                bytes.AddRange(item.Index.ToBytes());                                             //Index of argument
            }

            return(bytes.ToArray());
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the data currently in XMLtestfile.xml into a new <see cref="ProgramIndex"/> object, and
        /// returns it.
        /// </summary>
        /// <returns>Returns a new <see cref="ProgramIndex"/> object with all of the data from XMLtestfile.xml prepopulated.</returns>
        public ProgramIndex LoadData()
        {
            var          stream = File.OpenRead("XMLtestfile.xml");
            ProgramIndex data   = (ProgramIndex)dataContractSerializer.ReadObject(stream);

            stream.Close();
            return(data);
        }
Esempio n. 4
0
        public Form1()
        {
            InitializeComponent();
            var ds = new DataStore();

            programData = ds.LoadData();

            this.StudentsListBox.DataSource = programData.Students;
            this.CoursesListBox.DataSource  = new CourseGrade[0];
        }
 public ProgramIndexApiJson(ProgramIndex programIndex)
 {
     ProgramIndexID    = programIndex.ProgramIndexID;
     ProgramIndexCode  = programIndex.ProgramIndexCode;
     ProgramIndexTitle = programIndex.ProgramIndexTitle;
     Biennium          = programIndex.Biennium;
     Activity          = programIndex.Activity;
     Program           = programIndex.Program;
     Subprogram        = programIndex.Subprogram;
     Subactivity       = programIndex.Subactivity;
 }
Esempio n. 6
0
 public void Print(string fileName, ProgramIndex programData)
 {
     using (var stream = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
     {
         using (var document = new Document())
         {
             var writer = PdfWriter.GetInstance(document, stream);
             document.Open();
             var numberOfChapters = 0;
             foreach (var student in programData.Students)
             {
                 var c = new Chapter($"{student.LastName}, {student.FirstName} {student.StudentID}",
                                     numberOfChapters++);
                 var t = new PdfPTable(8)
                 {
                     HeaderRows = 1
                 };
                 t.AddCell("Course Name");
                 t.AddCell("Course ID");
                 t.AddCell("Course Number");
                 t.AddCell("Credit");
                 t.AddCell("Semester");
                 t.AddCell("Year");
                 t.AddCell("Course Type");
                 t.AddCell("Grade");
                 var courses = programData.FindCoursesForStudent(student);
                 foreach (var course in courses)
                 {
                     t.AddCell(course.Course.CourseName);
                     t.AddCell(course.Course.CourseID.ToString());
                     t.AddCell(course.Course.CourseNumber);
                     t.AddCell(course.Course.Credit.ToString());
                     t.AddCell(course.Course.Semester);
                     t.AddCell(course.Course.Year.ToString());
                     t.AddCell(course.Course.CourseType);
                     t.AddCell(course.Grade);
                 }
                 c.Add(t);
                 document.Add(c);
             }
         }
     }
 }
Esempio n. 7
0
        private void CoursesListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((ListView)sender).SelectedItems.Count == 0)
            {
                return;
            }
            var          ds          = new DataStore();
            ProgramIndex programData = ds.LoadData();
            string       result      = ((ListView)sender).SelectedItems[0].ToString().Split(':')[2].Trim(' ', '}');
            Course       c           = programData.FindCourseByID(int.Parse(result));

            CourseID.Text     = courseStringBase[0] + c.CourseID.ToString();
            CourseNumber.Text = courseStringBase[1] + c.CourseNumber;
            Credits.Text      = courseStringBase[3] + c.Credit.ToString();
            Semester.Text     = courseStringBase[4] + c.Semester.ToString();
            Year.Text         = courseStringBase[5] + c.Year.ToString();
            CourseType.Text   = courseStringBase[6] + c.CourseType;
            Grade.Text        = courseStringBase[2] + programData.OutputGrade(StudentListView.SelectedItems[0].Text.Split(';')[0].Trim('{'), int.Parse(result));
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var          ds           = new DataStore();
            ProgramIndex programData  = ds.LoadData();
            var          displayLogic = new DisplayLogic();

            while (true)
            {
                //Console.WriteLine("Please enter a student ID : ");
                string studentID = Console.ReadLine();
                var    student   = programData.FindStudentByID(studentID);
                if (student == null)
                {
                    continue;
                }
                else
                {
                    List <CourseGrade> list = programData.FindCoursesForStudent(student);
                    displayLogic.Display(student, list);
                }
            }
        }
Esempio n. 9
0
        private void StudentListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((ListView)sender).SelectedItems.Count == 0)
            {
                return;
            }
            var          ds          = new DataStore();
            ProgramIndex programData = ds.LoadData();

            CourseList              = programData.ListAllCoursesByStudent(((ListView)sender).SelectedItems[0].Text);
            Completioncheck         = programData.CompletionStatusPerType(((ListView)sender).SelectedItems[0].Text);
            GenEdCompletion.Text    = Completionstringbase[0] + Completioncheck[0] + "%";
            CoreCompletion.Text     = Completionstringbase[1] + Completioncheck[1] + "%";
            ElectiveCompletion.Text = Completionstringbase[2] + Completioncheck[2] + "%";
            CoursesListView.Items.Clear();
            CoursesListView.Items.AddRange(CourseList.Select(i => new ListViewItem(i)).ToArray());
            CourseID.Text     = courseStringBase[0];
            CourseNumber.Text = courseStringBase[1];
            Credits.Text      = courseStringBase[3];
            Semester.Text     = courseStringBase[4];
            Year.Text         = courseStringBase[5];
            CourseType.Text   = courseStringBase[6];
            Grade.Text        = courseStringBase[2];
        }