private void DirtyPriceBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { try { if (double.Parse(CleanPriceBox.Text) < 0) { MessageBox.Show("Clean Price cannot be less than 0."); } else { var client = new WebClient(); client.Proxy = null; Stream stream = client.OpenRead("http://192.168.137.158:8080/EbondSharkWeb/rest/ebonds/bonddetails?ISIN=" + bond.isin.ToString() + "&Qty=" + QuantityBox.Text + "¶m=DirtyPrice&value=" + DirtyPriceBox.Text.ToString()); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ComputationResult)); ComputationResult result = (ComputationResult)serializer.ReadObject(stream); DesiredYieldBox.Text = result.desiredYield.ToString(); CleanPriceBox.Text = result.cleanPrice.ToString(); DirtyPriceBox.Text = result.dirtyPrice.ToString(); AccruedAmountLabel.Content = result.accruedAmount.ToString(); SettlementAmountLabel.Content = result.settlementAmount.ToString(); } } catch { MessageBox.Show("Limit exceeded"); } } }
public TradeWindow(Bond selectedBond) { InitializeComponent(); bond = selectedBond; ISINLabel.Content = selectedBond.isin.ToString(); IssuerLabel.Content = selectedBond.issuerName.ToString(); YieldLabel.Content = selectedBond.yield.ToString(); if (selectedBond.change > 0) { ChangeLabel.Content = selectedBond.change.ToString(); this.ChangeLabel.Foreground = System.Windows.Media.Brushes.Green; GreenArrow.Visibility = Visibility.Visible; } else if (selectedBond.change == 0) { ChangeLabel.Content = selectedBond.change.ToString(); this.ChangeLabel.Foreground = System.Windows.Media.Brushes.Yellow; } else { ChangeLabel.Content = selectedBond.change.ToString(); this.ChangeLabel.Foreground = System.Windows.Media.Brushes.Red; RedArrow.Visibility = Visibility.Visible; } if (selectedBond.category == "corp") { CategoryLabel.Content = "Corporate"; } else { CategoryLabel.Content = "Government"; } IssueDateLabel.Content = selectedBond.Issue_Date.Date; MaturityDateLabel.Content = selectedBond.MaturityDate.Date; CouponRateLabel.Content = selectedBond.coupon; CouponFrequencyLabel.Content = selectedBond.couponFrequency; CurrencyLabel.Content = selectedBond.currency; Field_Label.Content = selectedBond.field; HighLabel.Content = selectedBond.high; LowLabel.Content = selectedBond.low; LastLabel.Content = selectedBond.last; ComputationResult result = new ComputationResult(); try { var client = new WebClient(); client.Proxy = null; Stream stream = client.OpenRead("http://192.168.137.158:8080/EbondSharkWeb/rest/ebonds/bonddetails?ISIN=" + selectedBond.isin.ToString() + "&Qty=" + "1" + "¶m=Yield&value=" + selectedBond.yield.ToString()); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ComputationResult)); result = (ComputationResult)serializer.ReadObject(stream); } catch { MessageBox.Show("Rest is resting"); } DesiredYieldBox.Text = result.desiredYield.ToString(); CleanPriceBox.Text = result.cleanPrice.ToString(); DirtyPriceBox.Text = result.dirtyPrice.ToString(); AccruedAmountLabel.Content = result.accruedAmount.ToString(); SettlementAmountLabel.Content = result.settlementAmount.ToString(); }