Datasets with lookup tables - display on form

dsk96m

Well-known member
Joined
Jan 11, 2013
Messages
173
Programming Experience
1-3
I am creating an application but having some trouble.

This is part of my form that I am having issues with:
View attachment form.bmp

I have a combobox that has some data in it. I want the user to select an item from the list, click add, and have it show up in the listbox, but also to my db table on save.

Here is a look at the dataset designer:
View attachment designer.bmp

As you can see, my main table is flightplan. I have an intersecting table and then a lookup table.
A flighplan can have multiple chargenumbers and charge numbers can belong to several flight plans. Many to Many.

The form is bound to flight plan, so the user opens to form the add a new flight plan. They will enter some other info and then select charge numbers associated with the flight. What is the best way to do this. I have the chargenumbers and its associated id already in the drop down. I just dont know how to work the add and how to display that selected item in the listbox.

Right now, I have the user save the flight plan with basic data they enter, then when they click save and continue, this groupbox shown in the image is enabled. I was thinking maybe i needed the id of the flight plan before i could add items to the flightcharge table.

I am all confused. I can do it all with sql, the old school way, but I am trying to learn how to use datasets and databinding, etc. This is just one of the items i cant figure out. Any help or guidance would be greatly appreciated.
 
You're quite correct that you need the flight plan ID before you can start adding charge numbers to the join table. What I would suggest is that, as the user selects charge numbers, just add the charge number rows themselves to a list. When the user commits the new flight plan record to the table you will then have an ID, so you can start adding records to the join table, one for each charge number row in your list with that flight number ID.
 
So i did it a different way and I am able to get the ids into the flightcharge table above. But how do I show the added charge in the list box. I know how i would do it with sql statement, select chargenumber from chargenumbers join flightcharge on charenumbers.id=flightcharge.charge_number_id where flight_charge_id = whatever the flight id is, but i dont know how to do it through the binding or dataset
 
On another note, how would i create a datagridview from my employee table that has ids related to other tables. for example, in the employee table there is a field called type. Then there is a tabled called type with items like id:1 type:hourly; ID:2 type:salary. So for me in my row in the employee table, would have Name: David, etc, TYPE:2.

What I want to show in a data grid view is the information in the employee table and the related value in other tables. So the data grid view would have: DAVID | SALARY | etc. How do I accomplish this. It is so confusing.
 
Anyone have any suggestions. this whole databinding, dataset, entity framework is confusing to me and I have been reading books about it. using sql was a lot of coding, but made sense. I could write select statements with joins, etc, update and delete statements. It made sense. I know this new way is better, I just cant figure out how to do it. I would be good if i could figure out the few things mentioned above, since those are the things I mostly do, but I cant seem to find the right information. Please help
 
Back
Top