private void LoadButton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; 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) { dl.add_detail(str_to_det(substrings[i], i)); } } verh = 0; for (int i = 0; i < dl.list.Count; i++) { verh += dl.list[i].b * dl.list[i].l; } flag = 0; for (int i = 0; i < dl.list.Count; ++i) { dgvInput.Rows.Add(); dgvInput.Rows[i].Cells[0].Value = dl.list[i].l; dgvInput.Rows[i].Cells[1].Value = dl.list[i].b; } flag = 1; }
private void button2_Click(object sender, EventArgs e) { verh = 0; for (int i = 0; i < dgvInput.Rows.Count - 1; i++) { verh += Convert.ToDouble(dgvInput.Rows[i].Cells[0].Value) * Convert.ToInt32(dgvInput.Rows[i].Cells[1].Value); } if (tb_length.Text == "") { MessageBox.Show("Введите длину бруска!", "Внимание!"); } if (dl != null) { dl.ClearAll(); } dl = new Detail_list(dgvInput.Rows.Count - 1); for (int i = 0; i < dgvInput.Rows.Count - 1; i++) { if (dgvInput.Rows[i].Cells[0].Value != null && Convert.ToInt32(dgvInput.Rows[i].Cells[1].Value) != 0) { dl.add_detail(new Detail(Convert.ToDouble(dgvInput.Rows[i].Cells[0].Value), Convert.ToInt32(dgvInput.Rows[i].Cells[1].Value), i)); } else { MessageBox.Show("Заполните данные!", "Внимание!"); dl.ClearAll(); break; } } }
public Cutting(double _L, Detail_list _dl) { M = _dl.list.Count; L = _L; dl = _dl; dl.update_work_list(); dl.sort_by_l(); cp_list = new List <Cutting_Pattern>(); }
private void DeleteButton_Click(object sender, EventArgs e) { if (dgvInput.SelectedRows.Count > 0 && dgvInput.SelectedRows[0].Index != dgvInput.Rows.Count - 1) { dgvInput.Rows.RemoveAt(dgvInput.SelectedRows[0].Index); } dl.ClearAll(); dl = new Detail_list(dgvInput.Rows.Count - 1); for (int i = 0; i < dgvInput.Rows.Count - 1; i++) { dl.add_detail(new Detail(Convert.ToDouble(dgvInput.Rows[i].Cells[0].Value), Convert.ToInt32(dgvInput.Rows[i].Cells[1].Value), i)); } }