Call method with updated data
Hello, im currently trying to make an update function.
I got 2 lists:
The first list stores every aircraft, while the second one only stores variables that are updatable.
If I exit the form a sql script runs which pulls the updated data in the second list, then It gets updated on the "overview" in a User Control, the user control has a method which calls up a more detailed form where I can update attributes.
Problem: If I open the aircraftDetails (picAircraft_Click) Form the old data is getting showed because the method with the older data is given to it, now I had the idea to compare the two lists and if there is any difference then it should give the updated data and if not it should give the old (currentAircraft).
You guys got any fix for that or an better solution I can use to update the Details form?
7 Replies
AircraftField_UC.cs
Method that is being called in the details Page:
i don't understand this part
the old data is getting showed because the method with the older data is given to itwhy do you have to use the old data?
Basically I can Update Data in The AircraftDeatails.cs Form, Like eg. Change Type or seats. Then I click on save, which Uploads The Changed Data to The Database. If I press The Exit Button in The Details Form it pulls The new Data from the Database and puts it in The AircraftField_UC.cs User Control, which is Then showing The updated Data.
If I click on The AircraftPicture in The UC an Event triggers to Open The Details Page, but if It opens the old Data is givien to The Details Page
so the event of having updated the data should go to the other component to update its data
No, both data needs to be updated
In the userControl, which is an overview its updating, but then it also needs to be updated in the details page
yes, but the point is the architecture of the program: you said you have cached/duplicated data somewhere, and you have also a form that updates the real source of the data, the database
so you need to host that cached data in a service that is aware of the fact that something else has updated the real data, ergo you need an event (or a maybe even a less detached mechanism) from the class that is updating the db to who is listening for updates of that data
I fixed it with these lines:
currentAircraft.Type = specificAircraft.Type;
currentAircraft.Engines = specificAircraft.Engines;
currentAircraft.Seats = specificAircraft.Seats;
currentAircraft.FirstFlight = specificAircraft.FirstFlight;
currentAircraft.SpecialLivery = specificAircraft.SpecialLivery;
currentAircraft.Favorite = specificAircraft.Favorite;
Thanks