Example #1
0
        private void save_Click(object sender, EventArgs e)
        {
            OleDbConnection c   = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source = '..\..\Resources\Saved Games.accdb'");
            OleDbCommand    sql = new OleDbCommand();

            sql.CommandType = CommandType.Text;
            sql.CommandText = @"INSERT INTO Game(PlayerTurn,isSP,P1CounterNum,p2CounterNum,Difficulty,GameName) VALUES(?,?,?,?,?,?)";// will put all the information about the game into the database to load at a later date.
            sql.Parameters.AddWithValue(@"PlayerTurn", _playerTurn);
            sql.Parameters.AddWithValue(@"isSP", _isSP);
            sql.Parameters.AddWithValue(@"P1CounterNum", _p1CounterNum);
            sql.Parameters.AddWithValue(@"P2CounterNum", _p2CounterNum);
            sql.Parameters.AddWithValue(@"Difficulty", _difficulty);
            sql.Parameters.AddWithValue(@"GameName", textBox.Text);
            sql.Connection = c;
            c.Open();
            sql.ExecuteNonQuery();
            c.Close();
            foreach (int col in _moveHistory)
            {
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = @"INSERT INTO MoveHistory(Columns,GameName) VALUES(?,?)";//Will put the move history into the database to be loaded at a later date.
                cmd.Parameters.AddWithValue(@"Columns", col);
                cmd.Parameters.AddWithValue(@"GameName", textBox.Text);
                cmd.Connection = c;
                c.Open();
                cmd.ExecuteNonQuery();
                c.Close();
            }
            Main_Menu m = new Main_Menu();// will bring you back to the main menu once saved.

            m.Show();
            m.Closed += (s, args) => this.Close();
            this.Hide();
        }
Example #2
0
        private void home_Click(object sender, EventArgs e)// Takes you to main menu form.
        {
            Main_Menu m = new Main_Menu();

            m.Show();
            m.Closed += (s, args) => this.Close();
            this.Hide();
        }
        private void home_Click(object sender, EventArgs e)
        {
            Main_Menu m = new Main_Menu();//Will go back to home menu if clicked.

            m.Closed += (s, args) => this.Close();
            this.Hide();
            m.Show();
        }
Example #4
0
        private void home_Click(object sender, EventArgs e)
        {
            Main_Menu m = new Main_Menu();

            m.Show();
            m.Closed += (s, args) => this.Close();
            this.Hide();
        }
Example #5
0
        private void PlayAgain_Click(object sender, EventArgs e)// If they click play again button will play again otherwise will exit.
        {
            Main_Menu m = new Main_Menu();

            m.Show();
            m.Closed += (s, args) => this.Close();
            this.Hide();
        }
Example #6
0
 private void Won_Click(object sender, EventArgs e) //Can only click when visible after the games won.
 {
     if (_board.boardFull())                        //if board was full takes to main menu otherwise takes you to winner form.
     {
         Main_Menu m = new Main_Menu();
         m.Show();
         m.Closed += (s, args) => this.Close();
         this.Hide();
     }
     else
     {
         Winner w = new Winner("Player " + (_u1.CurrentUser ? "1" : "2"));
         w.Show();
         w.Closed += (s, args) => this.Close();
         this.Hide();
     }
 }