Exemplo n.º 1
0
        private void B_Search_Click(object sender, EventArgs e)
        {
            // Method that initiates the search for students
            StudentAccessLayer SAL = new StudentAccessLayer(Session.Database);

            _searchResults = new List <Student>();
            try
            {
                switch (CB_SearchBy.SelectedIndex)
                {
                case 1:
                    _searchResults = SAL.GetStudentByForename(TB_StudentSearch.Text);
                    break;

                case 2:
                    _searchResults = SAL.GetStudentBySurname(TB_StudentSearch.Text);
                    break;

                default:
                    _searchResults.Add(SAL.GetStudentById(Convert.ToInt32(TB_StudentSearch.Text)));
                    break;
                }
            }
            catch (ValidationException vEx)
            {
                MessageBox.Show("Record not loaded.  There was an error with the student record: " + vEx.Message);
            }
            PopulateDT(_searchResults);
        }
Exemplo n.º 2
0
 private void B_EditStudent_Click(object sender, EventArgs e)
 {
     if (DGV_Students.SelectedRows.Count == 1)
     {
         StudentAccessLayer SAL = new StudentAccessLayer(Session.Database);
         F_StudentRegister  RS  = new F_StudentRegister(SAL.GetStudentById(Convert.ToInt32(DGV_Students.SelectedRows[0].Cells[0].Value.ToString())));
         RS.Show();  // Register form doubles up as edit form
     }
     else
     {
         MessageBox.Show("You have selected more than 1 or 0 students.");
     }
 }
Exemplo n.º 3
0
        // Buttons

        private void B_EnrolStudent_Click(object sender, EventArgs e)
        {
            // Makes sure that only one student is selected
            if (DGV_Students.SelectedRows.Count == 1)
            {
                StudentAccessLayer SAL = new StudentAccessLayer(Session.Database);
                F_Enrolment        ES  = new F_Enrolment(SAL.GetStudentById(Convert.ToInt32(DGV_Students.SelectedRows[0].Cells[0].Value.ToString())));
                ES.Show();  // Opening enrolment form
            }
            else
            {
                MessageBox.Show("You have selected more than 1 or less than 1 students.");
            }
        }
Exemplo n.º 4
0
        private void B_DeleteStudent_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure you want to delete this student?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                StudentAccessLayer SAL = new StudentAccessLayer(Session.Database);
                if (SAL.DeleteStudent(SAL.GetStudentById(Convert.ToInt32(DGV_Students.SelectedRows[0].Cells[0].Value.ToString()))))
                {
                    MessageBox.Show("Student deleted successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _dt.Rows.Clear();
                }
                else
                {
                    MessageBox.Show("Could not delete student.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void B_Search_Click(object sender, EventArgs e)
        {
            // Method that initiates the search for students
            StudentAccessLayer SAL = new StudentAccessLayer(Session.Database);

            _searchResults = new List <Student>();
            switch (CB_SearchBy.SelectedIndex)
            {
            case 1:
                _searchResults = SAL.GetStudentByForename(TB_StudentSearch.Text);
                break;

            case 2:
                _searchResults = SAL.GetStudentBySurname(TB_StudentSearch.Text);
                break;

            default:
                _searchResults.Add(SAL.GetStudentById(Convert.ToInt32(TB_StudentSearch.Text)));
                break;
            }
            PopulateDT(_searchResults);
        }