Example #1
0
        private void btnEnterAmount_Click(object sender, EventArgs e)
        {
            double amount;

            try
            {
                if (!Double.TryParse(txtParticipatingAmount.Text, out amount) || (amount <= 0))
                {
                    throw new Exception("Please enter a value amount!");
                }
                var source = comboSelectParticipant.SelectedItem as Participant;
                ParticipantEntryHistory pHistory = new ParticipantEntryHistory
                {
                    UserName    = source.UserName,
                    EntryDate   = DateTime.Now,
                    EntryAmount = Convert.ToDouble(txtParticipatingAmount.Text)
                };

                dataAccess.SaveParticipantEntry(pHistory);
                txtParticipatingAmount.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error entering amount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
 /// <summary>
 /// saves participants deposit to database in ParticipantEntryHistory table
 /// </summary>
 /// <param name="pHistory"></param>
 /// <returns>true if saved</returns>
 public bool SaveParticipantEntry(ParticipantEntryHistory pHistory)
 {
     using (IDbConnection cnn = new SQLiteConnection(GetConnectionString()))
     {
         string query = $"insert into ParticipantEntryHistory (EntryID, EntryDate, EntryAmount, UserName )" +
                        $"values (@EntryID, @EntryDate, @EntryAmount, @UserName)";
         cnn.Execute(query, pHistory);
     }
     UpdateQueuePositionToHighest(pHistory.UserName);
     OnParticipantDataUpdated();
     return(true);
 }