private void CreatePlayerTransaction(PlayersDBDataSet.PlayersRow player) { // make the transaction here TransactionsDBDataSet.TransactionsRow newWinTransaction = transactionsDBDataSet.Transactions.NewTransactionsRow(); // add the data to that row newWinTransaction.PlayerName = player.PlayerPoolName; newWinTransaction.SeasonName = PublicVariables.GetDefaultSeason; newWinTransaction.Type = "Win Credit"; newWinTransaction.Method = "Win Credit Progressive"; newWinTransaction.Amount = -(double)upDownPayAmount.Value; newWinTransaction.Week = "Week 17"; newWinTransaction.Date = DateTime.Now.ToString(); newWinTransaction.Notes = "Progressive Win Credit"; transactionsDBDataSet.Transactions.Rows.Add(newWinTransaction); TransactionsDBDataSet.TransactionsRow newWinTransaction2 = transactionsDBDataSet.Transactions.NewTransactionsRow(); newWinTransaction2.PlayerName = player.PlayerPoolName; newWinTransaction2.SeasonName = PublicVariables.GetDefaultSeason; newWinTransaction2.Type = "Pay Out"; newWinTransaction2.Method = "Pay Out Progressive"; newWinTransaction2.Amount = (double)upDownPayAmount.Value; newWinTransaction2.Week = "Week 17"; newWinTransaction2.Date = DateTime.Now.ToString(); newWinTransaction2.Notes = "Progressive Pay Out"; transactionsDBDataSet.Transactions.Rows.Add(newWinTransaction2); }
private void PopulateLedgerBox(PlayersDBDataSet.PlayersRow player) { // clear the box listViewLedgerBox.Items.Clear(); double balance = 0; foreach (TransactionsDBDataSet.TransactionsRow transactions in transactionsDBDataSet.Transactions) { if (transactions.PlayerName == player.PlayerPoolName) { ListViewItem newRow = new ListViewItem(); // the first column is different than the sub items // newRow.Text will fill the first column newRow.Text = transactions.Id.ToString(); newRow.SubItems.Add(transactions.SeasonName); newRow.SubItems.Add(transactions.Date); newRow.SubItems.Add(transactions.Type); newRow.SubItems.Add(transactions.Method); newRow.SubItems.Add(transactions.Amount.ToString()); balance += transactions.Amount; newRow.SubItems.Add(balance.ToString()); listViewLedgerBox.Items.Add(newRow); } } }
private void NewTransaction(PlayersDBDataSet.PlayersRow selectedPlayer) { // create a new row TransactionsDBDataSet.TransactionsRow newTransaction = transactionsDBDataSet.Transactions.NewTransactionsRow(); // add the data to that row newTransaction.PlayerName = selectedPlayer.PlayerPoolName; newTransaction.SeasonName = textBoxSelectedSeason.Text; newTransaction.Type = "Pay Out"; newTransaction.Method = comboBoxPayMethod.Text; newTransaction.Amount = (double)selectedPlayer.WeOWePlayer; newTransaction.Week = comboBoxSelectWeek.Text; newTransaction.Date = DateTime.Now.ToString(); newTransaction.Notes = "Group Pay Out"; if (comboBoxPayMethod.Text == "Check") { if (textBoxCheckNumber.Text == "") { MessageBox.Show("Enter a check number."); return; } newTransaction.CheckNumber = textBoxCheckNumber.Text; } transactionsDBDataSet.Transactions.Rows.Add(newTransaction); this.Validate(); this.transactionsBindingSource.EndEdit(); this.tableAdapterManager3.UpdateAll(this.transactionsDBDataSet); }
// update all of the labels on the form based on the selected player. private void UpdateForm(PlayersDBDataSet.PlayersRow selectedPlayer) { textBoxPoolNameAdd.Text = selectedPlayer.PlayerPoolName; upDownBuyInAmount.Value = selectedPlayer.PlayerBuyIn; upDownCurrentWinnings.Value = selectedPlayer.PlayerTotalWinnings; upDownWins.Value = selectedPlayer.PlayerTotalWins; textBoxNameAdd.Text = selectedPlayer.PlayerPersonalName; textBoxAddressAdd.Text = selectedPlayer.PlayerAddress; textBoxPhoneAdd.Text = selectedPlayer.PlayerPhone; textBoxEmailAdd.Text = selectedPlayer.PlayerEmail; textBoxPreferContactAdd.Text = selectedPlayer.PlayerContactMethod; textBoxPreferPayoutAdd.Text = selectedPlayer.PlayerPayoutMethod; textBoxGroupName.Text = selectedPlayer.Notes; textBoxPlayerNotes.Text = selectedPlayer.PlayerNotes; if (selectedPlayer.IsActive == true) { checkBoxIsActive.Checked = true; } else { checkBoxIsActive.Checked = false; } // if group leader is checked then make them the group leader///////////////////////********* if (selectedPlayer.IsGroupLeader == true) { checkBoxIsGroupLeader.Checked = true; } else { checkBoxIsGroupLeader.Checked = false; } // it kept filling the text boxes with empty strings. This was my solution. I hate it. textBoxPoolNameAdd.Text = textBoxPoolNameAdd.Text.Trim(); textBoxNameAdd.Text = textBoxNameAdd.Text.Trim(); textBoxPhoneAdd.Text = textBoxPhoneAdd.Text.Trim(); textBoxEmailAdd.Text = textBoxEmailAdd.Text.Trim(); textBoxPreferContactAdd.Text = textBoxPreferContactAdd.Text.Trim(); textBoxPreferPayoutAdd.Text = textBoxPreferPayoutAdd.Text.Trim(); textBoxAddressAdd.Text = textBoxAddressAdd.Text.Trim(); textBoxGroupName.Text = textBoxGroupName.Text.Trim(); }
private void UpdateForm(PlayersDBDataSet.PlayersRow selectedPlayer) { // update labels based on the selected player labelPlayerNameLarge.Text = selectedPlayer.PlayerPoolName; labelPlayerWinsLarge.Text = selectedPlayer.PlayerTotalWins.ToString(); labelOweUsAmountPlayers.Text = selectedPlayer.PlayerOwes.ToString(); labelOweThemAmountPlayers.Text = selectedPlayer.WeOWePlayer.ToString(); BuildPicksListBox(selectedPlayer); // this finds the current wins based on which week it is WeeklyWins(); //This will turn label red if that player is out green if they still in it. if (selectedPlayer.IsOut) { labelPlayerCurrentWinsLarge.BackColor = Color.Red; } else { labelPlayerCurrentWinsLarge.BackColor = Color.Green; } }
private void PopulatePersonalInfoBoxes(PlayersDBDataSet.PlayersRow player) { textBoxPlayerInformation.Text = player.PlayerPoolName + Environment.NewLine + player.PlayerPersonalName + Environment.NewLine + player.PlayerAddress; textBoxPlayerContactInfo.Text = "PH: " + player.PlayerPhone + Environment.NewLine + "Email: " + player.PlayerEmail + Environment.NewLine + "Prefered Contact: " + player.PlayerContactMethod; }
private void TotalWeekWinnings(string selectedWeek, PlayersDBDataSet.PlayersRow selectedPlayer) { if (selectedWeek == "Week 01") { selectedPlayer.PlayerWinningsWeek01 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 02") { selectedPlayer.PlayerWinningsWeek02 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 03") { selectedPlayer.PlayerWinningsWeek03 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 04") { selectedPlayer.PlayerWinningsWeek04 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 05") { selectedPlayer.PlayerWinningsWeek05 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 06") { selectedPlayer.PlayerWinningsWeek06 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 07") { selectedPlayer.PlayerWinningsWeek07 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 08") { selectedPlayer.PlayerWinningsWeek08 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 09") { selectedPlayer.PlayerWinningsWeek09 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 10") { selectedPlayer.PlayerWinningsWeek10 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 11") { selectedPlayer.PlayerWinningsWeek11 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 12") { selectedPlayer.PlayerWinningsWeek12 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 13") { selectedPlayer.PlayerWinningsWeek13 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 14") { selectedPlayer.PlayerWinningsWeek14 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 15") { selectedPlayer.PlayerWinningsWeek15 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 16") { selectedPlayer.PlayerWinningsWeek16 += (int)selectedPlayer.WeOWePlayer; } if (selectedWeek == "Week 17") { selectedPlayer.PlayerWinningsWeek17 += (int)selectedPlayer.WeOWePlayer; } }
private void ReverseTransaction() { // transaction inside the loop was causing problems changing data while looping through TransactionsDBDataSet.TransactionsRow newTransaction = null; PlayersDBDataSet.PlayersRow transactionPlayer = null; // find the correct transaction foreach (TransactionsDBDataSet.TransactionsRow currentTransaction in transactionsDBDataSet.Transactions) { if (currentTransaction.Id.ToString() == textBoxTransactionId.Text) { // determine the type of transaction eg Pay, Receive or Charge // if it is pay if (textBoxType.Text == "Pay Out") { // find the player foreach (PlayersDBDataSet.PlayersRow selectedPlayer in playersDBDataSet.Players) { if (selectedPlayer.PlayerPoolName == currentTransaction.PlayerName) { // subtract the amount from their total winnings selectedPlayer.PlayerTotalWinnings -= upDownAmount.Value; selectedPlayer.WeOWePlayer += upDownAmount.Value; // subtract the amount from that weeks winnings GetWeekForWinnings(selectedPlayer); foreach (AccountingDataSet.AccountingRow accounting in accountingDataSet.Accounting) { if (accounting.SeasonName == textBoxSelectedSeason.Text) { // subtract accounting total payed out // add accounting total funds accounting.TotalPayedOut -= upDownAmount.Value; accounting.TotalFunds += upDownAmount.Value; // pop up window reversing a pay out. does the player now owe us this amount? was the player actually paid? var confirmChargePlayer = MessageBox.Show("Do you also want to charge the player this amount? Were they physically paid and now need to pay you back?", "Confirm Charge Player", MessageBoxButtons.YesNo); // if yes then charge the player that amount if (confirmChargePlayer == DialogResult.Yes) { // need a transaction if we charge the player // create a new row newTransaction = transactionsDBDataSet.Transactions.NewTransactionsRow(); transactionPlayer = selectedPlayer; // increase the player owes us selectedPlayer.PlayerOwes += upDownAmount.Value; // increase accounting total owed to us accounting.TotalOwedToUs += upDownAmount.Value; // if no then leave it alone } } } } } } // if it is receive payment if (textBoxType.Text == "Receive Payment" || textBoxType.Text == "Initial Payment") { // find the player foreach (PlayersDBDataSet.PlayersRow selectedPlayer in playersDBDataSet.Players) { if (selectedPlayer.PlayerPoolName == currentTransaction.PlayerName) { // increase players player owes us selectedPlayer.PlayerOwes += upDownAmount.Value; foreach (AccountingDataSet.AccountingRow accounting in accountingDataSet.Accounting) { if (accounting.SeasonName == textBoxSelectedSeason.Text) { // accounting subtract total funds accounting.TotalFunds -= upDownAmount.Value; // accounting increase total owed to us accounting.TotalOwedToUs += upDownAmount.Value; } } } } } // if it is charge if (textBoxType.Text == "Charge") { // find the player foreach (PlayersDBDataSet.PlayersRow selectedPlayer in playersDBDataSet.Players) { if (selectedPlayer.PlayerPoolName == currentTransaction.PlayerName) { // player subtract player owes selectedPlayer.PlayerOwes -= upDownAmount.Value; foreach (AccountingDataSet.AccountingRow accounting in accountingDataSet.Accounting) { if (accounting.SeasonName == textBoxSelectedSeason.Text) { // accounting subtract total owed to us accounting.TotalOwedToUs -= upDownAmount.Value; // no point in having a negative amount owed to us if (accounting.TotalOwedToUs <= 0) { accounting.TotalOwedToUs = 0; } } } } } } // if it is credit if (textBoxType.Text == "Credit") { // find the player foreach (PlayersDBDataSet.PlayersRow selectedPlayer in playersDBDataSet.Players) { // player subtract player owes selectedPlayer.PlayerOwes += upDownAmount.Value; } } // if it is charge if (textBoxType.Text == "Interest") { foreach (AccountingDataSet.AccountingRow accounting in accountingDataSet.Accounting) { if (accounting.SeasonName == textBoxSelectedSeason.Text) { // accounting subtract total owed to us //accounting.TotalFunds += upDownInterest.Value; accounting.TotalInterest -= upDownInterest.Value; } } } // make the transaction pay method say REVERSED currentTransaction.Method = "REVERSED"; PopulateReversedTransaction(currentTransaction); } } // if a new transaction was created above by charging the player then do it here. if (newTransaction != null) { newTransaction.PlayerName = transactionPlayer.PlayerPoolName; newTransaction.SeasonName = textBoxSelectedSeason.Text; newTransaction.Type = "Generic Charge"; newTransaction.Method = comboBoxPayMethod.Text; newTransaction.Amount = (double)upDownAmount.Value; newTransaction.Week = comboBoxSelectWeek.Text; newTransaction.Date = DateTime.Now.ToString(); newTransaction.Notes = textBoxTransactionNotes.Text; if (comboBoxPayMethod.Text == "Check") { newTransaction.CheckNumber = textBoxCheckNumber.Text; } transactionsDBDataSet.Transactions.Rows.Add(newTransaction); } // update and save transaction database // update and save players database // update and save accounting database this.Validate(); this.transactionsBindingSource.EndEdit(); this.playersBindingSource.EndEdit(); this.accountingBindingSource.EndEdit(); this.tableAdapterManager1.UpdateAll(this.playersDBDataSet); this.tableAdapterManager2.UpdateAll(this.accountingDataSet); this.tableAdapterManager.UpdateAll(this.transactionsDBDataSet); }
private void GetWeekForWinnings(PlayersDBDataSet.PlayersRow player, decimal amount, bool isLess) { if (isLess) { // need to find out which week is selected and select the right weekly winnings for player if (comboBoxSelectWeek.Text == "Week 01") { player.PlayerWinningsWeek01 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 02") { player.PlayerWinningsWeek02 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 03") { player.PlayerWinningsWeek03 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 04") { player.PlayerWinningsWeek04 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 05") { player.PlayerWinningsWeek05 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 06") { player.PlayerWinningsWeek06 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 07") { player.PlayerWinningsWeek07 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 08") { player.PlayerWinningsWeek08 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 09") { player.PlayerWinningsWeek09 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 10") { player.PlayerWinningsWeek10 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 11") { player.PlayerWinningsWeek11 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 12") { player.PlayerWinningsWeek12 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 13") { player.PlayerWinningsWeek13 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 14") { player.PlayerWinningsWeek14 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 15") { player.PlayerWinningsWeek15 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 16") { player.PlayerWinningsWeek16 -= (int)amount; } if (comboBoxSelectWeek.Text == "Week 17") { player.PlayerWinningsWeek17 -= (int)amount; } } if (!isLess) { if (comboBoxSelectWeek.Text == "Week 01") { player.PlayerWinningsWeek01 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 02") { player.PlayerWinningsWeek02 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 03") { player.PlayerWinningsWeek03 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 04") { player.PlayerWinningsWeek04 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 05") { player.PlayerWinningsWeek05 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 06") { player.PlayerWinningsWeek06 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 07") { player.PlayerWinningsWeek07 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 08") { player.PlayerWinningsWeek08 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 09") { player.PlayerWinningsWeek09 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 10") { player.PlayerWinningsWeek10 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 11") { player.PlayerWinningsWeek11 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 12") { player.PlayerWinningsWeek12 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 13") { player.PlayerWinningsWeek13 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 14") { player.PlayerWinningsWeek14 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 15") { player.PlayerWinningsWeek15 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 16") { player.PlayerWinningsWeek16 += (int)amount; } if (comboBoxSelectWeek.Text == "Week 17") { player.PlayerWinningsWeek17 += (int)amount; } } }
private void GetWeekForWinnings(PlayersDBDataSet.PlayersRow player) { // need to find out which week is selected and select the right weekly winnings for player if (comboBoxSelectWeek.Text == "Week 01") { player.PlayerWinningsWeek01 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 02") { player.PlayerWinningsWeek02 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 03") { player.PlayerWinningsWeek03 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 04") { player.PlayerWinningsWeek04 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 05") { player.PlayerWinningsWeek05 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 06") { player.PlayerWinningsWeek06 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 07") { player.PlayerWinningsWeek07 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 08") { player.PlayerWinningsWeek08 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 09") { player.PlayerWinningsWeek09 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 10") { player.PlayerWinningsWeek10 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 11") { player.PlayerWinningsWeek11 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 12") { player.PlayerWinningsWeek12 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 13") { player.PlayerWinningsWeek13 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 14") { player.PlayerWinningsWeek14 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 15") { player.PlayerWinningsWeek15 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 16") { player.PlayerWinningsWeek16 -= (int)upDownAmount.Value; } if (comboBoxSelectWeek.Text == "Week 17") { player.PlayerWinningsWeek17 -= (int)upDownAmount.Value; } }
private void BuildPicksListBox(PlayersDBDataSet.PlayersRow selectedPlayer) { //http://www.dotnetperls.com/convert-list-string listBoxMyPicksPlayers.Items.Clear(); if (selectedPlayer.PicksWeek01 != "" && comboBoxSelectWeek.Text == "Week 01") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek01.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek02 != "" && comboBoxSelectWeek.Text == "Week 02") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek02.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek03 != "" && comboBoxSelectWeek.Text == "Week 03") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek03.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek04 != "" && comboBoxSelectWeek.Text == "Week 04") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek04.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek05 != "" && comboBoxSelectWeek.Text == "Week 05") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek05.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek06 != "" && comboBoxSelectWeek.Text == "Week 06") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek06.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek07 != "" && comboBoxSelectWeek.Text == "Week 07") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek07.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek08 != "" && comboBoxSelectWeek.Text == "Week 08") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek08.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek09 != "" && comboBoxSelectWeek.Text == "Week 09") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek09.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek10 != "" && comboBoxSelectWeek.Text == "Week 10") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek10.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek11 != "" && comboBoxSelectWeek.Text == "Week 11") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek11.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek12 != "" && comboBoxSelectWeek.Text == "Week 12") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek12.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek13 != "" && comboBoxSelectWeek.Text == "Week 13") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek13.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek14 != "" && comboBoxSelectWeek.Text == "Week 14") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek14.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek15 != "" && comboBoxSelectWeek.Text == "Week 15") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek15.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek16 != "" && comboBoxSelectWeek.Text == "Week 16") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek16.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } if (selectedPlayer.PicksWeek17 != "" && comboBoxSelectWeek.Text == "Week 17") { // split the PicksWeek01 string string[] tempString = selectedPlayer.PicksWeek17.Split(','); // create temp list for those split strings List <string> tempList = new List <string>(tempString); // add each string to the listBox foreach (string item in tempList) { listBoxMyPicksPlayers.Items.Add(item); } } }
// incase i need this somewhere else I wont have to type it again. Displays a players personal info. private void DisplayInfo(PlayersDBDataSet.PlayersRow playerInfo) { // wont always be a message box I need to export something useful to excel / word for use. MessageBox.Show("Player Pool Name: " + playerInfo.PlayerPoolName + "\n" + "Personal Name: " + playerInfo.PlayerPersonalName + "\n" + "Address: " + playerInfo.PlayerAddress + "\n" + "Phone: " + playerInfo.PlayerPhone + "\n" + "Email: " + playerInfo.PlayerEmail + "\n" + "Main Contact Method: " + playerInfo.PlayerContactMethod + "\n" + "Main Payout Method: " + playerInfo.PlayerPayoutMethod); }
// think i am just using the button to do the work. private void EditPlayer() { PlayersDBDataSet.PlayersRow selectedPlayer; if (listBoxPlayersList.SelectedItem == null) { MessageBox.Show("No player selected."); return; } foreach (PlayersDBDataSet.PlayersRow deleteRow in playersDBDataSet.Players.Rows) { // find the selected player if (deleteRow.PlayerPoolName == listBoxPlayersList.SelectedItem.ToString()) { try { // transfer that player to editPlayer so no garbage collection goes on. PlayersDBDataSet.PlayersRow editPlayersDBRow = deleteRow; if (editPlayersDBRow.PlayerPoolName != textBoxPoolNameAdd.Text) { foreach (TransactionsDBDataSet.TransactionsRow transaction in transactionsDBDataSet.Transactions) { if (editPlayersDBRow.PlayerPoolName == transaction.PlayerName) { transaction.PlayerName = textBoxPoolNameAdd.Text; } } this.Validate(); this.transactionsBindingSource.EndEdit(); this.tableAdapterManager2.UpdateAll(this.transactionsDBDataSet); } // this is where the error will occur if there is a duplicate name. editPlayersDBRow.PlayerPoolName = textBoxPoolNameAdd.Text; editPlayersDBRow.PlayerBuyIn = upDownBuyInAmount.Value; editPlayersDBRow.PlayerTotalWins = upDownWins.Value; editPlayersDBRow.PlayerTotalWinnings = upDownCurrentWinnings.Value; editPlayersDBRow.PlayerPersonalName = textBoxNameAdd.Text; editPlayersDBRow.PlayerAddress = textBoxAddressAdd.Text; editPlayersDBRow.PlayerEmail = textBoxEmailAdd.Text; editPlayersDBRow.PlayerPhone = textBoxPhoneAdd.Text; editPlayersDBRow.PlayerContactMethod = textBoxPreferContactAdd.Text; editPlayersDBRow.PlayerPayoutMethod = textBoxPreferPayoutAdd.Text; editPlayersDBRow.Notes = textBoxGroupName.Text; // if group leader is checked then make them the group leader/////////////////****** if (checkBoxIsGroupLeader.Checked) { editPlayersDBRow.IsGroupLeader = true; } else { editPlayersDBRow.IsGroupLeader = false; } // check if they are active or not if (checkBoxIsActive.Checked) { editPlayersDBRow.IsActive = true; } else { editPlayersDBRow.IsActive = false; } editPlayersDBRow.PlayerNotes = textBoxPlayerNotes.Text; // this is in case during an edit a name gets changed. I can update the player list then reselect this player selectedPlayer = editPlayersDBRow; // save changes to the database this.Validate(); this.playersBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.playersDBDataSet); this.tableAdapterManager1.UpdateAll(this.accountingDataSet); // update the list incase name got changed UpdatePlayerList(); foreach (string items in listBoxPlayersList.SelectedItems) { if (items == selectedPlayer.PlayerPoolName) { listBoxPlayersList.SelectedItem = items; } } // Add the new row to the database // playersDBDataSet.Players.AcceptChanges(); MessageBox.Show("Player " + editPlayersDBRow.PlayerPoolName + " changes made sucessfully."); } // this will catch the error above if the unique pool name is already in use. catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } //ClearForm(); << she did not want to clear the form after editing // have to break because listboxSelectedItem goes null. break; } } }
private void AddPlayer() { // make sure a season is created before adding players. if (accountingDataSet.Accounting.Rows.Count == 0) { MessageBox.Show("Please create a Season before adding players."); return; } // try to create the new player try { PlayersDBDataSet.PlayersRow newPlayersDBRow = playersDBDataSet.Players.NewPlayersRow(); // this is where the error will occur if there is a duplicate name. newPlayersDBRow.PlayerPoolName = textBoxPoolNameAdd.Text; newPlayersDBRow.PlayerBuyIn = upDownBuyInAmount.Value; newPlayersDBRow.PlayerTotalWins = upDownWins.Value; newPlayersDBRow.PlayerTotalWinnings = upDownCurrentWinnings.Value; if (checkBoxIsActive.Checked) { newPlayersDBRow.IsActive = true; } else { newPlayersDBRow.IsActive = false; } newPlayersDBRow.PlayerPersonalName = textBoxNameAdd.Text; newPlayersDBRow.PlayerAddress = textBoxAddressAdd.Text; newPlayersDBRow.PlayerEmail = textBoxEmailAdd.Text; newPlayersDBRow.PlayerPhone = textBoxPhoneAdd.Text; newPlayersDBRow.PlayerContactMethod = textBoxPreferContactAdd.Text; newPlayersDBRow.PlayerPayoutMethod = textBoxPreferPayoutAdd.Text; newPlayersDBRow.Notes = textBoxGroupName.Text; newPlayersDBRow.PlayerNotes = textBoxPlayerNotes.Text; // if group leader is checked then make them the group leader////////////////////////////***** if (checkBoxIsGroupLeader.Checked) { newPlayersDBRow.IsGroupLeader = true; } else { newPlayersDBRow.IsGroupLeader = false; } // Add the new row to the database playersDBDataSet.Players.Rows.Add(newPlayersDBRow); MessageBox.Show("Player " + newPlayersDBRow.PlayerPoolName + " has been added sucessfully."); } // this will catch the error above if the unique pool name is already in use. catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); textBoxPoolNameAdd.Enabled = true; } // save changes to the database this.Validate(); this.playersBindingSource.EndEdit(); this.accountingBindingSource.EndEdit(); this.tableAdapterManager1.UpdateAll(this.accountingDataSet); this.tableAdapterManager.UpdateAll(this.playersDBDataSet); }