Beispiel #1
0
 public void dg_to_dl()
 {
     for (int i = 0; i < dg_input.Rows.Count - 1; ++i)
     {
         dl.add_detail(str_to_det((dg_input.Rows[i].Cells[0].Value + "\t" + dg_input.Rows[i].Cells[1].Value.ToString()), i));
     }
 }
Beispiel #2
0
        private void button_load_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "C:\\Users\\Пушок\\Desktop\\Тесты\\";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                String input = File.ReadAllText(openFileDialog1.FileName);
                input = input.Replace("\r", "");
                input = input.Replace(".", ",");
                String[] substrings = input.Split('\n');
                dl = new Detail_list(substrings.Length);
                for (int i = 0; i < substrings.Length; ++i)
                {
                    if (substrings[i] == "")
                    {
                        continue;
                    }
                    Detail det = str_to_det(substrings[i], i);
                    if (det.l == -1 || det.b == -1 || det.i == -1)
                    {
                        MessageBox.Show("Неверный входной файл", "Ошибка");
                        return;
                    }
                    else
                    {
                        dl.add_detail(det);
                    }
                }
                dg_input.Rows.Clear();

                foreach (Detail d in dl.list)
                {
                    dg_input.Rows.Add(d.l.ToString(), d.b.ToString());
                }
            }
        }