Ejemplo n.º 1
0
 public static void SaveEl_2(El_2 e, int objId, NPLabDbContext db)
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion<NPLabDbContext, Configuration>());
     currObj = (from p in db.Object
                where p.Id == objId
                select p).FirstOrDefault();
     //e.Object = currObj;
     //.ObjectsId = currObj.Id;
     currObj.El_2.Add(e);
     db.Entry(e).State = System.Data.Entity.EntityState.Added;
     foreach (Sectors sec in e.ListOfSectors)
     {
         db.Entry(sec).State = System.Data.Entity.EntityState.Added;
         foreach (Floors f in sec.ListOfFloors)
         {
             db.Entry(f).State = System.Data.Entity.EntityState.Added;
             foreach (Rooms r in f.ListOfRooms)
             {
                 db.Entry(r).State = System.Data.Entity.EntityState.Added;
                 foreach (Installations inst in r.ListOfInstallations) db.Entry(inst).State = System.Data.Entity.EntityState.Added;
             }
         }
     }
     db.SaveChanges();
 }
Ejemplo n.º 2
0
 public ImpRoom(Main M, Rooms currRoom, El_2 El2Ref, int sector, int floor, int room, bool isNew)
 {
     this.currRoom = currRoom;
     //this.currRoom.ListOfInstallations.Clear();
     this.EL2Ref = El2Ref;
     this.M = M;
     this.sector = sector;
     this.floor = floor;
     this.room = room;
     this.isNew = isNew;
     InitializeComponent();
 }
Ejemplo n.º 3
0
 public static void UpdateEl_2(El_2 imp, DateTime date, int objId, NPLabDbContext db)
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion<NPLabDbContext, Configuration>());
     //var db = new NPLabDbContext();
     currObj = (from p in db.Object
                where p.Id == objId
                select p).FirstOrDefault();
     var curr = (from el in currObj.El_2
                 where el.ControlDate == date
                 select el).FirstOrDefault();
     //curr = imp;
     //db.Entry(imp).State = System.Data.Entity.EntityState.Modified;
     //foreach (Sectors sec in imp.ListOfCabels) db.Entry(cab).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public void LoadImp(El_2 isol)
 {
 }
Ejemplo n.º 6
0
 public void LoadImp(El_2 e, bool clear)
 {
     EngineerNameImp.SelectedItem = e.NameOfEngineer;
     ImpedanceDate.Value = e.ControlDate;
     Coefficient.Value = e.Coefficent;
     Minimum.Value = System.Convert.ToDecimal(e.MinMeasured);
     Maximum.Value = System.Convert.ToDecimal(e.MaxMeasured);
     if(clear) ImpTreeView.Nodes.Clear();
     foreach (Sectors sec in e.ListOfSectors)
     {
         ImpTreeView.Nodes.Add(sec.SectorName);
         foreach (Floors f in sec.ListOfFloors)
         {
             ImpTreeView.Nodes[ImpTreeView.Nodes.Count - 1].Nodes.Add(f.NameFloor);
             foreach (Rooms r in f.ListOfRooms)
             {
                 ImpTreeView.Nodes[ImpTreeView.Nodes.Count - 1].Nodes[ImpTreeView.Nodes[ImpTreeView.Nodes.Count - 1].Nodes.Count - 1].Nodes.Add(r.RoomName);
             }
         }
     }
     tempImp = e;
 }