private void PasswordJokes(string Password)
        {
            DialogResult MsgResult;

            Password = Password.ToLower();
            switch (Password)
            {
            case "beefstew":
                MsgResult = MessageBox.Show("Your password is not stroganoff!", "Password Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (MsgResult == DialogResult.OK)
                {
                    TXT_Password.Clear();
                    TXT_PassReEnter.Clear();
                }
                break;

            case "1forest1":
                MsgResult = MessageBox.Show("You are not forest gump", "Password Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (MsgResult == DialogResult.OK)
                {
                    TXT_Password.Clear();
                    TXT_PassReEnter.Clear();
                }
                break;
            }
        }
        private void BTN_Register_Click(object sender, EventArgs e)
        {
            DialogResult MsgResult;

            PasswordJokes(TXT_Password.Text);
            bool IsValid = TXT_Password.Text != "" && TXT_FirstName.Text != "";

            if (IsValid || (!CHC_IsTeacher.Checked && IsValid && TXT_Username.Text != ""))
            {
                if (TXT_Password.Text == TXT_PassReEnter.Text)
                {
                    Database.UpdateLoginCredentials(TXT_TeacherID.Text, TXT_TeacherPass.Text);
                    if (Database.ComparisonTeachers())
                    {
                        if (CHC_IsTeacher.Checked)
                        {
                            Database.AddTeacher(TXT_FirstName.Text, TXT_Password.Text);
                            MsgResult = MessageBox.Show("Teacher Added Sucessfully", "Teacher Added", MessageBoxButtons.OK, MessageBoxIcon.Question);
                            Form StudentDetails = new NewStudentDetails(Database, TXT_FirstName.Text, true);
                            StudentDetails.Show();
                            this.Hide();
                        }
                        else
                        {
                            Database.AddStudent(TXT_FirstName.Text, TXT_Username.Text, TXT_Password.Text, TXT_TeacherID.Text);
                            MsgResult = MessageBox.Show("Student Added Sucessfully", "Student Added", MessageBoxButtons.OK, MessageBoxIcon.Question);
                            Database.UpdateLoginCredentials(TXT_Username.Text, TXT_Password.Text);
                            Form StudentDetails = new NewStudentDetails(Database, TXT_FirstName.Text, false);
                            StudentDetails.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MsgResult = MessageBox.Show("You must have your teachers correct details!", "Incorrect Teacher!!!", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
                else
                {
                    MsgResult = MessageBox.Show("Your password is not the same!", "Password Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    if (MsgResult == DialogResult.OK)
                    {
                        TXT_Password.Clear();
                        TXT_PassReEnter.Clear();
                    }
                }
            }
            else
            {
                MsgResult = MessageBox.Show("There is blank fields!", "Credentials Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (MsgResult == DialogResult.OK)
                {
                    TXT_Password.Clear();
                    TXT_PassReEnter.Clear();
                }
            }
        }
Beispiel #3
0
        private void BTN_Login_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(TXT_Username.Text) && (!string.IsNullOrEmpty(TXT_Password.Text)))
                {
                    try
                    {
                        if (TXT_Username.Text == uneCn.VerifUsername(TXT_Username.Text).Rows[0]["username"].ToString() &&
                            TXT_Password.Text == uneCn.VerifPassword(TXT_Password.Text).Rows[0]["password"].ToString())
                        {
                            TXT_Username.Clear();
                            TXT_Password.Clear();
                            CB_ShowPassword.Checked = false;

                            this.Hide();

                            Mission1 formMain = new Mission1();
                            formMain.ShowDialog();
                            formMain = null;

                            this.Show();
                            this.TXT_Username.Select();
                        }
                        else
                        {
                            MessageBox.Show("L'Username ou le Password est incorect. Essayer encore.", " ",
                                            MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            TXT_Username.Focus();
                            TXT_Username.SelectAll();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Probleme de login");
                    }
                }
                else
                {
                    MessageBox.Show("S'il vous plait entrer un Username et un Password.", " ",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TXT_Username.Select();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Probleme de connexion");
            }
        }
        private void BTN_Import_Click(object sender, EventArgs e)
        {
            DialogResult MsgResult;

            Database.UpdateLoginCredentials(TXT_Username.Text, TXT_Password.Text);
            if (Database.ComparisonTeachers())
            {
                Form Import = new ImportScreen(Database);
                Import.Show();
                this.Dispose();
            }
            else
            {
                MsgResult = MessageBox.Show("You must be a teacher to import!", "Incorrect Login!!!", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (MsgResult == DialogResult.OK)
                {
                    TXT_Password.Clear();
                    TXT_Username.Clear();
                }
            }
        }
        private void BTN_Login_Click(object sender, EventArgs e)
        {
            DialogResult MsgResult;
            string       Output  = "Username or Password is incorrect, please try again";
            string       ExitMsg = "Loadup Error";

            Database.UpdateLoginCredentials(TXT_Username.Text, TXT_Password.Text);
            Database.FillStudentsTbl();
            if (Database.ComparisonStudents())
            {
                Form Menu = new SongMenu(Database);
                Menu.Show();
                this.Dispose();
            }
            else
            {
                MsgResult = MessageBox.Show(Output, ExitMsg, MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (MsgResult == DialogResult.OK)
                {
                    TXT_Password.Clear();
                    TXT_Username.Clear();
                }
            }
        }
Beispiel #6
0
 private void BTN_Clear_Click(object sender, EventArgs e)
 {
     TXT_Username.Clear();
     TXT_Password.Clear();
     TXT_Username.Focus();
 }