Beispiel #1
0
        public List <CourseEntity> GetCoursesTeachersStudents() // Method to show all courses with techers & students registered in
        {
            // Strat connection with database & excute the query
            DbConnection dbConnection = new DbConnection("GetCoursesTeachersStudents");

            dbConnection.con.Open();
            dbConnection.cmd.ExecuteNonQuery();
            // Pass dataset to be filled
            dbConnection.FillData(coursesDataset);
            // Create list of courses type to push the result in
            List <CourseEntity> crsList = new List <CourseEntity>();

            foreach (DataRow dr in coursesDataset.Tables[0].Rows)
            {
                // In each iteration push courses, teachers, students to list
                CourseEntity currenEnt = new CourseEntity();
                currenEnt.crsName  = (string)dr[0];
                currenEnt.techName = (string)dr[1].ToString();
                currenEnt.stdName  = (string)dr[2].ToString();
                crsList.Add(currenEnt);
            }

            // Close connection before moving to another query
            dbConnection.con.Close();
            // return the list of students
            return(crsList);
        }
Beispiel #2
0
        public AddTeacher()
        {
            InitializeComponent();
            // Create obj from courseEntity to call FillCourses method
            CourseEntity courseEntity = new CourseEntity();

            // Method to fill courses comboBox once page loaded
            coursesComboBox.DataSource = courseEntity.FillCoursesComboBox();
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            // create object from CourseEntity
            CourseEntity courseEntity = new CourseEntity();

            // Passing course name to the object
            courseEntity.SetCrsByName(txtCrsName.Text);
            // Confirm to user
            MessageBox.Show("Course added successfully!");
        }
Beispiel #4
0
        private void ShowCourses_Load(object sender, EventArgs e)
        {
            // Create object from CourseEntity to access GetCoursesTeacherStduents method
            CourseEntity courseEntity = new CourseEntity();
            // Create list to save the list returend from Get.. methond
            List <CourseEntity> crsList = courseEntity.GetCoursesTeachersStudents();

            // Show the content of course list on DataGridView
            dataGridView2.DataSource = crsList;
        }