private void SaveImp_Click(object sender, EventArgs e) { if (!isNewImp) SaveLoad.UpdateEl_2(tempImp, ImpedanceDate.Value, objId, db); else { if (currObj.El_2.Any<El_2>(p => p.ControlDate == IsolationDate.Value)) { MessageBox.Show("Вече съществува актуализация със същата дата!"); return; } SaveLoad.SaveEl_2(tempImp, objId, db); //currObj.El_1.Add(tempIsol); } foreach (Control con in Impedance.Controls) { if (con == NewActImp || con == EditActImp || con == SaveImp || con == BackImp || con == EngineerNameImp || con == ImpedanceDate) con.Enabled = true; else con.Enabled = false; } //db.SaveChanges(); SwitchVisImp(); El_2 t = tempImp; tempImp = new El_2(); foreach (Sectors sec in t.ListOfSectors) { Sectors tempS = new Sectors(); tempS.SectorName = sec.SectorName; foreach (Floors f in sec.ListOfFloors) { Floors tempF = new Floors(); tempF.NameFloor = f.NameFloor; foreach (Rooms r in f.ListOfRooms) { Rooms tempR = new Rooms(); tempR.RoomName = r.RoomName; foreach (Installations inst in r.ListOfInstallations) { Installations tempI = new Installations(); tempI.Amperage = inst.Amperage; tempI.Coefficient = inst.Coefficient; tempI.FollowsRequirements = inst.FollowsRequirements; tempI.Impedance = inst.Impedance; tempI.InstallationName = inst.InstallationName; tempI.isAutomaticProtector = inst.isAutomaticProtector; tempI.Item = inst.Item; tempI.Max = inst.Max; tempI.NumberOfInstallation = inst.NumberOfInstallation; tempI.Ofazen = inst.Ofazen; tempI.Reset = inst.Reset; tempR.ListOfInstallations.Add(tempI); } tempF.ListOfRooms.Add(tempR); } tempS.ListOfFloors.Add(tempF); } tempImp.ListOfSectors.Add(tempS); } tempImp.Coefficent = t.Coefficent; tempImp.ControlDate = t.ControlDate; tempImp.isAuto = t.isAuto; tempImp.MaxMeasured = t.MaxMeasured; tempImp.MinMeasured = t.MinMeasured; tempImp.NameOfEngineer = t.NameOfEngineer; tempImp.ObjectName = t.ObjectName; }
private void NewFloor_Click(object sender, EventArgs e) { if (ImpTreeView.SelectedNode == null) { MessageBox.Show("Моля изберете сектор!"); return; } if (ImpTreeView.SelectedNode.Level != 0) { MessageBox.Show("Моля изберете сектор!"); return; } Floors fl = new Floors { Id = tempImp.ListOfSectors.Count, NameFloor = "(Нов етаж)" }; tempImp.ListOfSectors.ElementAt(ImpTreeView.SelectedNode.Index).ListOfFloors.Add(fl); TreeNode treeNode = new TreeNode("Нов етаж"); ImpTreeView.SelectedNode.Nodes.Add(treeNode); ImpTreeView.SelectedNode = treeNode; treeNode.BeginEdit(); }