如何为我的表单提供通用列表? [英] How to provide generic lists to my forms?

查看:85
本文介绍了如何为我的表单提供通用列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在编写具有多种形式(MDI)的Windows应用程序,但要结合CRM和会计应用程序.

我已经实现了数据层(DAL和BLL).现在我正在设计表单,但我不知道该如何解决此任务:

在我的数据库中,我有4个表,这些表应提供多种形式的可能值的通用列表:

-列出具有ID,国际号码,姓氏,名称和国际电话代码的国家(ISO值),为邮政编码表提供值并以表格形式查找可能的邮政编码-例如:

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'

-带有ID国家/地区ID,邮政编码,位置的邮政编码列表,在地址表中提供位置ID-例如:

- 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'


-具有ID,LanguageID,标签和上次使用的值的值表的列表-例如:


- 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


-具有ID,valuetableID,LanguageID,数字,标签和缩写的每个值表的值列表-例如:


- 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'



表1,表2和表4应该作为通用列表用于所有表单,以填充组合框以设置或显示其他表中具有displaymember和valuemember的行的表单中的值.

然后,我将以每种形式设置每个组合,例如:



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. :

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!

推荐答案

看来,如果有问题,大多数帖子与问题无关.阅读泛型,阅读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 [ ^ ].

通常,列表"如何使用Forms或UI可以执行任何操作.有没有听说过分离关注点?好吧,请参阅:
http://en.wikipedia.org/wiki/Separation_of_concerns [ http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [如何在WPF中创建MDI父窗口? [ ^ ].

在我过去的答案中:
在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何最大程度地设置子表单,最小化最后一个子表单 [ ^ ].

祝你好运,
—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.



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


感谢您的输入.

我的问题不是如何从表中填充组合或创建列表,而是如何在应用程序中执行此操作的全局性问题.我没有找到太多有关应用程序标准化的文档.

但是我一直在进行研究,提到的文章通过将我链接到有趣的文章而确实对我们有所帮助!

最终,我选择了将此表作为可序列化的自定义类的集合在应用程序范围内使用,并将每个绑定的对象发送到fillfunction.在大多数情况下,这些表是只读的,我确实需要每种表格或报告中的表.仅当用户应更改表时,内存表也必须从BLL中更新.

我知道MDI应用程序的优缺点.我之所以选择这种方法,是因为现场经验表明,用户需要打开新表格,例如当他们在处理文件时收到呼叫,或在记帐部分中对文档进行编码时查找信息.我已经将MDI父选项卡设置为子窗体,并且由用户选择他打开了多少个选项卡.

亲切的问候!
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!


这篇关于如何为我的表单提供通用列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆