Esempio n. 1
0
        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            GolfDB db = new GolfDB();

            //create user to be saved
            User user = new User();


            //check to see if user is already present by username
            User testUser = DBHelper.GetUserByUsername(txtUsername.Text);

            if (testUser == null)
            {
                User saveUser = new User();
                saveUser.Username = txtUsername.Text;
                saveUser.Password = txtPassword.Text;

                db.Users.Add(saveUser);
                if (db.SaveChanges() == 1)
                {
                    MessageBox.Show("User saved!");
                }
            }
            else
            {
                MessageBox.Show("User already exists!");
            }
        }
Esempio n. 2
0
        private void btnFinishGame_Click(object sender, EventArgs e)
        {
            var db = new GolfDB();

            db.Users.Attach(game.UserId);

            db.Games.Add(game);

            if (db.SaveChanges() == 1)
            {
                MessageBox.Show("Game saved!");
            }
            else
            {
                MessageBox.Show("Something went wrong.");
            }
        }
Esempio n. 3
0
        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            //create new golfDB to connect to DB?
            GolfDB db = new GolfDB();

            //create user to be saved
            User user = new User();


            if (txtPassword.Text != txtPassConfirmation.Text)
            {
                txtPassNotMatched.Visible = true;
            }

            else if (txtPassword.Text == txtPassConfirmation.Text && txtPassword.Text.Length >= 6)
            {
                //check to see if user is already present by username
                User testUser = DBHelper.GetUserByUsername(txtUsername.Text);
                if (testUser == null)
                {
                    User saveUser = new User();
                    saveUser.Username = txtUsername.Text;
                    saveUser.Password = txtPassword.Text;

                    db.Users.Add(saveUser);
                    if (db.SaveChanges() == 1)
                    {
                        MessageBox.Show("User saved!");
                    }
                }
                else
                {
                    MessageBox.Show("User already exists!");
                }
            }
            else
            {
                lblPassCharacter.Visible = true;
            }
        }