I have a winform data entry and retrieval program called CaseNotes. This has a form that that fill in. On the form there are multiple dropdown,checkbox controls that I are data-bound to a tblCNMaintItem. The structure of that table is -->
ItemID | CategoryID | ItemDescription | OrderID | IsActive
There is a seperate Category table that provides that categoryID's. A CategoryID maps to a Single Control on the Case Notes Form.
My question is two-fold:
How should I go about getting the value for each item? As in, I grab the itemDescription by CategoryID to populate the controls but on SaveNewCaseNote() I need to get the corresponding ItemID instead. How can I accomplish this? Should I create a dictonary for each category(Control)? Should I Enumerate the ItemID/ItemDescription combo?
EDIT Forget #2 as I have found my answer.
Thanks!
Okay, for some reason I have failed to state this clearly and it is generating confusion. My DB consists of 3 tables. tblCaseNotes, tblCNMaintCategory, tblCNMaintItem. CaseNotes contains a complete "Case Note" per row. The Maint tables are for the multiple choice answers when filling out a CaseNote. Example: They must select a "Contact Location". The options "Office" or "Member's Home". In tblCNMaintCategory there is a enntry like so-->
CategoryID = 3, CatgoryName = Contact Location, IsActive = True
In tblCNMaintItem there are 2 entries like so -->
ItemID=51, CategoryID=2, ItemDescription=Office, OrderID=0, IsActive=True ItemID=52, CategoryID=2, ItemDescription=Member's Home, OrderID=0, IsActive=True
In tblCaseNote there would be an entry like so --> CaseNoteID=3243, PersonID=454676, AssocContactLocations= 51, and then many more columns following same pattern
Question 1 is pertaining to wanting to store the ItemID in AssocContactLocation versus the ItemDescription. I am thinking a
Dictionary <strng, int> cLocateItems(itemDescription,itemID)
maybe...
Does this help?
Thanks everyone for the time and effort!
After your edit, I think you mean, "How can I display the text but still use the numeric ID when I save the data?"
If that is your question, then yes your dictionary idea would work.
It's been a long time since I've done any CRUD work, but I recall that you could store the ID in the drop down box along with the text. Then when you do your update, you would use the ID instead of the text. This option may be easier than your dictionary idea.
If I have still misunderstood your question, I guess someone else will have to help.