Esempio n. 1
0
        public static void AddSuper(string add_supervisor)
        {
            List <SomerenModel.Supervisor> supervisors = new List <SomerenModel.Supervisor>();

            // to get data from DataBase
            supervisors = SomerenDB.DB_getSupervisors();
            List <string> supervisorsStrings = new List <string>();

            foreach (SomerenModel.Supervisor supervisor in supervisors)
            {
                supervisorsStrings.Add(supervisor.getLastName().ToLower());
            }

            // validation if the teacher is a supervisor
            if (supervisorsStrings.Contains(add_supervisor.ToLower()))
            {
                // show a message
                MessageBox.Show("This teacher is already a supervisor! Choose another one!",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                SomerenDB.DB_AddSupervisor(add_supervisor);
            }
        }
Esempio n. 2
0
        public static Control showListSupervisors()
        {
            List <SomerenModel.Supervisor> supervisors = new List <SomerenModel.Supervisor>();

            // to get data from DataBase
            supervisors = SomerenDB.DB_getSupervisors();

            // Making a list and editing its format

            ListView supervisorListView = new ListView();

            supervisorListView.Height        = 370;
            supervisorListView.Width         = 370;
            supervisorListView.View          = View.Details;
            supervisorListView.FullRowSelect = true;

            // adding colums to the list
            supervisorListView.Columns.Add("First Name", -2, HorizontalAlignment.Left);
            supervisorListView.Columns.Add("Last Name", -2, HorizontalAlignment.Left);


            // storing data into the list
            foreach (SomerenModel.Supervisor record in supervisors)
            {
                ListViewItem entryListItem = supervisorListView.Items.Add(record.getFirstName().ToString());
                entryListItem.SubItems.Add(record.getLastName().ToString());
            }

            return(supervisorListView);
        }