Ejemplo n.º 1
0
        public void LoadBoardEventsFromDatabase(OracleConnection connection)
        {
            try {
                OracleCommand command = connection.CreateCommand();
                command.CommandText = "SELECT EVENTS.ID, EVENTS.NAME, EVENTS.DESCRIPTION, TO_CHAR(EVENTS.DATESTART, 'DD-MM-YYYY') AS DATESTART FROM EVENTS";

                connection.Open();

                OracleDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    DateTime dateStart = DateTime.ParseExact(reader["DATESTART"].ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);

                    BoardGameEvent boardgameEvent = new BoardGameEvent(reader["NAME"].ToString(), reader["DESCRIPTION"].ToString(), dateStart, (Int32.Parse(reader["ID"].ToString())));
                    BoardgameEvents.Add(boardgameEvent);
                }
            }
            catch (OracleException e) {
                throw e;
            }
            catch (Exception e) {
                throw e;
            }
            finally {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void eventsDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                BoardGameEvent model = (BoardGameEvent)eventsDataGridView.Rows[e.RowIndex].DataBoundItem;

                if (e.ColumnIndex == 3)
                {
                    _dateTimePicker       = new DateTimePicker();
                    _dateTimePicker.Value = model.Datestart;
                    eventsDataGridView.Controls.Add(_dateTimePicker);
                    _dateTimePicker.Format = DateTimePickerFormat.Short;
                    Rectangle rectangle = eventsDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    _dateTimePicker.Size         = new Size(rectangle.Width, rectangle.Height);
                    _dateTimePicker.Location     = new Point(rectangle.X, rectangle.Y);
                    _dateTimePicker.CloseUp     += new EventHandler(_dateTimePicker_CloseUp);
                    _dateTimePicker.TextChanged += new EventHandler(_dateTimePicker_OnTextChange);
                    _dateTimePicker.Format       = DateTimePickerFormat.Custom;
                    _dateTimePicker.CustomFormat = "dd MMMM yyyy";
                    _dateTimePicker.Visible      = true;
                }

                try {
                    dbHelper.LockBeforeUpdate(model);
                }
                catch (OracleException ex) {
                    dbHelper.CancelUpdate();
                }
            }
        }
Ejemplo n.º 3
0
        private void btnAddEvent_Click(object sender, EventArgs e)
        {
            BoardGameEvent boardGameEvent = new BoardGameEvent();
            FormAddEvent   form           = new FormAddEvent(boardGameEvent);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                dbHelper.Insert(boardGameEvent);
                RefreshEventsGrid();
            }
        }
Ejemplo n.º 4
0
        private void eventBoardGamesRemoveBtn_Click(object sender, EventArgs e)
        {
            if (eventBoardGamesDataGridView.SelectedRows.Count == 1)
            {
                BoardGameEvent selectedEvent = eventComboBox.SelectedItem as BoardGameEvent;
                BoardGame      boardGame     = (BoardGame)eventBoardGamesDataGridView.SelectedRows[0].DataBoundItem;

                selectedEvent.RemoveBoardGameFromBoardGameList(boardGame, dbHelper.Connection);
                eventBoardGamesDataGridView.DataSource = null;
                eventBoardGamesDataGridView.DataSource = selectedEvent.BoardGameList;

                (eventBoardGamesListBox.DataSource as List <BoardGame>).Add(boardGame);
                List <BoardGame> temp = eventBoardGamesListBox.DataSource as List <BoardGame>;
                RefreshEventBoardGamesListBox(temp);
            }
        }
Ejemplo n.º 5
0
        private void eventBoardGamesAddBtn_Click(object sender, EventArgs e)
        {
            if (eventBoardGamesListBox.SelectedIndex > -1)
            {
                BoardGameEvent selectedEvent = eventComboBox.SelectedItem as BoardGameEvent;
                BoardGame      boardGame     = eventBoardGamesListBox.SelectedItem as BoardGame;

                selectedEvent.AddBoardGameToBoardGameList(boardGame, dbHelper.Connection);
                eventBoardGamesDataGridView.DataSource = null;
                eventBoardGamesDataGridView.DataSource = selectedEvent.BoardGameList;

                (eventBoardGamesListBox.DataSource as List <BoardGame>).Remove(boardGame);
                List <BoardGame> temp = eventBoardGamesListBox.DataSource as List <BoardGame>;
                RefreshEventBoardGamesListBox(temp);
            }
        }
Ejemplo n.º 6
0
        private void eventPlayersRemoveBtn_Click(object sender, EventArgs e)
        {
            if (eventPlayersDataGridView.SelectedRows.Count == 1)
            {
                BoardGameEvent selectedEvent = eventComboBox.SelectedItem as BoardGameEvent;
                Player         player        = (Player)eventPlayersDataGridView.SelectedRows[0].DataBoundItem;

                selectedEvent.RemovePlayerFromPlayerList(player, dbHelper.Connection);
                eventPlayersDataGridView.DataSource = null;
                eventPlayersDataGridView.DataSource = selectedEvent.PlayerList;

                (eventPlayersListBox.DataSource as List <Player>).Add(player);
                List <Player> temp = eventPlayersListBox.DataSource as List <Player>;
                RefreshEventPlayersListBox(temp);
            }
        }
Ejemplo n.º 7
0
        private void eventPlayersAddBtn_Click(object sender, EventArgs e)
        {
            if (eventPlayersListBox.SelectedIndex > -1)
            {
                BoardGameEvent selectedEvent = eventComboBox.SelectedItem as BoardGameEvent;
                Player         player        = eventPlayersListBox.SelectedItem as Player;

                selectedEvent.AddPlayerToPlayerList(player, dbHelper.Connection);
                eventPlayersDataGridView.DataSource = null;
                eventPlayersDataGridView.DataSource = selectedEvent.PlayerList;

                (eventPlayersListBox.DataSource as List <Player>).Remove(player);
                List <Player> temp = eventPlayersListBox.DataSource as List <Player>;
                RefreshEventPlayersListBox(temp);
            }
        }
Ejemplo n.º 8
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.º 9
0
 public FormAddEvent(BoardGameEvent boardGameEvent)
 {
     InitializeComponent();
     _boardGameEvent       = boardGameEvent;
     dtpNewEventDate.Value = DateTime.Now;
 }