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 NewSector_Click(object sender, EventArgs e) { Sectors sec = new Sectors { Id = tempImp.ListOfSectors.Count, SectorName = "(Нов сектор)" }; tempImp.ListOfSectors.Add(sec); TreeNode treeNode = new TreeNode("Нов сектор"); ImpTreeView.Nodes.Add(treeNode); //if (edit) { treeNode.EndEdit(true); return; } //ImpTreeView.SelectedNode = null; treeNode.BeginEdit(); //edit = true; //ImpTreeView.SelectedNode = null; }