private void UpdateStock() { if (Mode == "Price") { double price = -1; double.TryParse(txtPrice.Text, out price); if (price < 0) { MessageBox.Show(price.ToString() + " is an invalid price"); return; } rt.Price = price; StockPriceFactory spf = new StockPriceFactory(); StockPriceObject spo = new StockPriceObject(); spo.Cusip = txtCusip.Text; spo.Price = price; spo.PriceDate = DateTime.Today; try { spf.Delete(spo); spf.Insert(spo); } catch (Exception e) { MessageBox.Show("Problem Updating Price: \r\n" + e.ToString()); } try { DtcChannel.Instance.StockPriceUpdated(spo); } catch (Exception) { } } else if (Mode == "Ticker") { rt.Cusip = txtCusip.Text; rt.Company = txtDescription.Text; rt.Ticker = txtTicker.Text; StockInfoFactory sif = new StockInfoFactory(); StockInfoObject sio = new StockInfoObject(); sio.Cusip = txtCusip.Text; sio.Name = txtDescription.Text.ToUpper(); sio.Ticker = txtTicker.Text.ToUpper(); try { sif.Delete(sio); sif.Insert(sio); } catch (Exception e) { MessageBox.Show("Problem Updating Stock: \r\n" + e.ToString()); } try { DtcChannel.Instance.StockInfoUpdated(sio); } catch (Exception) { } } this.Close(); }
public StockInfoUpdateEventArgs(StockInfoObject si) { StockInfo = si; }
public void StockInfoUpdated(StockInfoObject si) { OnStockInfoUpdated(new StockInfoUpdateEventArgs(si)); }