Пример #1
0
        public void ManageFaculty_Create(object sender, EventArgs args)
        {
            //Return if invalid input
            if (string.IsNullOrEmpty(tbNewFaculty.Text))
            {
                MessageBox.Show("Please check your new faculty name.");
                return;
            }

            //Create new faculty
            Faculty faculty = new Faculty();

            faculty.CreatedBy    = GlobalApplication.cMyUser.User_ID;
            faculty.ModifiedBy   = faculty.CreatedBy;
            faculty.Faculty_Name = tbNewFaculty.Text;
            //Apply to db
            faculty = FacultyManager.Create(faculty);
            //If failed
            if (faculty == null)
            {
                MessageBox.Show("Failed to create new faculty.");
                return;
            }

            //Reset new faculty name input
            tbNewFaculty.Text = null;

            //Reload data grid view
            ReloadGridView();

            //Show message
            MessageBox.Show("Successfully created new faculty: " + faculty.Faculty_Name);
        }
Пример #2
0
        public void PopulateGridView()
        {
            //Get all faculties
            lcFaculties = FacultyManager.GetAll();

            //Add column
            dgvFaculties.Columns.Add("FacultyID", "Faculty ID");
            dgvFaculties.Columns.Add("FacultyName", "Faculty name");
            dgvFaculties.ToggleColumnSort(false);

            //Add rows
            for (int i = 0; i < lcFaculties.Count; i++)
            {
                dgvFaculties.Rows.Add(lcFaculties[i].Faculty_ID, lcFaculties[i].Faculty_Name);
            }

            //Refresh grid view
            dgvFaculties.Refresh();
        }
Пример #3
0
        public void FillFaculty()
        {
            //Clear all items
            lcFaculties = null;
            cbFaculty.Items.Clear();

            //Get list of all faculties
            lcFaculties = FacultyManager.GetAll();

            //Fill items
            for (int i = 0; i < lcFaculties.Count; i++)
            {
                cbFaculty.Items.Add(lcFaculties[i].Faculty_Name);

                //Select initial item
                if (lcFaculties[i].Faculty_ID.Equals(cSelectedCourse.Faculty_ID))
                {
                    cbFaculty.SelectedIndex = i;
                }
            }

            cbFaculty.Refresh();
        }
Пример #4
0
        public void FillFaculty()
        {
            //Clear all items
            lcFaculties = null;
            cbFaculty.Items.Clear();

            //Get list of all faculties
            lcFaculties = FacultyManager.GetAll();

            //Only if there are any faculties
            if (lcFaculties.Count > 0)
            {
                //Fill items
                for (int i = 0; i < lcFaculties.Count; i++)
                {
                    cbFaculty.Items.Add(lcFaculties[i].Faculty_Name);
                }

                //Select the first item
                cbFaculty.SelectedIndex = 0;
            }

            cbFaculty.Refresh();
        }