示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (drawing is null)
            {
                drawing          = new DrawingTree();
                DrawingTree.draw = true;
            }

            drawing.DrawTree();
            drawing.Show();
            drawing = null;
        }
示例#2
0
        private void button5_Click(object sender, EventArgs e)
        {
            try {
                List <string> listTemp = new List <string>();

                for (int i = 0; i < 4; i++)
                {
                    listTemp.Add(dataGridView2.Rows[i + 1].Cells[0].Value.ToString());
                }
                for (int i = 0; i < Company.Prices.Length; i++)
                {
                    Company.Prices[i] = Convert.ToSingle(this.dataGridView3.Rows[i].Cells[0].Value.ToString().Replace(".", ","));
                }

                Predictions.ForecastNii = (from item in data["forecast"] select Convert.ToSingle(item.Replace(".", ","))).ToArray();
                Company.CountProduct    = Convert.ToSingle(this.textBox2.Text.Replace(".", ","));

                data[mark == 0 ? "forecast" : "chance"] = listTemp;
                bank = new Bank()
                {
                    money   = Floor(Convert.ToSingle(dataGridView1.Rows[1].Cells[0].Value.ToString().Replace(".", ","))),
                    precent = Floor(Convert.ToSingle(dataGridView1.Rows[2].Cells[0].Value.ToString().Replace(".", ","))),
                    dateAvr = Floor(Convert.ToSingle(dataGridView1.Rows[3].Cells[0].Value.ToString().Replace(".", ",")))
                };

                List <float> changes = new List <float>();
                for (int i = 0; i < 3; i++)
                {
                    changes.Add(Convert.ToSingle(data["chance"][i].Replace(".", ",")));
                }

                company = new Company()
                {
                    changes = changes.ToArray()
                };

                this.firstNode.Text            = $"{textGroup} при {Predictions.ForecastNii[0]}";
                this.secondNode.Text           = $"{textGroup} при {Predictions.ForecastNii[1]}";
                this.thirdNode.Text            = $"{textGroup} при {Predictions.ForecastNii[2]}";
                this.notBuyProdectionNode.Text = $"{textGroup} без покупки прогнозов";
            } catch (NullReferenceException) {
                MessageBox.Show("Ошибка:\n Введите данные");
                return;
            } catch (FormatException ex) {
                MessageBox.Show("Ошибка:\n " + ex.Message);
                return;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            this.secondNode.Visible        = secondNodeMinChance.Visible = secondNodeSrChance.Visible = secondNodeMaxChance.Visible =
                secondNodeMinMoney.Visible = secondNodeSrMoney.Visible = secondNodeMaxMoney.Visible = label4.Visible =
                    label5.Visible         = mountAvr.Visible = martPrice.Visible = this.fullSumLabel.Visible = this.fullSum.Visible = true;

            drawing          = new DrawingTree();
            DrawingTree.draw = true;

            fileWriter.Clear();
            companies.Add(company);

            InsertChance();
            Calculate();

            companies.Clear();
            prodecties.Clear();
            Predictions.M.Clear();
        }