コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
        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();
                }
            }
        }