Esempio n. 1
0
        private void Loginbtn_Click(object sender, EventArgs e)
        {
            if (Usernametxt.TextLength > 0 && Passwordtxt.TextLength > 0)
            {
            username = Usernametxt.Text;
            String password = Passwordtxt.Text;

            MySqlConnection con = new MySqlConnection();
            con.ConnectionString = constring;
            MySqlDataAdapter dataadapter = new MySqlDataAdapter();
            DataSet dataset = new DataSet();

            MySqlCommand command = con.CreateCommand();
            command.CommandText = "SELECT * FROM staff WHERE staff_username='******' AND staff_password='******'";
            con.Open();
            dataadapter.SelectCommand = command;
            dataadapter.Fill(dataset, "staff");

            if (dataset.Tables["staff"].Rows.Count == 1)
            {
            DataRow dr = dataset.Tables["staff"].Rows[0];
            Usernametxt.Text = dr[5].ToString();
            string usernameresult = dr[5].ToString();
            string passresult = dr[6].ToString();

            if ((usernameresult == username) || (passresult == password))
            {
                if (password == "password")
                {
                    FirstTimeLogin FirstTimeLogin = new FirstTimeLogin();
                    FirstTimeLogin.Show();
                    this.Dispose(false);
                }
                else
                {
                    HomeForm HomeForm = new HomeForm();
                    HomeForm.Show();
                    this.Dispose(false);
                    con.Close();
                }
            }
            }

            else
            {
            MessageBox.Show("Incorrect Username/Password Combination");
            }
            }

            else if (Usernametxt.TextLength > 0 && Passwordtxt.TextLength == 0)
            {
            MessageBox.Show("Please Enter Your Password");
            }

            else
            {
            MessageBox.Show("Please Enter Your Username And Password");
            }
        }
Esempio n. 2
0
        private void Submitbtn_Click(object sender, EventArgs e)
        {
            DialogResult UpdateDetails = MessageBox.Show("Are You Sure You Wish To Update Your Details?", "Update Details", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (UpdateDetails == DialogResult.Yes)
            {
            if (Passwordtxt.Text == Password2txt.Text)
            {
            if (Passwordtxt.TextLength > 5)
            {
                if (Answer1txt.TextLength < 1)
                {
                    MessageBox.Show("Please enter your mothers maiden name.");
                }
                else if (Answer2txt.TextLength < 1)
                {
                    MessageBox.Show("Please enter your favourite instrument.");
                }
                else
                {
                    MySqlConnection con = new MySqlConnection();
                    con.ConnectionString = LoginForm.constring;

                    MySqlCommand command = con.CreateCommand();
                    command.CommandText = "UPDATE staff SET staff_password='******', staff_answer1='" + Answer1txt.Text + "', staff_answer2='" + Answer2txt.Text + "' WHERE staff_username='******'";
                    con.Open();
                    command.ExecuteNonQuery();
                    MessageBox.Show("Details submitted successfully.");
                    con.Close();

                    HomeForm HomeForm = new HomeForm();
                    HomeForm.Show();
                    this.Dispose(true);
                }
            }
            else
            {
                MessageBox.Show("Password must be 6-12 characters.");
            }
            }
            else if (Passwordtxt.Text != Password2txt.Text)
            {
            MessageBox.Show("Passwords do not match.");
            }

            else if (Answer1txt.TextLength < 0)
            {
            MessageBox.Show("Please enter your mothers maiden name.");
            }

            else if (Password2txt.TextLength < 0)
            {
            MessageBox.Show("Please enter your favourite instrument.");
            }
            }
        }
Esempio n. 3
0
 private void Homebtn_Click(object sender, EventArgs e)
 {
     HomeForm HomeForm = new HomeForm();
     HomeForm.Show();
     this.Dispose(true);
 }