Ejemplo n.º 1
0
 public static void SaveEl_3m(EL_3m e, 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();
     currObj.El_3m.Add(e);
     db.Entry(e).State = System.Data.Entity.EntityState.Added;
     foreach (LightningGrounding cab in e.ListOfGroundings_El_3m) db.Entry(cab).State = System.Data.Entity.EntityState.Added;
     db.SaveChanges();
 }
Ejemplo n.º 2
0
        private void SaveLiPro_Click(object sender, EventArgs e)
        {
            if (!isNewLiPro) SaveLoad.UpdateEl_3m(tempLiPro, LiProDate.Value, objId, db);
            else
            {
                if (currObj.El_3m.Any<EL_3m>(p => p.Date == LiProDate.Value))
                {
                    MessageBox.Show("Вече съществува актуализация със същата дата!");
                    return;
                }
                SaveLoad.SaveEl_3m(tempLiPro, objId, db);
                //currObj.El_1.Add(tempIsol);
            }
            foreach (Control con in LightningProtection.Controls)
            {
                if (con == NewActLiPro || con == EditActLiPro || con == SaveLiPro || con == BackLiPro || con == EngineerNameLiPro || con == LiProDate)
                    con.Enabled = true;
                else con.Enabled = false;
            }
            //db.SaveChanges();
            SwitchVisLiPro();

            EL_3m t = tempLiPro;
            tempLiPro = new EL_3m();
            foreach (LightningGrounding cab in t.ListOfGroundings_El_3m)
            {
                LightningGrounding tempC = new LightningGrounding();
                tempC.Adjusted = cab.Adjusted;
                tempC.AuxiliaryGrounding = cab.AuxiliaryGrounding;
                tempC.Measured = cab.Measured;
                tempC.Name = cab.Name;
                tempC.Probe = cab.Probe;
                tempLiPro.ListOfGroundings_El_3m.Add(tempC);
            }
            tempLiPro.Date = t.Date;
            tempLiPro.Max = t.Max;
            tempLiPro.NameOfEngineer = t.NameOfEngineer;
            tempLiPro.WetSeason = t.WetSeason;
        }
Ejemplo n.º 3
0
 public void LoadLiPro(EL_3m isol)
 {
 }
Ejemplo n.º 4
0
 public static void UpdateEl_3m(EL_3m liPro, 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_3m
                 where el.Date == date
                 select el).FirstOrDefault();
     //curr = liPro;
     //db.Entry(liPro).State = System.Data.Entity.EntityState.Modified;
     //foreach (Cabel cab in liPro.ListOfCabels) db.Entry(cab).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Ejemplo n.º 5
0
        public void LoadLiPro(EL_3m e, bool clear)
        {
            EngineerNameLiPro.SelectedItem = e.NameOfEngineer;
            LiProDate.Value = e.Date;
            if (e.WetSeason) FiLi.Value = 1.3M;
            else FiLi.Value = 1.15M;
            MaxLi.Value = System.Convert.ToDecimal(e.Max);
            wetLi.Checked = e.WetSeason;
            if (clear)
            {
                for (int j = 1; j < DelButtonsLi.Controls.Count; j++) (DelButtonsLi.Controls[1] as Button).PerformClick();
            }
            int i;
            for (i = 0; i < e.ListOfGroundings_El_3m.Count; i++)
            {
                LightningGrounding LiPro = e.ListOfGroundings_El_3m.ElementAt(i);
                (LiName.Controls[i] as TextBox).Text = LiPro.Name;
                (AuxLi.Controls[i] as NumericUpDown).Value = System.Convert.ToDecimal(LiPro.AuxiliaryGrounding);
                (ProbeLi.Controls[i] as NumericUpDown).Value = System.Convert.ToDecimal(LiPro.Probe);
                (LiMeas.Controls[i] as NumericUpDown).Value = System.Convert.ToDecimal(LiPro.Measured);
                if (LiName.Controls.Count < e.ListOfGroundings_El_3m.Count) NewLi.PerformClick();
            }

            tempLiPro = e;
        }