public void Add() { try { //veriables decimal quan; double pps; //parse decimal.TryParse(txtQuantity.Text, out quan); double.TryParse(txtPPS.Text, out pps); //new transaction CCryptoTran tran = new CCryptoTran(); //contents tran.StockId = tran.GetGuid(cboName.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(cboName.SelectedValue.ToString()); 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; } }
// GET: CTransaction/Delete/5 public ActionResult Delete(Guid id) { if (Session["user"] != null) { CCryptoTran t = new CCryptoTran(); t.LoadById(id); return(View(t)); } return(RedirectToAction("Login", "Login")); }
public ActionResult Delete(Guid id, CCryptoTran collection) { try { // TODO: Add delete logic here collection.Delete(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void Refresh() { decimal runningTotal = 0; try { CStockList stocks = new CStockList(); stocks.Load(); dgStocks.ItemsSource = stocks; //get total foreach (var s in stocks) { CTransaction t = new CTransaction(); runningTotal = t.GetTotal(s.Ticker) + runningTotal; } lblTotal.Content = runningTotal.ToString("c2"); dgStocks.Columns[4].Header = "Quantity"; dgStocks.Columns[5].Header = "Position Value"; dgStocks.Columns[0].Visibility = Visibility.Hidden; dgStocks.Columns[1].Visibility = Visibility.Hidden; } catch (Exception ex) { } try { CTransactionList trans = new CTransactionList(); trans.Load(); dgTransactions_Copy.ItemsSource = trans; dgTransactions_Copy.Columns[0].Header = "Stock"; dgTransactions_Copy.Columns[3].Header = "Date of Transaction"; dgTransactions_Copy.Columns[4].Header = "Buy"; dgTransactions_Copy.Columns[5].Header = "Quantity"; dgTransactions_Copy.Columns[6].Header = "Price Per Share"; dgTransactions_Copy.Columns[1].Visibility = Visibility.Hidden; dgTransactions_Copy.Columns[2].Visibility = Visibility.Hidden; } catch (Exception ex) { } try { CCryptoList stocks = new CCryptoList(); stocks.Load(); dgCrypto1.ItemsSource = stocks; //get total foreach (var s in stocks) { CCryptoTran t = new CCryptoTran(); decimal.TryParse(t.GetTotal(s.Ticker).ToString(), out decimal g); runningTotal = g + runningTotal; } lblTotal.Content = runningTotal.ToString("c2"); dgCrypto1.Columns[4].Header = "Quantity"; dgCrypto1.Columns[5].Header = "Position Value"; dgCrypto1.Columns[0].Visibility = Visibility.Hidden; dgCrypto1.Columns[1].Visibility = Visibility.Hidden; } catch (Exception ex) { } try { CCryptoTranList crypto = new CCryptoTranList(); crypto.Load(); dgCrypto_Copy.ItemsSource = crypto; dgCrypto_Copy.Columns[0].Header = "Currency"; dgCrypto_Copy.Columns[3].Header = "Transaction Date"; dgCrypto_Copy.Columns[4].Header = "Buy"; dgCrypto_Copy.Columns[5].Header = "Quantity"; dgCrypto_Copy.Columns[6].Header = "Price Per Share"; dgCrypto_Copy.Columns[1].Visibility = Visibility.Hidden; dgCrypto_Copy.Columns[2].Visibility = Visibility.Hidden; } catch (Exception) { } }