public void add() { try { //veriables int quan; decimal pps; //parse Int32.TryParse(txtQuantity.Text, out quan); decimal.TryParse(txtPPS.Text, out pps); //new transaction tran = new CTransaction(); //contents tran.StockId = tran.GetGuid(cboTicker.SelectedValue.ToString()); tran.TransDate = DTP.SelectedDate.Value; tran.Quantity = quan; tran.PricePerSharePaid = pps; //if if ((bool)rdoBuy.IsChecked) { tran.Buy = true; } if ((bool)rdoSell.IsChecked) { tran.Buy = false; } //insert tran.Insert(); MessageBox.Show("Transaction successfuly added", "Yay!"); //email CUser u = new CUser(); //u.SendEmail(); //close form this.Close(); // I have decided to not close the form after adding a transaction // for usability reasons. It is annoying to enter multiple transactions // and clicking to open the dialog box again and again txtPPS.Text = string.Empty; txtQuantity.Text = string.Empty; DTP = null; rdoBuy.IsChecked = false; rdoSell.IsChecked = false; } catch (Exception ex) { throw ex; } }
public void InsertTransactionTest() { CTransaction transaction = new CTransaction(Guid.NewGuid(), DateTime.Parse("2014-06-10"), true, 100, 175); transaction.Insert(); CTransaction newTransaction = new CTransaction(); newTransaction.LoadById(transaction.Id); Assert.AreEqual(transaction.TransDate, newTransaction.TransDate); }