Exemplo n.º 1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (SQLFunctions.checkLogIn(Convert.ToInt32(textBoxID.Text), textBoxPassword.Text))
            {
                this.Hide();

                if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Student")
                {
                    FormMenuStudent mainForm = new FormMenuStudent();
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Secretary")
                {
                    FormMenuSecretary mainForm = new FormMenuSecretary();
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Exam Department")
                {
                    FormMenuExamDepratment mainForm = new FormMenuExamDepratment();
                    mainForm.Show();
                }
                else if (SQLFunctions.checkRole(Convert.ToInt32(textBoxID.Text)) == "Admin")
                {
                }
                else
                {
                    MessageBox.Show("Unknown Error");
                }
            }
            else
            {
                MessageBox.Show("Logon Failure: unknown ID or bad password");
            }
        }
Exemplo n.º 2
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.º 3
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.º 4
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");
         }
     }
 }