Hi Guys,
i have several classes that i have created for simple wpf data entries like personal information for students and separate one for drivers and supervisors.
i thought to create a sepsarate class to contain common fields like addresses telephone and contact details all inked to corresponding object in column called Addres_Id that will be inserted from each object i.e student , driver.
the form for each object will include contact and addresses details.
my question how would i go about thi and call the shared class from within each object to be inserted within each object.
thank you in advance
VulpesPosted Mar 22, 2014, 4:26 PM
Basically, each time you create a ContactDetails object, you add it to a dictionary using its AddressId as the key.
A Student object uses its AddressId property to look up contact details in the dictionary and these are then exposed through Address and TelephoneNumber properties.
For simplicity I've presented the code as a console app:
Abbas HamzaPosted Mar 24, 2014, 3:59 PM
sorry for not giving the complete info as it was vs 2013 it automatically choose 4.5 framework
as i was using this part of this code as it will make NotifyPropertyChange() easy to dode as it wil apply for any property instead of indicate the property that changing every time specially the use of CallMemberName which is new in 4.5..
the code is like that
VulpesPosted Mar 24, 2014, 1:11 PM
Abbas HamzaPosted Mar 23, 2014, 5:12 PM
I have found this work around to make my vs 2013 to work with your vs 2010 that is if you are interested
http://stackoverflow.com/questions/12143383/converting-vs2012-solution-to-vs2010
Abbas HamzaPosted Mar 23, 2014, 4:34 PM
it is developed in vs 2013 but will follow your excellent guidance and will resolve the issue, if i need more help i know where to go
VulpesPosted Mar 23, 2014, 10:48 AM
However, in principle, there is no reason why the above code shouldn't work in any type of application.
As long as a dictionary exists mapping AddressIds to ContactDetails and a Student (or any other type of) object has an AddressId property, then the two can be linked together.
Incidentally, as dictionaries must have unique keys, it follows that AddressIds must be unique for this approach to work though I'd expect that to be the case. This, of course, wouldn't prevent multiple students having the same AddressId, if they all live at the same address.
Abbas HamzaPosted Mar 23, 2014, 5:41 AM
thanks for quick reply your answer is going to be part of my solution to link students to address,,,,may be i should have mentioned I'm currently learning MVVM and my project is one of them and i have used the following tutorial code to try to do something more elaborate http://www.youtube.com/watch?v=R_NQlB5eHKE.
my query if i got a WPF window with students detail and student contacts would the above contact will work in inserting new students, driver ,,etc..
i have attached the code of my project in a zip file sized at 106 kb and my database script.