示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Are you sure?", "Delete Account", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialog == DialogResult.Yes)
            {
                string query = "DELETE from Users Where ID = '" + Signin.id + "' ";

                SqlCommand deleteCommand = new SqlCommand(query);

                int row = objDBAccess.executeQuery(deleteCommand);

                if (row == 1)
                {
                    MessageBox.Show("Account Deleted Successfully.");

                    this.Hide();
                    Signin login = new Signin();
                    login.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured. Try Again.");
                }
            }
        }
示例#2
0
        private void btnUpdateInfo_Click(object sender, EventArgs e)
        {
            string newUserName     = txtNameHome.Text;
            string newUserEmail    = txtEmailHome.Text;
            string newUserPassword = txtPasswordHome.Text;
            string newUserCountry  = txtCountryHome.Text;

            if (newUserName.Equals(""))
            {
                MessageBox.Show("please write your name.");
            }
            else if (newUserEmail.Equals(""))
            {
                MessageBox.Show("please write your email.");
            }
            else if (newUserPassword.Equals(""))
            {
                MessageBox.Show("please write your password.");
            }
            else if (newUserCountry.Equals(""))
            {
                MessageBox.Show("please write your country.");
            }
            else
            {
                string query = "Update Users SET " +
                               "Name = '" + @newUserName + "', " +
                               "Email = '" + @newUserEmail + "', " +
                               "Password = '******', " +
                               "Country = '" + @newUserCountry + "' " +
                               "where ID = '" + Signin.id + "' ";

                // la @ serve a criptare

                SqlCommand updateCommand = new SqlCommand(query);

                updateCommand.Parameters.AddWithValue("@userName", @newUserName);
                updateCommand.Parameters.AddWithValue("@userEmail", @newUserEmail);
                updateCommand.Parameters.AddWithValue("@userPassword", @newUserPassword);
                updateCommand.Parameters.AddWithValue("@userCountry", @newUserCountry);

                int row = objDBAccess.executeQuery(updateCommand);

                if (row == 1)
                {
                    MessageBox.Show("Account Information Updated Successfully.");

                    this.Hide();
                    Signin login = new Signin();
                    login.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured. Try Again.");
                }
            }
        }
示例#3
0
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            string userName     = txtName.Text;
            string userEmail    = txtEmail.Text;
            string userPassword = txtPassword.Text;
            string userCountry  = txtCountry.Text;

            if (userName.Equals(""))
            {
                MessageBox.Show("Please enter your user name.");
            }
            else if (userEmail.Equals(""))
            {
                MessageBox.Show("Please enter your user email.");
            }
            else if (userPassword.Equals(""))
            {
                MessageBox.Show("Please enter your user password.");
            }
            else if (userCountry.Equals(""))
            {
                MessageBox.Show("Please enter your user country.");
            }
            else
            {
                SqlCommand insertCommand = new SqlCommand("insert into Users(Name,Email,Password,Country) values (@userName, @userEmail, @userPassword, @userCountry)");

                insertCommand.Parameters.AddWithValue("@userName", userName);
                insertCommand.Parameters.AddWithValue("@userEmail", userEmail);
                insertCommand.Parameters.AddWithValue("@userPassword", userPassword);
                insertCommand.Parameters.AddWithValue("@userCountry", userCountry);

                int row = objDBAccess.executeQuery(insertCommand);

                if (row == 1)
                {
                    MessageBox.Show("Account Created Successfully.");

                    this.Hide();
                    Signin login = new Signin();
                    login.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured. Try Again.");
                }
            }
        }