Пример #1
0
        private void Return_Click(object sender, EventArgs e)
        {
            LoginPart login = new LoginPart();

            this.Hide();
            login.Show();
        }
        //Deletes your account from the Database
        private void DeleteDB_Click(object sender, EventArgs e)
        {
            LoginPart login = new LoginPart();

            if (MessageBox.Show("Are you sure you want to delete your account", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var getIdByUsernameToDelete = contexts.PersonRegisters.FirstOrDefault(x => x.Username == label14.Text);
                BookForUser.Delete(getIdByUsernameToDelete.Id);
                PersonAccount.Delete(getIdByUsernameToDelete.Id);
                PersonRegister.Delete(getIdByUsernameToDelete.Id);
                MessageBox.Show("Account deleted succsesfully!");
                this.Hide();
                login.Show();
            }
        }
Пример #3
0
        private void Register_Click(object sender, EventArgs e)
        {
            LoginPart login = new LoginPart();

            //Check's is everything filled
            if (txtUsernameRegisterForm.Text == "" || txtPasswordRegisterForm.Text == "" || txtConfirmPasswordRegisterForm.Text == "" || Bookstypes.Text == "")
            {
                MessageBox.Show("Please fill the rows to register");
            }
            else
            {
                if (Bookstypes.Text == "Business")
                {
                    //Check's is the password textbox and Confirmpassword texbox are equal and not equal to zero
                    if (txtPasswordRegisterForm.Text == txtConfirmPasswordRegisterForm.Text && txtPasswordRegisterForm.Text.Length != 0)
                    {
                        //this variable returns true if the name exists or false if no
                        var CheckIfExists = User.CheckIfUsernameExists(txtUsernameRegisterForm.Text);
                        //this if statement checks if the names are equal or no
                        if (!(CheckIfExists == txtUsernameRegisterForm.Text))
                        {
                            User.Add(txtUsernameRegisterForm.Text, txtPasswordRegisterForm.Text);
                            //this if will happen only once per creation of a new account
                            if (!(UserBookType.CheckIfExsist()))
                            {
                                var business = "Business";
                                UserBookType.Add(business, 1);
                            }
                            var a = User.GetAll();
                            UserAccount.Add(1);
                            BookForUser.Add(smallshop.GetTime(), 0, 0, 0, 0, 0, 0, 1, a.Count());
                            this.Hide();
                            login.Show();
                            MessageBox.Show("Succsessfully registered");
                        }
                        else
                        {
                            MessageBox.Show("This Username is taken");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Passswords doesn't match");
                    }
                }
            }
        }