private void currentStatusToolStripMenuItem_Click(object sender, EventArgs e) { StatisticInfo dlg = new StatisticInfo(); //refresh current data RefreshObservedPool(); RefreshLongTermPool(); RefreshShortTermPool(); RefreshTacticalPool(); //calculate statistic data decimal longtermprofit = m_statData.LongTermProfit; decimal shorttermprofit = m_statData.ShortTermProfit; decimal tacticalprofit = m_statData.TacticalProfit; StockPool.LongTermTableDataTable longdt = (StockPool.LongTermTableDataTable)dataGridViewObserved.DataSource; foreach (StockPool.LongTermTableRow row in longdt.Rows) { m_statData.LongTermValue += row.CurrentPrice * row.Amount; longtermprofit += (row.CurrentPrice - row.CostPrice) * row.Amount; } StockPool.TacticalTableDataTable tacticaldt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource; foreach (StockPool.TacticalTableRow row in tacticaldt.Rows) { m_statData.TacticalValue += row.CurrentPrice * row.DealCount; tacticalprofit += (row.CurrentPrice - row.CostPrice) * row.DealCount; } StockPool.ShortTermTableDataTable shortdt = (StockPool.ShortTermTableDataTable)dataGridViewTactical.DataSource; foreach (StockPool.ShortTermTableRow row in shortdt.Rows) { m_statData.ShortTermValue += row.CurrentPrice * row.Amount; shorttermprofit += (row.CurrentPrice - row.CostPrice) * row.Amount; } //display dlg.textBoxLongTermValue.Text = m_statData.LongTermValue.ToString(); dlg.textBoxLongProfit.Text = longtermprofit.ToString(); dlg.textBoxLongLeftCash.Text = m_statData.LongTermLeftCash.ToString(); dlg.textBoxLongAvailable.Text = m_statData.LongTermAvailableCash.ToString(); dlg.textBoxTacticalValue.Text = m_statData.TacticalValue.ToString(); dlg.textBoxTacticalProfit.Text = tacticalprofit.ToString(); dlg.textBoxShortValue.Text = m_statData.ShortTermValue.ToString(); dlg.textBoxShortProfit.Text = shorttermprofit.ToString(); dlg.textBoxShortLeft.Text = m_statData.ShortTermLeftCash.ToString(); dlg.textBoxTotalLeft.Text = (m_statData.LongTermLeftCash + m_statData.ShortTermLeftCash).ToString(); m_statData.TotalAsset = m_statData.LongTermLeftCash + m_statData.ShortTermLeftCash + m_statData.LongTermValue + m_statData.TacticalValue + m_statData.ShortTermValue; dlg.textBoxTotalAsset.Text = m_statData.TotalAsset.ToString(); m_statData.TotalProfit = longtermprofit + tacticalprofit + shorttermprofit; dlg.textBoxTotalProfit.Text = m_statData.TotalProfit.ToString(); dlg.textBoxCostCash.Text = m_statData.CostCash.ToString(); dlg.textBoxNetCount.Text = m_statData.curNetCount.ToString(); m_statData.curNetValue = m_statData.TotalAsset / m_statData.curNetCount; dlg.textBoxNetValue.Text = m_statData.curNetValue.ToString(); dlg.ShowDialog(); }
private void currentStatusToolStripMenuItem_Click(object sender, EventArgs e) { StatisticInfo dlg = new StatisticInfo(); //refresh current data RefreshObservedPool(); RefreshLongTermPool(); RefreshShortTermPool(); RefreshTacticalPool(); //calculate statistic data decimal longtermprofit = m_statData.LongTermProfit; decimal shorttermprofit = m_statData.ShortTermProfit; decimal tacticalprofit = m_statData.TacticalProfit; StockPool.LongTermTableDataTable longdt = (StockPool.LongTermTableDataTable)dataGridViewObserved.DataSource; foreach (StockPool.LongTermTableRow row in longdt.Rows) { m_statData.LongTermValue += row.CurrentPrice * row.Amount; longtermprofit += (row.CurrentPrice - row.CostPrice) * row.Amount; } StockPool.TacticalTableDataTable tacticaldt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource; foreach (StockPool.TacticalTableRow row in tacticaldt.Rows) { m_statData.TacticalValue += row.CurrentPrice * row.DealCount; tacticalprofit += (row.CurrentPrice - row.CostPrice) * row.DealCount; } StockPool.ShortTermTableDataTable shortdt = (StockPool.ShortTermTableDataTable)dataGridViewTactical.DataSource; foreach (StockPool.ShortTermTableRow row in shortdt.Rows) { m_statData.ShortTermValue += row.CurrentPrice * row.Amount; shorttermprofit += (row.CurrentPrice - row.CostPrice) * row.Amount; } //display dlg.textBoxLongTermValue.Text = m_statData.LongTermValue.ToString(); dlg.textBoxLongProfit.Text = longtermprofit.ToString(); dlg.textBoxLongLeftCash.Text = m_statData.LongTermLeftCash.ToString(); dlg.textBoxLongAvailable.Text = m_statData.LongTermAvailableCash.ToString(); dlg.textBoxTacticalValue.Text = m_statData.TacticalValue.ToString(); dlg.textBoxTacticalProfit.Text = tacticalprofit.ToString(); dlg.textBoxShortValue.Text = m_statData.ShortTermValue.ToString(); dlg.textBoxShortProfit.Text = shorttermprofit.ToString(); dlg.textBoxShortLeft.Text = m_statData.ShortTermLeftCash.ToString(); dlg.textBoxTotalLeft.Text = (m_statData.LongTermLeftCash + m_statData.ShortTermLeftCash).ToString(); m_statData.TotalAsset = m_statData.LongTermLeftCash + m_statData.ShortTermLeftCash + m_statData.LongTermValue + m_statData.TacticalValue + m_statData.ShortTermValue; dlg.textBoxTotalAsset.Text = m_statData.TotalAsset.ToString(); m_statData.TotalProfit = longtermprofit + tacticalprofit + shorttermprofit; dlg.textBoxTotalProfit.Text = m_statData.TotalProfit.ToString(); dlg.textBoxCostCash.Text = m_statData.CostCash.ToString(); dlg.textBoxNetCount.Text = m_statData.curNetCount.ToString(); m_statData.curNetValue = m_statData.TotalAsset / m_statData.curNetCount; dlg.textBoxNetValue.Text = m_statData.curNetValue.ToString(); dlg.ShowDialog(); }