Exemplo n.º 1
0
 public static void SaveEl_1(EL_1 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_1.Add(e);
     db.Entry(e).State = System.Data.Entity.EntityState.Added;
     foreach (Cabel cab in e.ListOfCabels) db.Entry(cab).State = System.Data.Entity.EntityState.Added;
     db.SaveChanges();
 }
Exemplo n.º 2
0
 public static void UpdateEl_1(EL_1 isol, 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();
     //EL_1 curr = (from el in db.EL_1
     //            where el.Date == date && el.ObjectsId == objId
     //            select el).FirstOrDefault();
     //EL_1 t = isol;
     //isol = new EL_1();
     //foreach (Cabel cab in t.ListOfCabels)
     //{
     //    Cabel tempC = new Cabel();
     //    tempC.CabelModel = cab.CabelModel;
     //    tempC.CabelType = cab.CabelType;
     //    tempC.ConductorsCount = cab.ConductorsCount;
     //    tempC.L1 = cab.L1;
     //    tempC.L2 = cab.L2;
     //    tempC.L3 = cab.L3;
     //    tempC.Measured = cab.Measured;
     //    tempC.N = cab.N;
     //    tempC.Name = cab.Name;
     //    tempC.PE = cab.PE;
     //    tempC.PEN = cab.PEN;
     //    tempC.Thickness = cab.Thickness;
     //    isol.ListOfCabels.Add(tempC);
     //}
     //isol.MaxMeasured = t.MaxMeasured;
     //isol.Min = t.Min;
     //isol.NameOfEngineer = t.NameOfEngineer;
     //isol.SourceVoltage = t.SourceVoltage;
     //isol.MinMeasured = t.MaxMeasured;
     //isol.Date = t.Date;
     ////currObj.El_1.Remove(curr);
     ////curr.ListOfCabels.Clear();
     //for (int i = 0; i < curr.ListOfCabels.Count; i++) { Cabel cab = curr.ListOfCabels.ElementAt(i);  db.Cabel.Remove(cab); db.Entry(cab).State = System.Data.Entity.EntityState.Deleted; }
     //curr.ListOfCabels.Clear();
     //db.Entry(curr).State = System.Data.Entity.EntityState.Deleted;
     //currObj.El_1.Add(isol);
     //.Entry(isol).State = System.Data.Entity.EntityState.Added;
     //foreach (Cabel cab in isol.ListOfCabels) db.Entry(cab).State = System.Data.Entity.EntityState.Added;
     db.SaveChanges();
     //db.Entry(isol).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 3
0
 public void LoadIsol(EL_1 isol)
 {
 }
Exemplo n.º 4
0
        //private void IsolationTable_Scroll(object sender, EventArgs e) { IsolationTable.VerticalScroll.Value = (sender as ScrollBar).Value; }
        private void Main_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'nPLabDataSet.Engineers' table. You can move, or remove it, as needed.
            //this.engineersTableAdapter.Fill(this.nPLabDataSet.Engineers);
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<NPLabDbContext, Configuration>());

            currObj = (from p in db.Object
                       where p.Id == this.objId
                       select p).FirstOrDefault();
            //
            //var db = new NPLabDbContext();

            //Създаване на скролбар
            IsolationTable.AutoScroll = true;

            //Инициализация на статичните данни
            Stats = new StaticClass();

            //
            tempIsol = new EL_1
            {
                Date = DateTime.Now,
                SourceVoltage = System.Convert.ToInt32(Naprejenie.Value),
                Min = System.Convert.ToDouble(Norm.Value),
                MinMeasured = System.Convert.ToInt32(MinMeas.Value),
                MaxMeasured = System.Convert.ToInt32(MaxMeas.Value),
            };

            EngineerNameIsol.Items.AddRange(Stats.Engineers);
            EngineerNameIsol.SelectedIndex = 0;
            EngineerNameImp.Items.AddRange(Stats.Engineers);
            EngineerNameImp.SelectedIndex = 0;
            EngineerNameGr.Items.AddRange(Stats.Engineers);
            EngineerNameGr.SelectedIndex = 0;
            EngineerNameLiPro.Items.AddRange(Stats.Engineers);
            EngineerNameLiPro.SelectedIndex = 0;
            EngineerNameDef.Items.AddRange(Stats.Engineers);
            EngineerNameDef.SelectedIndex = 0;

            //Добавяне на вече съществуващите контроли към списъците с тях
            Names.Add(textBoxName);
            TypeCabs.Add(TypeCabel);
            Count.Add(Number);
            Surface.Add(CabelArea);
            MeasuredForm.Add(Measured);
            Conductors.Add(Cond);
            Rem.Add(Delete);

            //По подразбиране се избира тип кабел "СВТ"
            tempIsol.ListOfCabels.Add(new Cabel());
            TypeCabel.SelectedIndex = 0;
            textBoxName_TextChanged(textBoxName, new EventArgs());
            Number_ValueChanged(Number, new EventArgs());
            CabelArea_ValueChanged(CabelArea, new EventArgs());
            Measured_ValueChanged(Measured, new EventArgs());

            tempImp.Coefficent = System.Convert.ToInt32(Coefficient.Value);
            tempImp.MaxMeasured = System.Convert.ToDouble(Maximum.Value);
            tempImp.MinMeasured = System.Convert.ToDouble(Minimum.Value);

            Grounding gr = new Models.Grounding
            {
                AuxiliaryGrounding = System.Convert.ToDouble(AuxGr1.Value),
                Probe = System.Convert.ToDouble(Probe1.Value),
                Measured = System.Convert.ToDouble(Meas1.Value),
                Adjusted = System.Convert.ToDouble(Adj1.Value),
                Name = GroundingName.Text
            };
            tempGr.ListOfGroundings.Add(gr);

            LightningGrounding LiGr = new Models.LightningGrounding
            {
                AuxiliaryGrounding = System.Convert.ToDouble(AuxLi1.Value),
                Probe = System.Convert.ToDouble(ProbeLi1.Value),
                Measured = System.Convert.ToDouble(MeasLi1.Value),
                Adjusted = System.Convert.ToDouble(AdjLi1.Value),
                Name = LightningName.Text
            };
            tempLiPro.ListOfGroundings_El_3m.Add(LiGr);
            LoadObj(currObj);
            tempDef.DNHighest = System.Convert.ToDouble(MaxIN.Value);
            tempDef.DNLowest = System.Convert.ToDouble(MinIN.Value);
            tempDef.DTHighest = System.Convert.ToDouble(Maxt.Value);
            tempDef.DTLowest = System.Convert.ToDouble(Mint.Value);
            tempDef.maxDN = System.Convert.ToDouble(NormIN.Value);
            tempDef.maxDT = System.Convert.ToDouble(Normt.Value);
        }
Exemplo n.º 5
0
 public void LoadIsol(EL_1 e, bool clear)
 {
     EngineerNameIsol.SelectedItem = e.NameOfEngineer;
     IsolationDate.Value = e.Date;
     Norm.Value = System.Convert.ToDecimal(e.Min);
     MinMeas.Value = e.MinMeasured;
     MaxMeas.Value = e.MaxMeasured;
     Naprejenie.Value = e.SourceVoltage;
     if (clear)
     {
         for (int j = 1; j < Rem.Count; j++) Rem[1].PerformClick();
     }
     int i;
     for (i = 0; i < e.ListOfCabels.Count; i++)
     {
         Cabel cab = e.ListOfCabels.ElementAt(i);
         Names[i].Text = cab.CabelType;
         TypeCabs[i].SelectedItem = cab.CabelModel;
         Count[i].Value = cab.ConductorsCount;
         Surface[i].Value = System.Convert.ToDecimal(cab.Thickness);
         MeasuredForm[i].Value = System.Convert.ToDecimal(cab.Measured);
         if(Names.Count < e.ListOfCabels.Count) ButtonForAdd.PerformClick();
     }
     //Rem[i-1].PerformClick();
     //Rem[i-2].PerformClick();
     tempIsol = e;
 }
Exemplo n.º 6
0
        private void SaveIsol_Click(object sender, EventArgs e)
        {
            if (!isNewIsol) SaveLoad.UpdateEl_1(tempIsol, IsolationDate.Value, objId, db);
            else
            {
                if (currObj.El_1.Any<EL_1>(p => p.Date == IsolationDate.Value))
                {
                    MessageBox.Show("Вече съществува актуализация със същата дата!");
                    return;
                }
                SaveLoad.SaveEl_1(tempIsol, objId, db);
                //currObj.El_1.Add(tempIsol);
            }

            //db.SaveChanges();
            foreach (Control con in Isolation.Controls)
            {
                if (con == NewActIsol || con == EditActIsol || con == SaveIsol || con == BackIsol || con == EngineerNameIsol || con == IsolationDate)
                    con.Enabled = true;
                else con.Enabled = false;
            }
            SwitchVisIsol();
            EL_1 t = tempIsol;
            tempIsol = new EL_1();
            foreach (Cabel cab in t.ListOfCabels)
            {
                Cabel tempC = new Cabel();
                tempC.CabelModel = cab.CabelModel;
                tempC.CabelType = cab.CabelType;
                tempC.ConductorsCount = cab.ConductorsCount;
                tempC.L1 = cab.L1;
                tempC.L2 = cab.L2;
                tempC.L3 = cab.L3;
                tempC.Measured = cab.Measured;
                tempC.N = cab.N;
                tempC.Name = cab.Name;
                tempC.PE = cab.PE;
                tempC.PEN = cab.PEN;
                tempC.Thickness = cab.Thickness;
                tempIsol.ListOfCabels.Add(tempC);
            }
            tempIsol.MaxMeasured = t.MaxMeasured;
            tempIsol.Min = t.Min;
            tempIsol.NameOfEngineer = t.NameOfEngineer;
            tempIsol.SourceVoltage = t.SourceVoltage;
            tempIsol.MinMeasured = t.MaxMeasured;
            tempIsol.Date = t.Date;
        }