Expressapp framework-Introduction to DC Technology series (1) use DC to implement real entities

Source: Internet
Author: User

PreviousArticleI introduced the DC and introduced the official description and features of the DC. At the beginning, I will start with the actualCodeProject to gradually introduce a DC-based procurement system,

First, we first use the Microsoft ide tool vs2005/2008/2010 to build an xaf application.ProgramHere, I use vs2010 to create an xaf winform desktop application mypurchasesystem, such:

 

To facilitate the organization of DC files, I put the DC files in the Entities folder. Let's start to design and define the DC. Before getting started, let's first understand the composition of DC, here we will first define a "Product Information" DC:

C # code

 

1 [Domaincomponent ()]
2 [Navigationitem ( " Basic Information " )]
3 [Xafdisplayname ( " Goods Materials " )]
4 [Xafdefaultproperty ( " Goodscode " )]
5 Public   Interface Igoodsinfo
6 {
7 [Ruleuniquevalue ( "" , Defaultcontexts. Save)]
8 [Rulerequiredfield ( "" , Defaultcontexts. Save)]
9 [Visibleinlookuplistview ( True )]
10 [Xafdisplayname ( " Goods Code " )]
11 String Goodscode { Get ; Set ;}
12 [Xafdisplayname ( " Item Name " )]
13 [Rulerequiredfield ( "" , Defaultcontexts. Save)]
14 String Goodsname { Get ; Set ;}
15 [Xafdisplayname ( " Product Specifications " )]
16 String Goodsspec { Get ; Set ;}
17 }

 

VB Code

1 < Domaincomponent () > _
2   < Navigationitem ( " Basic Information " ) > _
3   < Xafdisplayname ( " Goods Materials " ) > _
4   < Xafdefaultproperty ( " Goodscode " ) > _
5   Public   Interface Igoodsinfo
6   < Ruleuniquevalue ( "" , Defaultcontexts. Save) > _
7   < Rulerequiredfield ( "" , Defaultcontexts. Save) > _
8   < Visibleinlookuplistview ( True ) > _
9   < Xafdisplayname ( " Goods Code " ) > _
10   Property Goodscode () As   String
11   < Xafdisplayname ( " Item Name " ) > _
12   < Rulerequiredfield ( "" , Defaultcontexts. Save) > _
13   Property Goodsname () As   String
14   < Xafdisplayname ( " Product Specifications " ) > _
15   Property Goodsspec () As   String
16   End Interface

 

The code above will find that this is actually an interface, but there are some special attributes on the basis of the interface,

Domaincomponent defines this interface as a DC,

<Navigationitem (" item")> defines the navigation group of the DC in the UI as ""

Xafdisplayname defines the localized display name (including the member name) of the DC.

Property... defines DC members (table fields)

Ruleuniquevalue defines the unique validation rules for this field

Rulerequiredfield defines that this field must contain characters

The following code registers the currently defined DC in the xaf module so that the DC can run as expected:

Public overrides sub setup (byval application as xafapplication)
If (not xaftypesinfo. isinitialized) then
Xaftypesinfo. instance. addentitytogenerate ("mycomponent", GetType (igoodsinfo), GetType (baseobject ))
End if
Mybase. Setup (Application)
End sub

Now let's run the program to see what the effect is.

 

We can see that the program has been running according to our expected results. To achieve this effect, we only need 3 minutes. If we develop this effect by ourselves, we should know how long it will take, okay. In this article, we understand the basic definition of DC. In the next article, we will understand the relationship between entities in DC,

Typical master detail table structure, purchase order
 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.