private void button2_Click(object sender, EventArgs e)// Add selected player { if (dataGridView1.SelectedRows.Count == 1) { DataGridViewRow Row = this.dataGridView1.SelectedRows[0]; playerID = Int32.Parse(Row.Cells[0].Value.ToString()); playerPrice = Int32.Parse(Row.Cells[4].Value.ToString()); } else { MessageBox.Show("Please select only one player to Add"); return; } if (wildcard_activated) { if ((UserBank - (playerPrice / 2)) < 0) { MessageBox.Show("Funds not avilable to complete your transfer !"); return; } int result1 = controllerObj.AddPlayer(playerID, UserID); int result2 = controllerObj.UpdateBank(UserID, UserBank - (playerPrice / 2), ref UserBank); if (result1 == 0) { MessageBox.Show("Failed to Add Player"); } else if (result2 == 0) { MessageBox.Show("Failed to Update Bank"); } else { MessageBox.Show("Player Added & Bank Updated successfully !"); textBox1.Text = UserBank.ToString(); DataTable dt1 = controllerObj.SelectAllUserUnpickedTeam(UserID); dataGridView1.DataSource = dt1; dataGridView1.Refresh(); DataTable dt2 = controllerObj.SelectAllUserPickedTeam(UserID); dataGridView2.DataSource = dt2; dataGridView2.Refresh(); } int result = controllerObj.UpdateUsedWildcard(UserID); if (result == 0) { MessageBox.Show("Failed to Update user's used wild card"); } else { MessageBox.Show("user's used wild card updated succesfully"); } //query update attribute used for wildcard to be = 1 given UserID } else { if ((UserBank - playerPrice) < 0) { MessageBox.Show("Funds not avilable to complete your transfer !"); return; } int result1 = controllerObj.AddPlayer(playerID, UserID); int result2 = controllerObj.UpdateBank(UserID, UserBank - playerPrice, ref UserBank); if (result1 == 0) { MessageBox.Show("Failed to Add Player"); } else if (result2 == 0) { MessageBox.Show("Failed to Update Bank"); } else { MessageBox.Show("Player Added & Bank Updated successfully !"); textBox1.Text = UserBank.ToString(); DataTable dt1 = controllerObj.SelectAllUserUnpickedTeam(UserID); dataGridView1.DataSource = dt1; dataGridView1.Refresh(); DataTable dt2 = controllerObj.SelectAllUserPickedTeam(UserID); dataGridView2.DataSource = dt2; dataGridView2.Refresh(); } } }