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(); }
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 LoadRoom(Rooms r) { CurrProg.DataSource = new BindingSource(); RoomName.Text = r.RoomName; counts = new Panel[3]{ ContCount, LightCount, PowAmp }; amps = new Panel[3]{ ContAmp, LightAmp, PowAmperage }; names = new ListBox[3] { ContList, LightList, PowAmpList }; foreach(Installations inst in r.ListOfInstallations) { InstallationItem it = inst.Item; int type = (int)inst.Item.Type; int sec = Main.Stats.Items.FindAll(x => (int)x.Type == type).IndexOf(it); if (type == 2) { PowAmpCollection.SetItemChecked(sec, true); sec = PowAmpList.Items.IndexOf(it.Name); } (counts[type].Controls[sec] as NumericUpDown).Value++; if((counts[type].Controls[sec] as NumericUpDown).Value == 1) (amps[type].Controls[sec] as NumericUpDown).Value = System.Convert.ToDecimal(inst.Amperage); } ImpBindingSource = new BindingSource(); foreach (Installations inst in r.ListOfInstallations) { ImpBindingSource.Add(inst); CurrProg.Columns[0].DataPropertyName = "InstallationName"; CurrProg.Columns[1].DataPropertyName = "Amperage"; CurrProg.Columns[2].DataPropertyName = "Coefficient"; CurrProg.Columns[3].DataPropertyName = "Impedance"; CurrProg.Columns[4].DataPropertyName = "Max"; CurrProg.DataSource = ImpBindingSource; } CurrProg.Update(); CurrProg.Refresh(); }
private void ImpRoom_Load(object sender, EventArgs e) { //EditContacts.DataSource = currRoom.ListOfInstallations; //Main.Stats = new StaticClass(); foreach (InstallationItem item in Main.Stats.Items) { if ((int)item.Type == 0) { ContList.Items.Add(item.Name); ContList.Items.Add(""); } if ((int)item.Type == 1 && item.Id < 4000) { LightList.Items.Add(item.Name); LightList.Items.Add(""); } if ((int)item.Type == 1 && item.Id >= 4000) { LumList.Items.Add(item.Name); LumList.Items.Add(""); } if ((int)item.Type == 2) PowAmpCollection.Items.Add(item.Name); } CurrProg.AutoGenerateColumns = false; ImpBindingSource = new BindingSource(); foreach(Installations inst in currRoom.ListOfInstallations) ImpBindingSource.Add(inst); CurrProg.DataSource = ImpBindingSource; CurrProg.Columns[0].DataPropertyName = "InstallationName"; CurrProg.Columns[1].DataPropertyName = "Amperage"; CurrProg.Columns[2].DataPropertyName = "Coefficient"; CurrProg.Columns[3].DataPropertyName = "Impedance"; CurrProg.Columns[4].DataPropertyName = "Max"; foreach (Control con in this.Controls) { if (con is Panel) { (con as Panel).AutoScroll = false; (con as Panel).AutoSize = true; } //if (con is GroupBox) (con as GroupBox).Sc = true; } Rooms t = currRoom; M.SuccRoom = false; currRoom = M.tempImp.ListOfSectors.ElementAt(sector).ListOfFloors.ElementAt(floor).ListOfRooms.ElementAt(room); LoadRoom(currRoom); showMsg = true; //currRoom = t; CurrProg.Update(); CurrProg.Refresh(); }