Create a dictionary
Bind dictionary content to ComboBox
Cbocategory. initializevaluelistfromdictionary ("databasescript ");
The effect is as follows:
When designing the Windows component ComboBox, the existence of the data dictionary was not taken into account, and the implementation of initializevaluelistfromdictionary was not implemented.
With the expansion of the system, the data dictionary function is implemented in the business system. However, the ComboBox component still does not know anything about the data dictionary. That is, the implementation of ComboBox cannot depend on the data dictionary function, which is not conducive to expansion and maintenance.
Do not changeCodeTo add a new method, you can use the extension method.
Public static class extensionhelper
{
Public static void initializevaluelistfromdictionary (this ComboBox combox, string dictionarycode)
{
}
}
The data dictionary function is implemented.
Continue to apply data dictionaries to employee information to bind Provinces
Cboproverince. initializevaluelistfromdictionary ("Province ");
The SQL script is as follows:
If object_id ('dbo. gbdich ') is not null
Drop table DBO. gbdich
Go
Create Table DBO. gbdich
(
Name nvarchar (50) not null,
Description nvarchar (200) null,
Suincluded bit null,
Constraint pk_gbdich primary key (name)
)
Goif object_id ('dbo. gbdicd') is not null
Drop table DBO. gbdicd
Go
Create Table DBO. gbdicd
(
Code_name nvarchar (50) not null,
Name nvarchar (50) null,
Description nvarchar (200) null,
Suincluded bit null,
Constraint pk_gbdicd primary key (code_name ),
Constraint fk_gbdicd_gbdicd foreign key (name) References DBO. gbdich (name)
)
Go
Unchanged data dictionary changeless
There is a type of data dictionary, and its value will not change. For example, there are only three types of message commands: Receive, send, and reply.
Public Enum messageflowtype
{
Outgoing = 0,
Incoming = 1,
Reply = 2,
}
For example, a report data source is defined as an application database, framework database, or custom database.
Public Enum reportdatasource
{
Companydatabase = 0,
Systemdatabase = 1,
Customdatabase = 2,
}
This data dictionary is directly compiledProgramCentralized, and the binding issue should be considered when designing the ComboBox component
Public void initializevaluelistfromenum (type enumtype, bool allowempty ){}