Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsUsers(Convert.ToInt32(textBox_ID.Text)) == false)
     {
         SQLFunctions.insertUser(Convert.ToInt32(textBox_ID.Text), textBox_Password.Text, textBox_FirstName.Text, textBox_LastName.Text, comboBox_Permission.Text, comboBox_Department.Text);
         if (comboBox_Permission.SelectedIndex == 0 || comboBox_Permission.SelectedIndex == 1)
         {
             MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as a " + comboBox_Permission.Text + " in " + comboBox_Department.Text + " department.");
         }
         else if (comboBox_Permission.SelectedIndex == 3)
         {
             MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as an " + comboBox_Permission.Text);
         }
         else
         {
             MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as an " + comboBox_Permission.Text + " employee");
         }
         this.Hide();
         FormMenuAdmin adminForm = new FormMenuAdmin();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("Student " + textBox_FirstName.Text + " is already registered in the system");
     }
 }
        private void button_Back_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormMenuAdmin adminForm = new FormMenuAdmin();

            adminForm.Show();
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (SQLFunctions.checkExistsUsers(Convert.ToInt32(textBox_ID.Text)) == false)
            {
                if (!SQLFunctions.checkExistsEmail(textBox_email.Text))
                {
                    if (textBox_email.Text.Contains("@"))
                    {
                        if (comboBox_Permission.Text == "Student Secretary")
                        {
                            SQLFunctions.insertUser(textBox_email.Text, Convert.ToInt32(textBox_ID.Text), textBox_Password.Text, textBox_FirstName.Text, textBox_LastName.Text, "SecretaryA", comboBox_Department.Text);
                        }
                        else if (comboBox_Permission.Text == "Department Secretary")
                        {
                            SQLFunctions.insertUser(textBox_email.Text, Convert.ToInt32(textBox_ID.Text), textBox_Password.Text, textBox_FirstName.Text, textBox_LastName.Text, "Secretary", comboBox_Department.Text);
                        }

                        else
                        {
                            SQLFunctions.insertUser(textBox_email.Text, Convert.ToInt32(textBox_ID.Text), textBox_Password.Text, textBox_FirstName.Text, textBox_LastName.Text, comboBox_Permission.Text, comboBox_Department.Text);
                        }
                        if (comboBox_Permission.SelectedIndex == 3)
                        {
                            MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as an " + comboBox_Permission.Text);
                        }
                        else if (comboBox_Permission.SelectedIndex == 2)
                        {
                            MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as an " + comboBox_Permission.Text + " employee");
                        }
                        else
                        {
                            MessageBox.Show(textBox_LastName.Text + " " + textBox_FirstName.Text + " was added as a " + comboBox_Permission.Text + " in " + comboBox_Department.Text + " department.");
                        }
                        this.Hide();
                        FormMenuAdmin adminForm = new FormMenuAdmin();
                        adminForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Email address");
                    }
                }
                else
                {
                    MessageBox.Show("Email " + textBox_email.Text + " is already registered in the system");
                }
            }
            else
            {
                MessageBox.Show("Student " + textBox_FirstName.Text + " is already registered in the system");
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsClassroom(textBox_ClassName.Text) == false)
     {
         SQLFunctions.addClassroom(textBox_ClassName.Text, Convert.ToInt32(textBox_Capacity.Text));
         MessageBox.Show("class " + textBox_ClassName.Text + " was added with " + textBox_Capacity.Text + " seats.");
         this.Hide();
         FormMenuAdmin adminForm = new FormMenuAdmin();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("class " + textBox_ClassName.Text + " is already exists.");
     }
 }
Exemplo n.º 5
0
 private void button_Accept_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsClassroom(textBox_ClassName.Text) == true)
     {
         SQLFunctions.deleteClassroom(textBox_ClassName.Text);
         MessageBox.Show("Class " + textBox_ClassName.Text + " was deleted!");
         this.Hide();
         FormMenuAdmin adminForm = new FormMenuAdmin();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("Classroom could not be located in the database");
     }
 }
Exemplo n.º 6
0
 private void button_Accept_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsClassroom(listView1.SelectedItems[0].SubItems[0].Text) == true)
     {
         SQLFunctions.deleteClassroom(listView1.SelectedItems[0].SubItems[0].Text);
         MessageBox.Show("Class " + listView1.SelectedItems[0].SubItems[0].Text + " was deleted!");
         this.Hide();
         FormMenuAdmin adminForm = new FormMenuAdmin();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("Classroom was not found");
     }
 }
 private void button_Accept_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsUsers(Convert.ToInt32(listView1.SelectedItems[0].SubItems[0].Text)) == true)
     {
         SQLFunctions.deleteUser(Convert.ToInt32(listView1.SelectedItems[0].SubItems[0].Text));
         MessageBox.Show("User with ID: " + listView1.SelectedItems[0].SubItems[0].Text + " was deleted!");
         this.Hide();
         FormMenuAdmin adminForm = new FormMenuAdmin();
         adminForm.Show();
     }
     else
     {
         MessageBox.Show("User ID could not be located in the database");
     }
 }
Exemplo n.º 8
0
        private void login1()
        {
            if (!link)
            {
                DataRow dataRow = SQLFunctions.checkFbLogIn(fbMail);

                if (dataRow == null)
                {
                    MessageBox.Show("This facebook account is not linked to any system user\nPlease link your Facebook account and try again");
                    B_8.login login = new B_8.login();
                    login.Show();
                }
                else if (SQLFunctions.checkLogIn(Convert.ToInt32(dataRow[0]), dataRow[1].ToString()))
                {
                    if (SQLFunctions.checkRole(Convert.ToInt32(dataRow[0])) == "Student")
                    {
                        FormMenuStudent mainForm = new FormMenuStudent(Convert.ToInt32(dataRow[0]), dataRow[1].ToString());
                        mainForm.Show();
                    }
                    else if (SQLFunctions.checkRole(Convert.ToInt32(dataRow[0])) == "SecretaryA")
                    {
                        FormMenuSecretary mainForm = new FormMenuSecretary(Convert.ToInt32(dataRow[0]), dataRow[1].ToString());
                        mainForm.Show();
                    }
                    else if (SQLFunctions.checkRole(Convert.ToInt32(dataRow[0])) == "Exam Department")
                    {
                        FormMenuExamDepartment mainForm = new FormMenuExamDepartment();
                        mainForm.Show();
                    }
                    else if (SQLFunctions.checkRole(Convert.ToInt32(dataRow[0])) == "Admin")
                    {
                        FormMenuAdmin mainForm = new FormMenuAdmin();
                        mainForm.Show();
                    }
                    else
                    {
                        B_8.login login = new B_8.login(true, SQLFunctions.convertFbMailToMail(fbMail), dataRow[1].ToString());
                    }
                }
            }
            else
            {
                SQLFunctions.linkFbAccount(mail, fbMail);
                MessageBox.Show("Your facebook account was succesfuly linked");
                this.Hide();
            }
        }
Exemplo n.º 9
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (textBoxID.Text == "")
            {
                MessageBox.Show("Logon Failure: unknown ID or invalid password");
                return;
            }

            if (SQLFunctions.checkLogIn(Convert.ToInt32(textBoxID.Text), textBoxPassword.Text))
            {
                this.Hide();

                if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Student")
                {
                    FormMenuStudent mainForm = new FormMenuStudent(Convert.ToInt32(textBoxID.Text), textBoxPassword.Text);
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Secretary")
                {
                    FormMenuSecretary mainForm = new FormMenuSecretary(Convert.ToInt32(textBoxID.Text), textBoxPassword.Text);
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Exam Department")
                {
                    FormMenuExamDepartment mainForm = new FormMenuExamDepartment();
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Admin")
                {
                    FormMenuAdmin mainForm = new FormMenuAdmin();
                    mainForm.Show();
                }
                else
                {
                    MessageBox.Show("Unknown Error");
                }
            }
            else
            {
                MessageBox.Show("Logon Failure: unknown ID or invalid password");
            }
        }
Exemplo n.º 10
0
        private void FormAdminViewErros_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();

            List <int> errorIDs = new List <int>();

            for (int i = 0; i < errors.Count; i++)
            {
                if (errors[i][4] == "True")
                {
                    errorIDs.Add(Convert.ToInt32(errors[i][0]));
                }
            }

            SQLFunctions.updateErrorsStatus(errorIDs);

            FormMenuAdmin adminForm = new FormMenuAdmin();

            adminForm.Show();
        }
Exemplo n.º 11
0
 private void button_Accept_Click(object sender, EventArgs e)
 {
     if (SQLFunctions.checkExistsUsers(Convert.ToInt32(textBox_UserID.Text)) == true)
     {
         if (SQLFunctions.checkRole(Convert.ToInt32(textBox_UserID.Text)) != comboBox_Permission.Text)
         {
             SQLFunctions.updateUserRole(Convert.ToInt32(textBox_UserID.Text), comboBox_Permission.Text);
             MessageBox.Show("User permission was changed to " + comboBox_Permission.Text + ".");
             this.Hide();
             FormMenuAdmin adminForm = new FormMenuAdmin();
             adminForm.Show();
         }
         else
         {
             MessageBox.Show("This user is already " + comboBox_Permission.Text);
         }
     }
     else
     {
         MessageBox.Show("User ID could not be located in the database");
     }
 }
Exemplo n.º 12
0
 private void button_Accept_Click(object sender, EventArgs e)
 {
     if (textBox_UserID.Enabled == true)
     {
         if (SQLFunctions.checkExistsUsers(Convert.ToInt32(textBox_UserID.Text)) == true)
         {
             if (SQLFunctions.checkRole(Convert.ToInt32(textBox_UserID.Text)) != comboBox_Permission.Text || comboBox_Permission.Text == "Student")
             {
                 if (comboBox_Permission.Text == "Students Secretary")
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(textBox_UserID.Text), "SecretaryA", comboBox_Department.Text);
                 }
                 else if (comboBox_Permission.Text == "Department Secretary")
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(textBox_UserID.Text), "Secretary", comboBox_Department.Text);
                 }
                 else
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(textBox_UserID.Text), comboBox_Permission.Text, comboBox_Department.Text);
                 }
                 if (comboBox_Permission.SelectedIndex == 0)
                 {
                     if (SQLFunctions.checkExistsStudents(Convert.ToInt32(textBox_UserID.Text)) == true)
                     {
                         SQLFunctions.updateStudentYearAndSemester(Convert.ToInt32(Convert.ToInt32(textBox_UserID.Text)), Convert.ToInt32(comboBox_Year.Text), Convert.ToChar(comboBox_Semester.Text));
                     }
                     else
                     {
                         SQLFunctions.addStudent(Convert.ToInt32(Convert.ToInt32(textBox_UserID.Text)), Convert.ToInt32(comboBox_Year.Text), Convert.ToChar(comboBox_Semester.Text));
                     }
                 }
                 else
                 {
                     if (SQLFunctions.checkExistsStudents(Convert.ToInt32(textBox_UserID.Text)) == true)
                     {
                         SQLFunctions.deleteStudent(Convert.ToInt32(Convert.ToInt32(textBox_UserID.Text)));
                     }
                 }
                 MessageBox.Show("User permission was changed to " + comboBox_Permission.Text + ".");
                 this.Hide();
                 FormMenuAdmin adminForm = new FormMenuAdmin();
                 adminForm.Show();
             }
             else
             {
                 MessageBox.Show("This user is already " + comboBox_Permission.Text);
             }
         }
         else
         {
             MessageBox.Show("User was not found");
         }
     }
     else
     {
         if (SQLFunctions.checkExistsUsers(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString())) == true)
         {
             if (SQLFunctions.checkRole(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString())) != comboBox_Permission.Text || comboBox_Permission.Text == "Student")
             {
                 if (comboBox_Permission.Text == "Students Secretary")
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()), "SecretaryA", comboBox_Department.Text);
                 }
                 else if (comboBox_Permission.Text == "Department Secretary")
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()), "Secretary", comboBox_Department.Text);
                 }
                 else
                 {
                     SQLFunctions.updateUserRole(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()), comboBox_Permission.Text, comboBox_Department.Text);
                 }
                 if (comboBox_Permission.SelectedIndex == 0)
                 {
                     if (SQLFunctions.checkExistsStudents(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString())) == true)
                     {
                         SQLFunctions.updateStudentYearAndSemester(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()), Convert.ToInt32(comboBox_Year.Text), Convert.ToChar(comboBox_Semester.Text));
                     }
                     else
                     {
                         SQLFunctions.addStudent(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()), Convert.ToInt32(comboBox_Year.Text), Convert.ToChar(comboBox_Semester.Text));
                     }
                 }
                 else
                 {
                     if (SQLFunctions.checkExistsStudents(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString())) == true)
                     {
                         SQLFunctions.deleteStudent(Convert.ToInt32(allUsers.Rows[comboBox_users.SelectedIndex]["ID"].ToString()));
                     }
                 }
                 MessageBox.Show("User permission was changed to " + comboBox_Permission.Text + ".");
                 this.Hide();
                 FormMenuAdmin adminForm = new FormMenuAdmin();
                 adminForm.Show();
             }
         }
         else
         {
             MessageBox.Show("User was not found");
         }
     }
 }