public void MovePlayers( int tableNum ) { int numPlayersOnTable = TableDataService.GetNumPlayers( tableNum ); int numSelectedPlayers = this.playersGrid.SelectedRows.Count; this.playersGrid.EndEdit(); if ( numPlayersOnTable + numSelectedPlayers > 9 ) { MessageBox.Show( "Too many players. You can only have 9 players per table. Select another table or cancel.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List<int> playerIDs = new List<int>(); _movePlayersForm.DisableCancelButton(); _movePlayersForm.ChangeDisplayText( "Moving players to table " + Convert.ToString( tableNum ) + "....."); foreach ( DataGridViewRow player in this.playersGrid.SelectedRows ) { playerIDs.Add( Convert.ToInt32( player.Cells[0].Value.ToString() ) ); } TableDataService.MovePlayers( playerIDs, tableNum ); _movePlayersForm.Hide(); _status = EditTableStatus.Done; this.Enabled = true; }
private void playersGrid_CellEndEdit( object sender, DataGridViewCellEventArgs e ) { playersGrid.Rows[e.RowIndex].ErrorText = String.Empty; List<string> playerNames = GetPlayerNames( e.RowIndex ); string newPlayerName = PlayerNameFunctions.GetName( (string)playersGrid.Rows[e.RowIndex].Cells[1].Value, playerNames ); playersGrid.Rows[e.RowIndex].Cells[1].Value = newPlayerName; TablesDB.DataContext.SubmitChanges(); _status = EditTableStatus.Done; }
private void movePlayersForm_Canceled( object sender, EventArgs e ) { this._status = EditTableStatus.Done; this._movePlayersForm.Hide(); this.Enabled = true; }
private void playersGrid_CellBeginEdit( object sender, DataGridViewCellCancelEventArgs e ) { _status = EditTableStatus.Busy; }
private void btnMovePlayers_Click( object sender, EventArgs e ) { foreach ( DataGridViewCell cell in this.playersGrid.SelectedCells ) { cell.OwningRow.Selected = true; } int selectedRowCount = this.playersGrid.Rows.GetRowCount( DataGridViewElementStates.Selected ); if ( selectedRowCount < 1 ) { MessageBox.Show( "No players are selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } _status = EditTableStatus.MovingPlayers; _movePlayersForm.Show(); _movePlayersForm.Left = this.Parent.Left + (this.Width / 2) - (_movePlayersForm.Width / 2); _movePlayersForm.BringToFront(); this.Enabled = false; }