Example #1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            // enable changes and clear dataset
            data.AnalysisTable.BeginLoadData();
            data.Clear();

            double   underlying, volatility;
            DateTime end_date = endDateTimePicker.Value;

            try   { volatility = double.Parse(volatilityTextBox.Text.Replace("%", "")) * 0.01; }
            catch { volatility = double.NaN; }

            try   { underlying = double.Parse(underlyingTextBox.Text); }
            catch { underlying = double.NaN; }

            switch (mode)
            {
            case TableMode.MODE_STOCK_PRICE:
                for (underlying = from_price; underlying <= to_price; underlying += reso_price)
                {
                    UpdateCell(-1, underlying, end_date, volatility);
                }
                break;

            case TableMode.MODE_VOLATILITY:
                for (volatility = from_volatility * 0.01; volatility <= to_volatility * 0.01; volatility += reso_volatility * 0.01)
                {
                    UpdateCell(-1, underlying, end_date, volatility);
                }
                break;

            case TableMode.MODE_END_DATE:
                for (end_date = from_date; end_date <= to_date; end_date += reso_date)
                {
                    UpdateCell(-1, underlying, end_date, volatility);
                }
                break;
            }

            // accept changes and end changes session
            data.AcceptChanges();
            data.AnalysisTable.EndLoadData();

            // link to data grid view
            resultsDataGridView.DataSource = data.AnalysisTable;
            resultsDataGridView.Refresh();
        }