public sellingOrder(Object sub) { concreteSub = (RealtimeData)sub; InitializeComponent(); foreach (company company in concreteSub.getCompanies()) { this.comboBox1.Items.Add(company.Name); } comboBox1.SelectedIndex = 0; }
public void update() { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); foreach (company company in StockMarket.getCompanies()) { if (company.Name == companyName) { newCompany = company; break; } } int i = 0; foreach (Order buyOrder in newCompany.getBuyOrders()) { string[] row1 = { buyOrder.Size.ToString(), buyOrder.Price.ToString(), null, null }; dataGridView1.Rows.Add(row1); i++; if (i == 10) { break; } } for (int j = 0; j < 10; j++) { string[] row1 = { null, null, null, null }; dataGridView1.Rows.Add(row1); } int k = 0; foreach (Order sellOrder in newCompany.getSellOrders()) { dataGridView1[2, k].Value = sellOrder.Price.ToString(); dataGridView1[3, k].Value = sellOrder.Size.ToString(); k++; if (k == 10) { break; } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { foreach (company company in concreteSub.getCompanies()) { int i = 0; if (comboBox1.SelectedIndex == i) { newCompany = company; break; } else { i++; } } }
public void watchSSMenu(ToolStripMenuItem options) { ToolStripMenuItem subMenu; List <company> companies = concreteSub.getCompanies(); foreach (company company in companies) { if (options.Name == "marketByPriceToolStripMenuItem1") { subMenu = new ToolStripMenuItem(company.Name, null, marketByPriceToolStripMenuItem_Click); } else { subMenu = new ToolStripMenuItem(company.Name, null, marketByOrderToolStripMenuItem_Click); } options.DropDownItems.Add(subMenu); } }
public void update() { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); List <company> companies = stockMarket.getCompanies(); int i = 0; foreach (company company in companies) { double changeNet; double changePercent; int volume; Bitmap images; images = noChange; if (company.LastSale == 0) { changeNet = 0; changePercent = 0; } else { changeNet = company.LastSale - company.OpenPrice; if (changeNet < 0) { images = downImage; } else if (changeNet > 0) { images = upImage; } changeNet = Math.Abs(company.LastSale - company.OpenPrice); changePercent = (changeNet / company.OpenPrice) * 100; } volume = company.getVolume(); string[] row = { company.Name, company.Symbol, company.OpenPrice.ToString(), company.LastSale.ToString(), changeNet.ToString(), null, changePercent.ToString("00.00"), volume.ToString() }; dataGridView1.Rows.Add(row); dataGridView1[5, i].Value = images; i++; } }
public void update() { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); foreach (company company in StockMarket.getCompanies()) { if (company.Name == companyName) { newCompany = company; break; } } int[] number = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Double[] price = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int[] volume = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int index = 0; var firstBuyPrice = newCompany.getBuyOrders().FirstOrDefault(); if (firstBuyPrice != null) { price[index] = firstBuyPrice.Price; } foreach (Order B in newCompany.getBuyOrders()) { if (price[index] == B.Price) { number[index]++; volume[index] += B.Size; } else { index++; number[index] = 1; price[index] = B.Price; volume[index] = B.Size; } } for (int j = 0; j < 10; j++) { string[] row1 = { (price[j] == 0 ? "" : number[j].ToString()), (volume[j] == 0 ? "" :volume[j].ToString()), (price[j] == 0 ? "" : price[j].ToString()) }; dataGridView1.Rows.Add(row1); } int[] number2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Double[] price2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int[] volume2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int index2 = 0; var firstSellPrice = newCompany.getSellOrders().FirstOrDefault(); if (firstSellPrice != null) { price[index2] = firstSellPrice.Price; } foreach (Order S in newCompany.getSellOrders()) { if (price2[index2] == S.Price) { number2[index2]++; volume2[index2] += S.Size; } else { index2++; number2[index2] = 1; price2[index2] = S.Price; volume2[index2] = S.Size; } } for (int k = 0; k < 10; k++) { dataGridView1[3, k].Value = (price2[k] == 0 ? "" : price2[k].ToString()); dataGridView1[4, k].Value = (volume2[k] == 0 ? "" : volume2[k].ToString()); dataGridView1[5, k].Value = (price2[k] == 0 ? "" : number2[k].ToString()); } }