Click here to Skip to main content
15,916,600 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi all,

I am programming a windows application with multiple forms (MDI), wich is ment to be a combination of a CRM and an accounting application.

I have already implemented the datatiers (DAL and BLL). Now I am designing the forms, but I don't know how I should solve this task :

In my database I have 4 tables that should provide generic lists of possible values to multiple forms :

- list countries (ISO values) with ID, international number, abbriviation, name and internatial phone code, providing values to the zipcodes-table and narowing the possible zips in forms - e.g.:
1,  56, 'BE', 'Belgium',        '+32'
2, 826, 'GB', 'United Kingdom', '+44'
- list of zipcodes with ID country ID, Zipcode, Place, providing the location Id in the adresses-table - e.g.:
1,  32, '3000',     'Leuven'
2, 826, 'EC1A 4JA', 'London'

- list of valuetables with ID, LanguageID, Label and Last used value - e.g.:
1, 3, 'genders',         2
2, 3, 'contact titles',  2
3, 3, 'professions',     0
4, 3, 'legal statute',   0
5, 3, 'kind of address', 0

- list of values for each valuetable with ID, valuetableID, LanguageID, Number, Label and Abbriviation - e.g.:
1, 1, 3, 1, 'male',   ''
2, 1, 3, 2, 'female', ''
3, 2, 3, 1, 'Sir',    'Sr'
4, 2, 3, 2, 'Miss',   'Ms'


Tables 1, 2 and 4 should be available to all forms as generic lists to populate comboboxes to set or show the values in the form for the row shown in other tables with a displaymember and a valuemember.

In each form I will then set each combo, e.g. :
VB
cbo_gender.datasource = GenericTable("Genders",user.Language)
cbo_gender.DisplayMember = "Label"
cbo_gender.ValueMember = "Number"
cbo_gender.SelectedIndex = IIf(IsNothing(Item.GenderID),-1,Item.GenderID)


Any idea how I should provide this generic lists in my application? I have no clue for the moment... Thanks in advance!
Posted
Updated 18-Oct-12 8:33am
v2
Comments
milenalukic 18-Oct-12 15:20pm    
you just need to query your database and attach the datsource
Sergey Alexandrovich Kryukov 18-Oct-12 15:21pm    
Nothing is clear here? What do you mean "provide"? Whatever it is, how can it be a problem? Read on generics, read on System.Collections.Generic.
--SA

It looks like most of the post is irrelevant to the problem, if there is a problem. Read on generics, read on System.Collections.Generic:
http://msdn.microsoft.com/en-us/library/w256ka79%28v=vs.80%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx[^],
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[^].

How can "lists" do anything with Forms or UI in general. Ever heard of separation of concerns? Well, please see:
http://en.wikipedia.org/wiki/Separation_of_concerns[^].

UI must be well isolated from all other aspects of application, just to give you the basic idea.

[EDIT]

Also, using MDI is a very bad idea. Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. I can explain what to do instead.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

In my past answers:
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

Good luck,
—SA
 
Share this answer
 
v3
Comments
Maciej Los 18-Oct-12 15:44pm    
No comments, +5!
Sergey Alexandrovich Kryukov 18-Oct-12 15:52pm    
Thank you very much, Maciej.
--SA
Espen Harlinn 18-Oct-12 18:41pm    
5'ed!
Sergey Alexandrovich Kryukov 18-Oct-12 18:44pm    
Thank you, Espen.
--SA
Thank you for the input.

My problem was not how to fill a combo from a table or create the lists, more a global question as how to do this in my application. I did not find very much documentation about standardization in applications.

But I have been keeping on doing research and the mentioned articles did help in this by linking me to interesting articles!

Finally I have choosen to make this tables available at application scope as a collection of a serializable custom class, and to send each bound object to a fillfunction. Most of the time these tables are readonly and I need them really in every form or report. Only when a user should change a table, the in memory tables must be updated from within the BLL too.

I know the pro's and con's of MDI applications. I have choosen for this approach because experience on the field learned that users need to open new forms e.g. when they recieve a call while working on a file or to lookup information while encoding documents in the accounting part. I have made the MDI parent tabs the child forms and it is the user who choose how many tabs he opens.

Kind regards!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900