Esempio n. 1
0
        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;
            }
        }