private void Edit_B_Layer_Click(object sender, EventArgs e) { try { var nameChange = cB_Layer.Text; var change = repository.Layers.Where(n => n.NameLayer == nameChange).ToList(); DialogLayer Dialog = new DialogLayer(change, nameChange) { Text = "Изменение пласта" }; if (Dialog.ShowDialog() == DialogResult.OK) { //MessageBox.Show(Dialog.dGV_Layer.Rows[0].Cells[0].Value.ToString()); repository.AddLayer(new Layer() { PK_Layer = change[0].PK_Layer, MyTask = change[0].MyTask, Numberlayer = change[0].Numberlayer, 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() { PK_Layer = change[i].PK_Layer, MyTask = change[i].MyTask, Numberlayer = change[i].Numberlayer, 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() { PK_Layer = change[8].PK_Layer, MyTask = change[8].MyTask, Numberlayer = change[8].Numberlayer, 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); } catch { MessageBox.Show("Не получилось изменить угольный пласт", "Ошибка"); } }
/// <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); }