private void Sector_Click(object sender, EventArgs e) { SectorPropertiesForm spf = new SectorPropertiesForm(Available, Position, Rail.ID, SectorInformation, Reserved); spf.ShowDialog(); if (sender is Label) { Label label = (Label)sender; if (label.Parent.Parent is BeheerSysteemForm) { BeheerSysteemForm form = (BeheerSysteemForm)label.Parent.Parent; form.GetAllSectors(); } } }
private void Rail_Click(object sender, EventArgs e) { List <Sector> allSectors = new List <Sector>(); List <Sector> sectorsFromRail = new List <Sector>(); BeheerSysteemForm form = new BeheerSysteemForm(); //list van alle sectoren if (sender is Label) { Label label = (Label)sender; if (label.Parent.Parent is BeheerSysteemForm) { form = (BeheerSysteemForm)label.Parent.Parent; allSectors = form.Sectors; } } //list van alle sectoren van huidige rail foreach (Sector s in allSectors) { if (s.Rail.ID.ToString() == ID.ToString() && !string.IsNullOrEmpty(s.SectorInformation)) { sectorsFromRail.Add(s); } } sectorsFromRail.Sort(); //tellen hoeveel sectoren er zijn int totalPostitions = sectorsFromRail.Count; for (int i = 0; i < totalPostitions; i++) { if (!sectorsFromRail[i].Available) { break; } if (sectorsFromRail[i].Position < totalPostitions) { sectorsFromRail[i].SectorInformation = sectorsFromRail[i + 1].SectorInformation; OracleParameter[] parameters1 = new OracleParameter[] { new OracleParameter("sectorinformation", sectorsFromRail[i + 1].SectorInformation), new OracleParameter("railid", ID), new OracleParameter("position", sectorsFromRail[i].Position) }; DatabaseManager.ExecuteInsertQuery(DatabaseQuerys.query["UpdateSectorInformation"], parameters1); } if (sectorsFromRail[i].Position == totalPostitions) { sectorsFromRail[i].SectorInformation = ""; OracleParameter[] parameters1 = new OracleParameter[] { new OracleParameter("railid", ID), new OracleParameter("position", sectorsFromRail[i].Position) }; DatabaseManager.ExecuteInsertQuery(DatabaseQuerys.query["UpdateLastSectorInformation"], parameters1); } } form.GetAllSectors(); /* * //messagebox for sectorfromrail * foreach (Sector s in sectorsFromRail) * { * MessageBox.Show(s.Rail.ID.ToString() + " - " + s.Position.ToString() + " - " + s.SectorInformation); * }*/ }