Esempio n. 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (!this.IsNotNull())
         {
             StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[this.tbStock.Text.Trim()];
             if (stockInformation.Number > 0)
             {
                 long volume = 0L;
                 decimal price = 0m;
                 long.TryParse(this.tbVolume.Text.Replace(",", ""), out volume);
                 decimal.TryParse(this.tbPrice.Text, out price);
                 if (this._stockTHItems.ContainsKey(this.tbStock.Text.Trim()))
                 {
                     frmRiskControl.StockThreasholdItem stockThreasholdItem = this._stockTHItems[this.tbStock.Text.Trim()];
                     stockThreasholdItem.stock = this.tbStock.Text;
                     stockThreasholdItem.side = this.GetSideString();
                     stockThreasholdItem.volume = volume;
                     stockThreasholdItem.price = price;
                 }
                 else
                 {
                     frmRiskControl.StockThreasholdItem stockThreasholdItem = new frmRiskControl.StockThreasholdItem(this.tbStock.Text, this.GetSideString(), price, volume);
                     this._stockTHItems.Add(this.tbStock.Text.Trim(), stockThreasholdItem);
                 }
                 this.UpdateToListView();
                 this.tbStock.Text = string.Empty;
                 this.tbVolume.Text = string.Empty;
                 this.tbPrice.Text = string.Empty;
                 this.SetLabelText("", Color.Black);
                 this.tbStock.Focus();
             }
             else
             {
                 this.SetLabelText("Invalid stock symbol!!!", Color.DarkRed);
                 this.tbStock.Clear();
                 this.tbStock.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         this.ShowError("btnAdd_Click", ex);
     }
 }
Esempio n. 2
0
 private void bgwReloadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     try
     {
         if (this._stockTHItems == null)
         {
             this._stockTHItems = new Dictionary<string, frmRiskControl.StockThreasholdItem>();
         }
         else
         {
             this._stockTHItems.Clear();
         }
         foreach (DataRow dataRow in this.tds.Tables[0].Rows)
         {
             frmRiskControl.StockThreasholdItem value = new frmRiskControl.StockThreasholdItem(dataRow["stock"].ToString(), dataRow["side"].ToString(), Convert.ToDecimal(dataRow["price"].ToString()), Convert.ToInt64(dataRow["quantity"].ToString()));
             string text = dataRow["stock"].ToString();
             if (text == null)
             {
                 goto IL_212;
             }
             if (!(text == "@VALUE"))
             {
                 if (!(text == "@VOLUME"))
                 {
                     if (!(text == "@STSECTOR"))
                     {
                         if (!(text == "@SECTORS"))
                         {
                             if (!(text == "@CHG"))
                             {
                                 goto IL_212;
                             }
                             this.chbChgLimit.Checked = true;
                             this.tbChgLimitValue.Text = dataRow["quantity"].ToString();
                         }
                         else
                         {
                             this.chbSectorLimit.Checked = true;
                             this.tbSectorLimitValue.Text = dataRow["quantity"].ToString();
                         }
                     }
                     else
                     {
                         this.chbStocksInSector.Checked = true;
                         this.tbStocksInSector.Text = dataRow["quantity"].ToString();
                     }
                 }
                 else
                 {
                     this.chbAvg5Volume.Checked = true;
                     this.tbAvg5Volume.Text = dataRow["quantity"].ToString();
                 }
             }
             else
             {
                 this.chbValueLimit.Checked = true;
                 this.tbValueLimitValue.Text = dataRow["quantity"].ToString();
             }
             continue;
             IL_212:
             this._stockTHItems.Add(dataRow["stock"].ToString(), value);
         }
         this.UpdateToListView();
         this.SetLabelText("", Color.Black);
     }
     catch (Exception ex)
     {
         this.ShowError("StockThreshold:RunWorkerCompleted", ex);
     }
     this.IsLoadingData = false;
 }