private void btn_UpdateInfo_Click(object sender, EventArgs e)
        {
            string newUserName     = txt_NameHome.Text;
            string newUserEmail    = txt_EmailHome.Text;
            string newUserPassword = txt_PasswordHome.Text;
            string newUserCountry  = txt_CountryHome.Text;

            if (newUserName.Equals(""))
            {
                MessageBox.Show("Please fill user name.");
            }
            else if (newUserEmail.Equals(""))
            {
                MessageBox.Show("Please fill user Email.");
            }
            else if (newUserPassword.Equals(""))
            {
                MessageBox.Show("Please fill user Password.");
            }
            else if (newUserCountry.Equals(""))
            {
                MessageBox.Show("Please fill user County.");
            }
            else
            {
                string qurey = "Update Users SET Name='" + @newUserName + "',Email='" + @newUserEmail + "',Password='******',Country='" + @newUserCountry + "'where ID='" + SignIn.id + "'";

                SqlCommand updateCommand = new SqlCommand(qurey);

                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 sign = new SignIn();
                    sign.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured..Try Again");
                }
            }
        }
Esempio n. 2
0
        private void btn_SignUp_Click(object sender, EventArgs e)
        {
            string userName     = txt_Name.Text;
            string userEmail    = txt_Email.Text;
            string userPassword = txt_Password.Text;
            string userCountry  = txt_Country.Text;


            if (userName.Equals(""))
            {
                MessageBox.Show("Write your user name.");
            }
            else if (userEmail.Equals(""))
            {
                MessageBox.Show("Write your Email.");
            }
            else if (userPassword.Equals(""))
            {
                MessageBox.Show("Write your Password.");
            }
            else if (userCountry.Equals(""))
            {
                MessageBox.Show("Write your 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,Please login now.");
                    this.Hide();

                    SignIn sign = new SignIn();
                    sign.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured..Try Again");
                }
            }
        }
        private void btn_Delete_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 information deleted  successfully");
                    this.Hide();

                    SignIn sign = new SignIn();
                    sign.Show();
                }
                else
                {
                    MessageBox.Show("Error Occured..Try Again");
                }
            }
        }