Beispiel #1
0
        /// <summary>
        /// Возращает истино, если удалось записать данные
        /// </summary>
        /// <param name="dt">таблица данных</param>
        /// <param name="n">размерность матрицы</param>
        /// <returns></returns>
        public bool FromDataTable(DataTable dt, int n)
        {
            int        j = 0, val = 0;
            List <int> temp_mas = new List <int>();
            List <int> temp_pd  = new List <int>();

            for (int i = 0; i < n; i++)
            {
                j = 0;
                while (j <= i && Prosto.CheckInt(dt.Rows[i][j].ToString(), out val) && val == 0)
                {
                    j++;
                }
                if (j <= i && !Prosto.CheckInt(dt.Rows[i][j].ToString(), out val))
                {
                    return(false);
                }
                else
                {
                    if (j == i + 1)
                    {
                        temp_mas.Add(0);
                        temp_pd.Add(temp_mas.Count - 1);
                    }
                    else
                    {
                        for (int g = j; g <= i; g++)
                        {
                            if (!Prosto.CheckInt(dt.Rows[i][g].ToString(), out val))
                            {
                                return(false);
                            }
                            else
                            {
                                temp_mas.Add(val);
                            }
                        }
                        temp_pd.Add(temp_mas.Count - 1);
                    }
                }
            }
            this.mas = new int[temp_mas.Count];
            this.pd  = new int[temp_pd.Count];
            this.mas = temp_mas.ToArray();
            this.pd  = temp_pd.ToArray();
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// изменение размеров матриц по кнопке
        /// </summary>
        private void ChangeSizes()
        {
            int  n;
            bool res = true;

            res = Prosto.CheckInt(textBox1.Text, out n);
            if (!res)
            {
                MessageBox.Show("Введены неположительные размеры матриц", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (n <= 0)
                {
                    MessageBox.Show("Введены неположительные размеры матриц", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SetMatrixSize(MatrixA, dataGridView1, n);
                    SetMatrixSize(MatrixB, dataGridView2, n);
                }
            }
        }