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); }
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 PopulateReversedTransaction(TransactionsDBDataSet.TransactionsRow transaction) { // if the transaction has been reversed then disable everything if (transaction.Method == "REVERSED") { MessageBox.Show("This transaction has been reversed. Changes can no longer be made to it. Go to accounting and create a new transaction."); textBoxType.Enabled = false; comboBoxPayMethod.Enabled = false; comboBoxSelectWeek.Enabled = false; upDownAmount.Enabled = false; upDownInterest.Enabled = false; textBoxDateTime.Enabled = false; textBoxCheckNumber.Enabled = false; buttonReverseTransaction.Visible = false; buttonSaveChanges.Visible = false; textBoxTransactionNotes.Enabled = false; } else { textBoxType.Enabled = true; comboBoxPayMethod.Enabled = true; comboBoxSelectWeek.Enabled = true; upDownAmount.Enabled = true; upDownInterest.Enabled = true; textBoxDateTime.Enabled = true; textBoxCheckNumber.Enabled = true; buttonReverseTransaction.Visible = true; buttonSaveChanges.Visible = true; textBoxTransactionNotes.Enabled = true; } }
private void CreateTransactionRow(TransactionsDBDataSet.TransactionsRow transaction, string selectedType) { ListViewItem newRow = new ListViewItem(); if (PublicVariables.GetDefaultSeason != null) { if (transaction.SeasonName == PublicVariables.GetDefaultSeason) { newRow.Text = transaction.Id.ToString(); newRow.SubItems.Add(transaction.PlayerName); newRow.SubItems.Add(transaction.Method); if (transaction.Type == "Interest") { newRow.SubItems.Add(transaction.Interest.ToString()); } else { newRow.SubItems.Add(transaction.Amount.ToString()); } if (transaction.Type == "Receive Payment" && selectedType == "Receive Payment" || transaction.Type == "Initial Payment" && selectedType == "Receive Payment") { listViewLedger.Items.Add(newRow); } if (transaction.Type == "Pay Out" && selectedType == "Pay Out") { listViewLedger.Items.Add(newRow); } if (transaction.Type == "Charge" && selectedType == "Charge") { listViewLedger.Items.Add(newRow); } if (transaction.Type == "Interest" && selectedType == "Interest") { listViewLedger.Items.Add(newRow); } if (transaction.Type == "Win Credit" && selectedType == "Win Credit") { listViewLedger.Items.Add(newRow); } } } }
private void CreateProgressiveTransaction() { // make the transaction here TransactionsDBDataSet.TransactionsRow newProgressiveTransaction = transactionsDBDataSet.Transactions.NewTransactionsRow(); // add the data to that row newProgressiveTransaction.PlayerName = "Progressive Pot"; newProgressiveTransaction.SeasonName = PublicVariables.GetDefaultSeason; newProgressiveTransaction.Type = "Progressive"; newProgressiveTransaction.Method = "Auto Progressive"; newProgressiveTransaction.Amount = -(double)upDownPayAmount.Value; newProgressiveTransaction.Week = "Week 17"; newProgressiveTransaction.Date = DateTime.Now.ToString(); newProgressiveTransaction.Notes = "Remove Progressive Amount"; transactionsDBDataSet.Transactions.Rows.Add(newProgressiveTransaction); foreach (AccountingDataSet.AccountingRow accounting in accountingDataSet.Accounting) { if (accounting.SeasonName == PublicVariables.GetDefaultSeason) { accounting.ProgressivePot -= upDownPayAmount.Value; } } }
private void CreateTransactionWeekRow(TransactionsDBDataSet.TransactionsRow transaction, string selectedWeek) { ListViewItem newRow = new ListViewItem(); if (PublicVariables.GetDefaultSeason != null) { if (transaction.SeasonName == PublicVariables.GetDefaultSeason) { newRow.Text = transaction.Id.ToString(); newRow.SubItems.Add(transaction.PlayerName); newRow.SubItems.Add(transaction.Method); if (transaction.Type == "Interest") { newRow.SubItems.Add(transaction.Interest.ToString()); } else { newRow.SubItems.Add(transaction.Amount.ToString()); } if (transaction.Week != "") { if (transaction.Week == "Week 01" && selectedWeek == "Week 01") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 02" && selectedWeek == "Week 02") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 03" && selectedWeek == "Week 03") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 04" && selectedWeek == "Week 04") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 05" && selectedWeek == "Week 05") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 06" && selectedWeek == "Week 06") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 07" && selectedWeek == "Week 07") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 08" && selectedWeek == "Week 08") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 09" && selectedWeek == "Week 09") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 10" && selectedWeek == "Week 10") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 11" && selectedWeek == "Week 11") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 12" && selectedWeek == "Week 12") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 13" && selectedWeek == "Week 13") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 14" && selectedWeek == "Week 14") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 15" && selectedWeek == "Week 15") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 16" && selectedWeek == "Week 16") { listViewTransactionWeek.Items.Add(newRow); } if (transaction.Week == "Week 17" && selectedWeek == "Week 17") { listViewTransactionWeek.Items.Add(newRow); } } } } }
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 PostAccounting(string playerName) { // if there is a buy in amount entered the charge it if (upDownBuyInAmount.Value > 0) { TransactionsDBDataSet.TransactionsRow newTransaction = transactionsDBDataSet.Transactions.NewTransactionsRow(); newTransaction.PlayerName = playerName; newTransaction.SeasonName = PublicVariables.GetDefaultSeason; newTransaction.Type = "Charge"; newTransaction.Method = "Buy in Charge"; newTransaction.Amount = (double)upDownBuyInAmount.Value; if (PublicVariables.GetDefaultWeek != null) { newTransaction.Week = PublicVariables.GetDefaultWeek; } newTransaction.Date = DateTime.Now.ToString(); newTransaction.Notes = "Charge created when adding player"; transactionsDBDataSet.Transactions.Rows.Add(newTransaction); } // if there is a receive payment amount if (upDownReceiveAmount.Value > 0) { TransactionsDBDataSet.TransactionsRow newTransaction2 = transactionsDBDataSet.Transactions.NewTransactionsRow(); TransactionsDBDataSet.TransactionsRow newTransaction3 = transactionsDBDataSet.Transactions.NewTransactionsRow(); newTransaction2.PlayerName = playerName; newTransaction2.SeasonName = PublicVariables.GetDefaultSeason; newTransaction2.Type = "Receive Payment"; newTransaction2.Method = comboBoxPayMethod.Text; if (comboBoxPayMethod.Text == "Check") { newTransaction2.CheckNumber = textBoxCheckNumber.Text; } newTransaction2.Amount = -(double)upDownReceiveAmount.Value; if (PublicVariables.GetDefaultWeek != null) { newTransaction2.Week = PublicVariables.GetDefaultWeek; } newTransaction2.Date = DateTime.Now.ToString(); newTransaction2.Notes = "Receipt created when adding player"; newTransaction3.PlayerName = "House"; newTransaction3.SeasonName = textBoxSelectedSeason.Text; newTransaction3.Type = "Interest"; newTransaction3.Method = comboBoxPayMethod.Text; newTransaction3.Interest = 3; if (PublicVariables.GetDefaultWeek != null) { newTransaction3.Week = PublicVariables.GetDefaultWeek; } newTransaction3.Date = DateTime.Now.ToString(); newTransaction3.Notes = playerName; transactionsDBDataSet.Transactions.Rows.Add(newTransaction2); transactionsDBDataSet.Transactions.Rows.Add(newTransaction3); } this.Validate(); this.transactionsBindingSource.EndEdit(); this.tableAdapterManager2.UpdateAll(this.transactionsDBDataSet); }