Пример #1
0
        private void buttonSignIn_Click(object sender, EventArgs e)
        {
            //Presence check
            if(textBoxStudentID.Text.Length>0 & textBoxStudentName.Text.Length>0)
            {
                Student student = Student.Get(int.Parse(textBoxStudentID.Text));
                if (student == null)
                {
                    //Creates a new student
                    student = new Student();
                    student.StudentID = int.Parse(textBoxStudentID.Text);
                    student.StudentName = textBoxStudentName.Text;
                    //Pass the student
                }else
                {
                    student.StudentName = textBoxStudentName.Text;

                }
                Console.WriteLine("CName: "+student.CourseName);

                MainForm mainForm = new MainForm(student);
                mainForm.LoadModules(LevelType.Level4);
                mainForm.LoadModules(LevelType.Level5);
                mainForm.LoadModules(LevelType.Level6);
                mainForm.Show();

                this.Hide();
            }
        }
Пример #2
0
        public RegisterCourse(Student student,Label cname)
        {
            InitializeComponent();

            this.student = student;
            this.labelCName = cname;
        }
Пример #3
0
        /// <summary>
        /// To create a new module
        /// </summary>
        /// <param name="student"></param>
        /// <param name="level"></param>
        /// <param name="mainform"></param>
        public ModuleForm(Student student, LevelType level, MainForm mainform)
        {
            InitializeComponent();

            this.student = student;
            this.level = level;
            this.mainform = mainform;
        }
Пример #4
0
        public MainForm(Student student)
        {
            InitializeComponent();

            this.student = student;
            for (int i = 4; i < 7; i++)
            {
                int index = dataGridView4.Rows.Add(1);
                dataGridView4.Rows[index].Cells[0].Value = "Level " + i;
            }
            int graderow = dataGridView4.Rows.Add(1);
            dataGridView4.Rows[graderow].Cells[0].Value = "Final Grade";

            labelCName.Text = student.CourseName+"";
        }
Пример #5
0
        /// <summary>
        /// Get a student
        /// </summary>
        /// <param name="studentID">Student ID</param>
        /// <returns></returns>
        public static Student Get(int studentID)
        {
            Student student = null;

            string sql = "SELECT * FROM " + Student.TABLE + " WHERE " + Student.STUDENT_ID + "=" + studentID;

            SQLiteDataReader reader = DBConnection.Get(sql);

            #region Creates the Student
            if (reader.Read())
            {
                student = new Student();
                student.StudentID = int.Parse(reader[0].ToString());
                student.StudentName = reader[1].ToString();
                student.CourseName = reader[2].ToString();

                //Assign modules recorded for each level
                foreach (Level level in student.Levels)
                {
                    level.Modules = Module.Get(student.StudentID, level.Name);
                }
            }
            #endregion

            return student;
        }
Пример #6
0
        /// <summary>
        /// Add a new student
        /// </summary>
        /// <param name="student">Student instance</param>
        public static void Set(Student student)
        {
            if (Get(student.StudentID) == null)
            {
                string sql = "INSERT INTO " + Student.TABLE + " VALUES (" + student.StudentID + ",'" + student.StudentName + "','" + student.CourseName + "')";

                DBConnection.Set(sql);
            }

            //Delete all the modules of the student
            Module.Delete(student.StudentID);

            //Go through each level
            foreach (Level level in student.Levels)
            {
                //Insert all the modules in each level
                foreach (Module module in level.Modules)
                {
                    Module.Set(module, student.StudentID, level.Name);
                }
            }
        }