コード例 #1
0
        private void Form4_test_Load(object sender, EventArgs e)
        {
            comboBox_year.SelectedText = "2015";
            checkBox1_index.Enabled    = false;
            checkBox_sp.Enabled        = false;
            selectedAssets             = new Asset[Program.form.dataGridView2.Rows.Count];
            constraints = new double[Program.form.dataGridView2.Rows.Count];

            int j = 0;

            foreach (DataGridViewRow t in Program.form.dataGridView2.Rows)
            {
                Asset a = (Asset)t.Cells[0].Value;
                selectedAssets[j] = a;
                constraints[j]    = Convert.ToDouble(t.Cells[1].Value.ToString().Replace('.', ','));

                j++;
            }
            j = 0;
            dataGridView.Rows.Clear();
            dataGridView.Rows.Add(Program.form.dataGridView2.Rows.Count + 1);
            foreach (DataGridViewRow a in Program.form.dataGridView2.Rows)
            {
                Asset asset = (Asset)a.Cells[0].Value;

                dataGridView[0, j].Value = asset.ToString();
                j++;
            }
            dataGridView[0, j].Value = "СУММА";

            DoList();

            /*
             * try
             * {
             *  DoList();
             * }
             * catch (System.IO.IOException ex)
             * {
             *
             *  string[] exception = ex.Message.Split(' ');
             *  DialogResult dr = MessageBox.Show("Ошибка при считывании файла " + exception[exception.Length - 1] + ". Замените этот актив или попробуйте еще раз.\nПовторить попытку?",
             *      "Ошибка!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             *  if (dr == System.Windows.Forms.DialogResult.Retry) Form4_test_Load(sender, e);
             *  else this.Close();
             * }
             * catch (Exception ex)
             * {
             *  string[] exception = ex.Message.Split(' ');
             *  DialogResult dr = MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             *  if (dr == System.Windows.Forms.DialogResult.Retry) Form4_test_Load(sender, e);
             *  else this.Close();
             * }*/
        }
コード例 #2
0
        public void DoTable(Portfolio res)
        {
            int    j   = 0;
            double sum = 0;

            dataGridView.Rows.Clear();
            dataGridView.Rows.Add(Program.form.dataGridView2.Rows.Count + 1);
            foreach (DataGridViewRow a in Program.form.dataGridView2.Rows)
            {
                Asset asset = (Asset)a.Cells[0].Value;
                dataGridView[0, j].Value = asset.ToString();
                dataGridView[1, j].Value = res.ConvertPortfolio()[j] + "%";
                j++;
            }
            sum = res.GetSum;
            dataGridView[1, j].Value = sum + "%";
            label_stand.Text         = res.StandDev + "%";
            label_profitValue.Text   = res.Profit + "%";
            label_riskValue.Text     = res.Risk + "%";
            // label_cost.Text =string.Format("{0:###,###.##} руб.", Math.Round(res.Cost));
        }