Пример #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;


            cmd.CommandText = " select * from library_person where username='******' and password='******'";
            cmd.ExecuteNonQuery();
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            count = Convert.ToInt32(dt.Rows.Count.ToString());
            if (count == 0)
            {
                MessageBox.Show("Wrong Username/Password !!!\nPlease Try Again");
            }
            else
            {
                this.Hide();
                mdi_user mu = new mdi_user();
                mu.Show();
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = $"select * from library_person where username='******' and password='******';";
            //takes the data from the password and user fields and checks them agains the database
            MySqlCommand cmd = new MySqlCommand(sql, dbconnection);

            cmd.ExecuteNonQuery();

            DataTable dt = new DataTable();
            // creating a datatable to populate with the users' credentials provided
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);

            //uses a data adatapter and fills the newly created datatable
            da.Fill(dt);
            count = Convert.ToInt32(dt.Rows.Count.ToString());

            if (count == 0)
            {
                MessageBox.Show("username password does not match");
            }
            else
            {
                this.Hide();                   // hides the page as it is no longer required
                dbconnection.Close();          // closes the db connecection
                mdi_user mdi = new mdi_user(); //navigates to the mdi user
                mdi.Show();                    //shows the defined link above
            }
        }
Пример #3
0
        private void ButtonCreateAccount_Click(object sender, EventArgs e)
        {
            // opens dbconnection
            con = new MySqlConnection("server=localhost;user=root;database=120itdb;port=3306;password=;");
            con.Open();
            MySqlCommand command = con.CreateCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "Insert into library_person(`Id`, `fullname`, `username`, `password`, `email`)  values (null,'" + textBoxFirstname.Text + "', '" + textBoxUsername.Text + "', '" + textBoxPassword.Text + "', '" + textBoxEmail.Text + "')";
            command.ExecuteNonQuery();
            // fills data into db if the following statements are correct

            if (!CheckTextBoxesValues()) // see the method further below, but checks if the default values are present
            {
                // check if the password equal the confirm password
                if (textBoxPassword.Text.Equals(textBoxConfirmPassword.Text))
                {
                    // check if this username already exists
                    if (checkUsername())
                    {
                        MessageBox.Show("This Username Already Exists, Select A Different One", "Duplicate Username", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                    else
                    {
                        // execute the query
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Your Account Has Been Created", "Account Created, Welcome to Lend-It-Out", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                            con.Close();
                            mdi_user mu = new mdi_user();
                            mu.Show();
                        }
                        else
                        {
                            MessageBox.Show("ERROR");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Wrong Confirmation Password", "Password Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Enter Your Data First", "Empty Data", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }