コード例 #1
0
ファイル: BoardGameEvent.cs プロジェクト: SimCitee/ProjetBD2
        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, Description, Datestart.ToString("yy-MM-dd"));
                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, Description, Datestart));

                dbHelper.Transaction.Commit();

                BoardGameEventCollection.Instance().BoardgameEvents.Add(this);
            }
            catch (OracleException e) {
                throw e;
            }
        }
コード例 #2
0
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == 3)
            {
                eventPlayersDataGridView.DataSource    = null;
                eventBoardGamesDataGridView.DataSource = null;
                eventPlayersListBox.DataSource         = null;
                eventBoardGamesListBox.DataSource      = null;

                eventComboBox.DataSource    = new BindingSource(BoardGameEventCollection.Instance().BoardgameEvents, null);
                eventComboBox.DisplayMember = "EventNameDate";
                eventComboBox.ValueMember   = "Id";
            }
            else if (tabControl.SelectedIndex == 4)
            {
                try {
                    dbHelper.Connection.Open();
                    OracleCommand command = dbHelper.Connection.CreateCommand();
                    command.CommandText = QRY_VIEW_UPCOMING_EVENTS;
                    OracleDataReader reader = command.ExecuteReader();

                    DataTable upcomingEventDataTable = new DataTable();
                    InitViewDataTable(upcomingEventDataTable);

                    while (reader.Read())
                    {
                        upcomingEventDataTable.Rows.Add(reader["NAME"].ToString(), reader["DESCRIPTION"].ToString(), reader["DATESTART"].ToString(), reader["BOARDGAMENAME"].ToString(), reader["MINIMUM_PLAYER_NUMBER"].ToString(), reader["MAXIMUM_PLAYER_NUMBER"].ToString(), reader["MINIMUM_AGE"].ToString(), reader["AVERAGE_GAME_TIME"].ToString());
                    }

                    command.CommandText = QRY_VIEW_ADULT_EVENTS;
                    reader = command.ExecuteReader();

                    DataTable adultEventDataTable = new DataTable();
                    InitViewDataTable(adultEventDataTable);

                    while (reader.Read())
                    {
                        adultEventDataTable.Rows.Add(reader["EVENTNAME"].ToString(), reader["DESCRIPTION"].ToString(), reader["DATESTART"].ToString(), reader["NAME"].ToString(), reader["MINIMUM_PLAYER_NUMBER"].ToString(), reader["MAXIMUM_PLAYER_NUMBER"].ToString(), reader["MINIMUM_AGE"].ToString(), reader["AVERAGE_GAME_TIME"].ToString());
                    }

                    upcomingEventsDataGridView.DataSource = upcomingEventDataTable;
                    eventForAdultDataGridView.DataSource  = adultEventDataTable;
                }
                catch (OracleException ex) {
                    throw ex;
                }
                finally {
                    if (dbHelper.Connection != null)
                    {
                        dbHelper.Connection.Close();
                    }
                }
            }
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #5
0
ファイル: BoardGameEvent.cs プロジェクト: SimCitee/ProjetBD2
        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, Description, Datestart));
                dbHelper.LogTransaction(LogActions.Redo, command.CommandText);

                dbHelper.Transaction.Commit();

                BoardGameEventCollection.Instance().BoardgameEvents.Remove(this);
            }
            catch (OracleException e) {
                Name        = Memento.Name;
                Description = Memento.Description;
                Datestart   = Memento.Datestart;
                throw e;
            }
        }
コード例 #6
0
 private void RefreshEventsGrid()
 {
     eventsDataGridView.DataSource = null;
     eventsDataGridView.DataSource = BoardGameEventCollection.Instance().BoardgameEvents;
 }