Ejemplo n.º 1
0
        public override void Delete(DatabaseHelper dbHelper)
        {
            try {
                OracleCommand command = dbHelper.Connection.CreateCommand();
                command.CommandText = QRY_LOCK;
                command.ExecuteNonQuery();

                command.CommandText = String.Format(QRY_DELETE, Id);
                command.ExecuteNonQuery();

                dbHelper.LogTransaction(LogActions.Undo, String.Format(QRY_FULL_INSERT, Id, Name, MinimumPlayerNumber, MaximumPlayerNumber, MinimumAge, AverageGameTime));
                dbHelper.LogTransaction(LogActions.Redo, command.CommandText);

                dbHelper.Transaction.Commit();

                BoardGameCollection.Instance().BoardGames.Remove(this);
            }
            catch (OracleException e) {
                Name = Memento.Name;
                MinimumPlayerNumber = Memento.MinimumPlayerNumber;
                MaximumPlayerNumber = Memento.MaximumPlayerNumber;
                MinimumAge          = Memento.MinimumAge;
                AverageGameTime     = Memento.AverageGameTime;
                throw e;
            }
        }
Ejemplo n.º 2
0
        public override void Insert(DatabaseHelper dbHelper)
        {
            try {
                OracleDecimal output;
                OracleCommand command = dbHelper.Connection.CreateCommand();
                command.CommandText = QRY_LOCK;
                command.ExecuteNonQuery();

                command.CommandText = String.Format(QRY_INSERT, Name, MinimumPlayerNumber, MaximumPlayerNumber, MinimumAge, AverageGameTime);
                command.Parameters.Add("output", OracleDbType.Decimal, ParameterDirection.ReturnValue);
                command.ExecuteNonQuery();

                output  = (OracleDecimal)command.Parameters["output"].Value;
                this.Id = output.ToInt32();

                dbHelper.LogTransaction(LogActions.Undo, String.Format(QRY_DELETE, output.ToInt32()));
                dbHelper.LogTransaction(LogActions.Redo, String.Format(QRY_INSERT, Name, MinimumPlayerNumber, MaximumPlayerNumber, MinimumAge, AverageGameTime));

                dbHelper.Transaction.Commit();

                BoardGameCollection.Instance().BoardGames.Add(this);
            }
            catch (OracleException e) {
                throw e;
            }
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            dbHelper = new DatabaseHelper(DBCONFIG);

            statusLabel.Text = "Connecté";

            BoardGameEventCollection.Instance().LoadBoardEventsFromDatabase(dbHelper.Connection);
            BoardGameCollection.Instance().LoadBoardGamesFromDatabase(dbHelper.Connection);
            PlayerCollection.Instance().LoadPlayersFromDatabase(dbHelper.Connection);
        }
Ejemplo n.º 4
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            eventsDataGridView.Width      = eventsTabPage.Width - eventsDataGridView.Location.X;
            eventsDataGridView.Height     = eventsTabPage.Height - 80;
            playersDataGridView.Width     = playersTabPage.Width - playersDataGridView.Location.X;
            playersDataGridView.Height    = playersTabPage.Height - 80;
            boardGamesDataGridView.Width  = boardGamesTabPage.Width - boardGamesDataGridView.Location.X;
            boardGamesDataGridView.Height = boardGamesTabPage.Height - 80;

            eventPlayersDataGridView.AutoGenerateColumns    = false;
            eventBoardGamesDataGridView.AutoGenerateColumns = false;
            eventsDataGridView.AutoGenerateColumns          = false;
            boardGamesDataGridView.AutoGenerateColumns      = false;
            playersDataGridView.AutoGenerateColumns         = false;
            eventForAdultDataGridView.AutoGenerateColumns   = false;
            upcomingEventsDataGridView.AutoGenerateColumns  = false;

            eventsDataGridView.DataSource     = BoardGameEventCollection.Instance().BoardgameEvents;
            boardGamesDataGridView.DataSource = BoardGameCollection.Instance().BoardGames;
            playersDataGridView.DataSource    = PlayerCollection.Instance().Players;
        }
Ejemplo n.º 5
0
        public void LoadBoardGamesFromDatabase(OracleConnection connection)
        {
            try {
                OracleCommand command = connection.CreateCommand();
                command.CommandText = String.Format(QRY_SELECT_BOARDGAMES, _id);

                connection.Open();

                OracleDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    BoardGameList.Add(BoardGameCollection.Instance().BoardGames.Where(s => s.Id == Int32.Parse(reader["BOARDGAME_ID"].ToString())).First());
                }
            }
            catch (OracleException e) {
                throw e;
            }
            finally {
                connection.Close();
            }
        }
Ejemplo n.º 6
0
        private void eventComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == 3 && eventComboBox.SelectedItem != null)
            {
                BoardGameEvent selectedEvent = eventComboBox.SelectedItem as BoardGameEvent;

                selectedEvent.PlayerList.Clear();
                selectedEvent.BoardGameList.Clear();

                selectedEvent.LoadPlayersFromDatabase(dbHelper.Connection);
                selectedEvent.LoadBoardGamesFromDatabase(dbHelper.Connection);

                List <Player> playerList = new List <Player>();
                foreach (Player player in PlayerCollection.Instance().Players)
                {
                    if (!selectedEvent.PlayerList.Exists(x => x.Id == player.Id))
                    {
                        playerList.Add(player);
                    }
                }

                List <BoardGame> boardGameList = new List <BoardGame>();
                foreach (BoardGame boardgame in BoardGameCollection.Instance().BoardGames)
                {
                    if (!selectedEvent.BoardGameList.Exists(x => x.Id == boardgame.Id))
                    {
                        boardGameList.Add(boardgame);
                    }
                }

                RefreshEventPlayersListBox(playerList);
                RefreshEventBoardGamesListBox(boardGameList);

                eventPlayersDataGridView.DataSource    = selectedEvent.PlayerList;
                eventBoardGamesDataGridView.DataSource = selectedEvent.BoardGameList;
            }
        }
Ejemplo n.º 7
0
 private void RefreshBoardGamesGrid()
 {
     boardGamesDataGridView.DataSource = null;
     boardGamesDataGridView.DataSource = BoardGameCollection.Instance().BoardGames;
 }