private void EditDelCoursesMnBtn_Click(object sender, EventArgs e)
 {
     UserGroupBox.Hide();
     AssignMsgLabel.Hide();
     AssignCourseBtn.Hide();
     CancelUsersBtn.Hide();
     CancelCoursesBtn.Hide();
     ClearBoxes();
     UsersList.Enabled        = true;
     CoursesList.Enabled      = true;
     CreateEditCourseBtn.Text = "Submit";
     UsersList.Show();
     CoursesList.Show();
     CourseGroupBox.Show();
     ChangeMsgLabel("Edit", "Courses");
     this.CourseGroupBox.Location = new Point(410, 12);
     this.UsersList.Location      = new Point(635, 12);
 }
        //On click on every menu button, objects that are not needed are being hidden, text boxes are being cleared
        //and the lists are being enabled. The regnumbo on edit must be disable so that the admin cannot create or
        //replace(by accident or not) a user from there

        private void CreateCourseMenuBtn_Click(object sender, EventArgs e)
        {
            UserGroupBox.Hide();
            CoursesList.Hide();
            AssignMsgLabel.Hide();
            AssignCourseBtn.Hide();
            CancelUsersBtn.Hide();
            CancelCoursesBtn.Hide();
            ClearBoxes();
            UsersList.Enabled        = true;
            CoursesList.Enabled      = true;
            CreateEditCourseBtn.Text = "Create";
            ChangeMsgLabel("Create", "Courses");
            UsersList.Show();
            CourseGroupBox.Show();
            this.CourseGroupBox.Location = new Point(550, 12);
            this.UsersList.Location      = new Point(150, 12);
        }
 private void EditDelUsersMnBtn_Click(object sender, EventArgs e)
 {
     CourseGroupBox.Hide();
     CoursesList.Hide();
     PassBox.Hide();
     PassLabel.Hide();
     AssignMsgLabel.Hide();
     AssignCourseBtn.Hide();
     HideAllErrors();
     CancelUsersBtn.Hide();
     CancelCoursesBtn.Hide();
     ClearBoxes();
     UsersList.Enabled   = true;
     CoursesList.Enabled = true;
     RegNumBox.Enabled   = false;
     UserGroupBox.Show();
     UsersList.Show();
     this.UserGroupBox.Location = new Point(550, 12);
     this.UsersList.Location    = new Point(150, 12);
     ChangeMsgLabel("Edit", "Users");
     CreateEditUserBtn.Text = "Submit";
 }
        private void CreateUserMenuBtn_Click(object sender, EventArgs e)
        {
            CourseGroupBox.Hide();
            UsersList.Hide();
            CoursesList.Hide();
            AssignMsgLabel.Hide();
            AssignCourseBtn.Hide();
            CancelUsersBtn.Hide();
            CancelCoursesBtn.Hide();
            HideAllErrors();
            ChangeMsgLabel("Create", "Users");
            ClearBoxes();

            UsersList.Enabled   = true;
            CoursesList.Enabled = true;
            RegNumBox.Enabled   = true;
            PassBox.Show();
            PassLabel.Show();
            UserGroupBox.Show();
            UserGroupBox.Left = (this.ClientSize.Width - UserGroupBox.Width + 100) / 2;
            UserGroupBox.Top  = (this.ClientSize.Height - UserGroupBox.Height - 100) / 2;

            CreateEditUserBtn.Text = "Create";
        }
        public AdminForm()
        {
            InitializeComponent();

            UserGroupBox.Controls.Add(NameBox);
            UserGroupBox.Controls.Add(RegNumBox);
            UserGroupBox.Controls.Add(SurnameBox);
            UserGroupBox.Controls.Add(PassBox);
            UserGroupBox.Controls.Add(EmailBox);
            UserGroupBox.Controls.Add(CapacityBox);
            UserGroupBox.Controls.Add(CreateEditUserBtn);
            UserGroupBox.Controls.Add(NameLabel);
            UserGroupBox.Controls.Add(RegNumLabel);
            UserGroupBox.Controls.Add(SurnameLabel);
            UserGroupBox.Controls.Add(PassLabel);
            UserGroupBox.Controls.Add(EmailLabel);
            UserGroupBox.Controls.Add(CapacityLabel);



            //Creating the UsersList
            UsersList.Bounds        = new Rectangle(new Point(196, 12), new Size(375, 500));
            UsersList.View          = View.Details;
            UsersList.FullRowSelect = true;
            UsersList.GridLines     = true;
            UsersList.Sorting       = SortOrder.Ascending;
            UsersList.Columns.Add("Registration Number", -2, HorizontalAlignment.Left);
            UsersList.Columns.Add("Name", -2, HorizontalAlignment.Left);
            UsersList.Columns.Add("Surname", -2, HorizontalAlignment.Left);
            UsersList.Columns.Add("Email", -2, HorizontalAlignment.Left);
            UsersList.Columns.Add("Capacity", -2, HorizontalAlignment.Left);

            //============================================================================



            LocalUsersDatabase.Add("kp0000");
            LocalUsersDatabase.Add("Mike");
            LocalUsersDatabase.Add("Kalliafas");
            LocalUsersDatabase.Add("*****@*****.**");
            LocalUsersDatabase.Add("Professor");

            LocalUsersDatabase.Add("p50000");
            LocalUsersDatabase.Add("Alberto");
            LocalUsersDatabase.Add("Makavegias");
            LocalUsersDatabase.Add("*****@*****.**");
            LocalUsersDatabase.Add("Student");

            LocalCoursesDatabase.Add("Algebra");
            LocalCoursesDatabase.Add("Professor 1");
            LocalCoursesDatabase.Add("Physics");
            LocalCoursesDatabase.Add("Professor 2");



            //Users Right Click menu creation
            ToolStripMenuItem UsersRightClickMenuEdit   = new ToolStripMenuItem("Edit");
            ToolStripMenuItem UsersRightClickMenuDelete = new ToolStripMenuItem("Delete");

            UsersRightClickMenuDelete.Click += new EventHandler(UserDelete_RightClick);
            UsersRightClickMenuEdit.Click   += new EventHandler(UserEdit_RightClick);
            UsersRightClickMenu.Items.AddRange(new ToolStripItem[] { UsersRightClickMenuEdit, UsersRightClickMenuDelete });

            //===================================================================================


            //Courses Right Click menu creation
            ToolStripMenuItem CoursesRightClickMenuEdit   = new ToolStripMenuItem("Edit");
            ToolStripMenuItem CoursesRightClickMenuDelete = new ToolStripMenuItem("Delete");

            CoursesRightClickMenuDelete.Click += new EventHandler(CoursesDelete_RightClick);
            CoursesRightClickMenuEdit.Click   += new EventHandler(CoursesEdit_RightClick);
            CoursesRightClickMenu.Items.AddRange(new ToolStripItem[] { CoursesRightClickMenuEdit, CoursesRightClickMenuDelete });
            //===================================================================================



            //Creating the CoursesList
            CoursesList.Bounds        = new Rectangle(new Point(150, 12), new Size(250, 500));
            CoursesList.View          = View.Details;
            CoursesList.FullRowSelect = true;
            CoursesList.GridLines     = true;
            CoursesList.Sorting       = SortOrder.Ascending;
            CoursesList.Columns.Add("Courses", -2, HorizontalAlignment.Left);
            CoursesList.Columns.Add("Professor", -2, HorizontalAlignment.Left);
            //=============================================================================



            ChangeMsgLabel("Create", "Users");

            CourseGroupBox.Text = "";
            UserGroupBox.Text   = "";

            CoursesList.Hide();
            UsersList.Hide();
            CourseGroupBox.Hide();
            CourseTitleErrorLabel.Hide();
            AssignMsgLabel.Hide();
            AssignCourseBtn.Hide();
            RegMsgLabel.Hide();
            NameMsgLabel.Hide();
            SurnameMsgLabel.Hide();
            EmailMsgLabel.Hide();
            PassMsgLabel.Hide();
            CapacityMsgLabel.Hide();
            CancelCoursesBtn.Hide();
            RegNumErrorLabel.Hide();
            NameErrorLabel.Hide();
            SurnameErrorLabel.Hide();
            EmailErrorLabel.Hide();
            PassErrorLabel.Hide();
            CapacityErrorLabel.Hide();
            CancelUsersBtn.Hide();

            RegNumErrorLabel.SendToBack();
            NameErrorLabel.SendToBack();
            SurnameErrorLabel.SendToBack();
            EmailErrorLabel.SendToBack();
            PassErrorLabel.SendToBack();
            CapacityErrorLabel.SendToBack();



            UserGroupBox.Left = (this.ClientSize.Width - UserGroupBox.Width + 100) / 2;
            UserGroupBox.Top  = (this.ClientSize.Height - UserGroupBox.Height - 100) / 2;

            UpdateList("Users");
            UpdateList("Courses");
        }