private void Add_B_Class_Click(object sender, EventArgs e) { DialogLayerCalc Dialog = new DialogLayerCalc() { Text = "Создание класса расчета" }; var calca = dGVCalcs.CurrentRow.DataBoundItem as Calc; if (Dialog.ShowDialog() == DialogResult.OK) { for (var i = 0; i < 6; i++) { repository.AddLayersCalculations(new LayersCalculation() { Calc = calca.PK_Calc, Class = Dialog.tBClass.Text, C1 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[0].Value.ToString()), C2 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[1].Value.ToString()), C3 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[2].Value.ToString()), C4 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[3].Value.ToString()), C5 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[4].Value.ToString()), C6 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[5].Value.ToString()), }); } } LoadLayersCalc(); }