Beispiel #1
0
        private void оценкаНадежностиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 form = new Form2();

            form.dtGrdVw2.ColumnCount = 4;
            form.dtGrdVw2.RowCount    = 4;
            form.l_o.Text             = "Скорость";
            form.mas_car = new string[]
            {
                "Лев",
                "Тигр",
                "Лошадь",
                "Кенгуру"
            };
            form.ShowDialog();
            Form1.S        item = default(Form1.S);
            List <Form1.S> list = new List <Form1.S>();

            for (int i = 0; i < 4; i++)
            {
                item.ZN  = Convert.ToDouble(form.dtGrdVw2[4, i].Value);
                item.str = form.mas_car[i];
                list.Add(item);
            }
            this.LL.Add(list);
            this.L_str.Add("Скорость");
            this.оценкаНадежностиToolStripMenuItem.Enabled    = false;
            this.оценкаЕкономичностиToolStripMenuItem.Enabled = true;
        }
Beispiel #2
0
        private void результатToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.dtGdVw1.Visible               = true;
            this.dtGdVw1.ColumnCount           = 4;
            this.dtGdVw1.RowCount              = 5;
            this.dtGdVw1.Columns[0].HeaderText = "Содержание в $";
            this.dtGdVw1.Columns[1].HeaderText = "Содержание нормованная";
            this.dtGdVw1.Columns[2].HeaderText = "Функция полезности";
            this.dtGdVw1.Columns[3].HeaderText = "Отношение";
            double[] array = new double[]
            {
                400.0,
                700.0,
                200.0,
                300.0
            };
            Form1.S item = default(Form1.S);
            double  num  = 0.0;

            for (int i = 0; i < 4; i++)
            {
                item.ZN  = array[i];
                item.str = this.mas_car[i];
                this.L_car_maney.Add(item);
                num += array[i];
            }
            item.ZN  = num;
            item.str = "Summa";
            this.L_car_maney.Add(item);
            this.LL_R.Add(this.L_car_maney);
            double num2 = 0.0;

            for (int i = 0; i < 4; i++)
            {
                item.ZN  = Math.Round(this.L_car_maney[i].ZN * 1.0 / num, 3);
                item.str = this.mas_car[i];
                this.L_car_maney_n.Add(item);
                num2 += this.L_car_maney_n[i].ZN;
            }
            item.ZN  = num2;
            item.str = "Summa";
            this.L_car_maney_n.Add(item);
            this.LL_R.Add(this.L_car_maney_n);
            this.LL_R.Add(this.Integr_oc);
            List <Form1.S> list = new List <Form1.S>();

            for (int i = 0; i < 4; i++)
            {
                item.ZN  = Math.Round(Math.Round(this.Integr_oc[i].ZN * 1.0 / this.L_car_maney_n[i].ZN, 3), 3);
                item.str = this.mas_car[i];
                list.Add(item);
            }
            this.LL_R.Add(list);
            for (int j = 0; j < this.LL_R.Count; j++)
            {
                for (int i = 0; i < this.LL_R[j].Count; i++)
                {
                    this.dtGdVw1.Rows[i].HeaderCell.Value = this.LL_R[j][i].str;
                    this.dtGdVw1[j, i].Value = Convert.ToString(this.LL_R[j][i].ZN);
                }
            }
            List <int> list2 = this.Sort(list);

            for (int j = 0; j < this.LL_R.Count; j++)
            {
                for (int i = 0; i < list2.Count; i++)
                {
                    this.dtGdVw1.Rows[i].HeaderCell.Value = this.LL_R[j][list2[i]].str;
                    this.dtGdVw1[j, i].Value = Convert.ToString(this.LL_R[j][list2[i]].ZN);
                }
            }
            this.результатToolStripMenuItem.Enabled = false;
        }
Beispiel #3
0
        private void весаКритериевToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.dataGridView1.Visible = true;
            Form2 form = new Form2();

            form.dtGrdVw2.ColumnCount = this.L_str.Count;
            if (this.L_str.Count == 0)
            {
                MessageBox.Show("Введите данные оценок");
            }
            else
            {
                form.dtGrdVw2.RowCount = this.L_str.Count;
                form.l_o.Text          = "Веса критериев";
                form.mas_car           = new string[this.L_str.Count];
                for (int i = 0; i < this.L_str.Count; i++)
                {
                    form.mas_car[i] = this.L_str[i];
                }
                form.ShowDialog();
                Form1.S        item = default(Form1.S);
                List <Form1.S> list = new List <Form1.S>();
                for (int i = 0; i < this.L_str.Count; i++)
                {
                    item.ZN  = Convert.ToDouble(form.dtGrdVw2[this.L_str.Count, i].Value);
                    item.str = form.mas_car[i];
                    list.Add(item);
                }
                this.dataGridView1.ColumnCount = this.LL.Count + 1;
                this.dataGridView1.RowCount    = this.LL[0].Count;
                for (int j = 0; j < this.LL.Count; j++)
                {
                    this.dataGridView1.Columns[j].HeaderText = this.L_str[j];
                    for (int i = 0; i < this.LL[j].Count; i++)
                    {
                        this.dataGridView1.Rows[i].HeaderCell.Value = this.LL[j][i].str;
                        this.dataGridView1[j, i].Value = Convert.ToString(this.LL[j][i].ZN);
                    }
                }
                this.Integr_oc = new List <Form1.S>();
                this.dataGridView1.Columns[this.LL.Count].HeaderText = "Функция полезности";
                double num = 0.0;
                for (int j = 0; j < this.LL[0].Count; j++)
                {
                    double num2 = 0.0;
                    for (int i = 0; i < this.LL.Count; i++)
                    {
                        num2 += Math.Round(this.LL[i][j].ZN * list[i].ZN, 3);
                    }
                    item     = default(Form1.S);
                    item.ZN  = num2;
                    item.str = this.LL[0][j].str;
                    this.Integr_oc.Add(item);
                    num += num2;
                    this.dataGridView1[this.LL.Count, j].Value = Convert.ToString(num2);
                }
                item.ZN  = num;
                item.str = "Summa";
                this.Integr_oc.Add(item);
                this.результатToolStripMenuItem.Enabled     = true;
                this.весаКритериевToolStripMenuItem.Enabled = false;
            }
        }