/// <summary> /// Работа с пластами угля /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Add_B_Layer_Click(object sender, EventArgs e) { DialogLayer Dialog = new DialogLayer() { Text = "Создание пласта" }; var mytask = dGVTasks.CurrentRow.DataBoundItem as MyTask; int numLayer; try ////////////////////Некрасиво /переделать { numLayer = repository.Layers.Where(c => c.MyTask == mytask.PK_Task).Max(a => a.Numberlayer); } catch { numLayer = 0; } if (Dialog.ShowDialog() == DialogResult.OK) { //MessageBox.Show(Dialog.dGV_Layer.Rows[0].Cells[0].Value.ToString()); repository.AddLayer(new Layer() { MyTask = mytask.PK_Task, Numberlayer = numLayer + 1, NameLayer = Dialog.tBLayerName.Text, C1 = Convert.ToDouble(Dialog.dGV_Layer.Rows[0].Cells[0].Value.ToString()), C2 = Convert.ToDouble(Dialog.dGV_Layer.Rows[0].Cells[1].Value.ToString()), }); for (var i = 1; i < 8; i++) { repository.AddLayer(new Layer() { MyTask = mytask.PK_Task, Numberlayer = numLayer + 1, NameLayer = Dialog.tBLayerName.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()), C7 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[6].Value.ToString()), C8 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[7].Value.ToString()), C9 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[8].Value.ToString()), C10 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[9].Value.ToString()), C11 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[10].Value.ToString()), C12 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[11].Value.ToString()), C13 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[12].Value.ToString()), C14 = Convert.ToDouble(Dialog.dGV_Layer.Rows[i].Cells[13].Value.ToString()), }); } repository.AddLayer(new Layer() { MyTask = mytask.PK_Task, Numberlayer = numLayer + 1, NameLayer = Dialog.tBLayerName.Text, C1 = Convert.ToDouble(Dialog.dGV_Layer.Rows[8].Cells[0].Value.ToString()), C2 = Convert.ToDouble(Dialog.dGV_Layer.Rows[8].Cells[1].Value.ToString()), }); } dGVTasks_CurrentCellChanged(sender, e); }