VB. NET data center charging system-how to write the appearance layer, vb.net Charging System

Source: Internet
Author: User

VB. NET data center charging system-how to write the appearance layer, vb.net Charging System
The design pattern is detailed on page 103rd of "big talk Design Pattern". It is only the first step for you to read, read, and repeat the examples on the design pattern, next, if we use the design pattern flexibly in our projects and use the design pattern out of the flowers, it would be king. Some people always say that the paper will end with a glimpse, and we will never know how to do this, however, when it comes to practice, it will never work, but the language will not work. The design mode is C #, and the fee for the IDC is VB. in the NET version, the model in the book cannot be connected to the data center, and I don't know how to use it. I can't help it. I just read the blog, ask people, and check the information online. In this way, I have a look, although it is not perfect, it is very precious, because it is the flower that I have struggled for a long time from the dust, and the application of the appearance model is summarized here.
As for the registration function in the data room charging system, before proceeding, we need to do the following:
A. Check whether the student ID exists in the student table;
B. Check whether the card number exists in the card table;
C. Insert a record into the student table;
D. Insert a record into the table;
E. Insert a record in the recharge table;
In the appearance layer, my code is as follows: (this blog post focuses on the style of the appearance layer, and its layer will not be repeated here)

<Span style = "font-size: 18px; "> '************************************* * ******** 'file Name: registerFacade 'namespace: Facade 'internal volume: queries from the card table and student table whether the card number and student number exist. If yes, a prompt is displayed, indicating that the account does not exist. After successful registration, the account is directed to the card table at one time, student table and recharge table write related information 'function: Register 'file relationship:' OPERATOR: Ding Guohua 'small group: Baby scheduler' generation Date: 15:06:56 'version: v2.0 'modify log: 'copyright description: '*************************************** * ***** Public Class RegisterFacade '// <summary>' // depiction: <check whether the student ID exists in the student table> '// </summary>' // <param name = "<enStudent>"> <Student Entity> </param> '// <returns>' // <returns a set of student entities> '// </returns> Public Function QueryStudentNo (ByVal studentNo As String) as List (Of Entity. studentEntity) Dim studentBLL As New BLL. t_StudentBLL Dim myList As List (Of Entity. studentEntity) myList = studentBLL. queryStudentNo (studentNo) If myList. count> 0 Then Throw New Exception ("this student ID already exists") Else Return myList End If End Function '// <summary>' // depiction: <check whether the card number exists in the card table> '// </summary>' // <param name = "<enCard>"> <card entity> </param> '// <returns>' // <returns a collection of card entities> '// </returns> Public Function QueryCardNo (ByVal cardNo As String) as List (Of Entity. cardEntity) Dim cardBLL As New BLL. t_CardBLL Dim myList As List (Of Entity. cardEntity) myList = cardBLL. queryCardNo (CardNo) If myList. count> 0 Then Throw New Exception ("this card number already exists") Else Return myList End If End Function '// <summary>' // depiction: <insert a student information> '// </summary>' // <param name = "<enStudent>"> <Student Entity> </param> '/// <returns> '// <return Boolean value>' // </returns> Public Function InsertStudent (ByVal enStudent As Entity. studentEntity) As Boolean Dim StudentBLL As New BLL. t_StudentBLL Dim flag As Boolean flag = StudentBLL. insertStudent (enStudent) Return flag End Function '// <summary>' // depiction: <insert a card information> '// </summary>' // <param name = "<enCard>"> <card entity> </param> '/// <returns> '// <return Boolean value>' // </returns> Public Function InsertCard (ByVal enCard As Entity. cardEntity) As Boolean Dim CardBLL As New BLL. t_CardBLL Dim flag As Boolean flag = CardBLL. insertCard (enCard) Return flag End Function '// <summary>' // depiction: <insert a recharge message> '// </summary>' // <param name = "<enRecharge>"> <recharge entity> </param> '/// <returns> '// <return Boolean value>' // </returns> Public Function InsertRecharge (ByVal enRecharge As Entity. rechargeEntity) As Boolean Dim RechargeBLL As New BLL. t_RechargeBLL Dim Flag As Boolean Flag = RechargeBLL. insertRecharge (enRecharge) Return Flag End FunctionEnd Class </span>
Next, let's look at the next recharge function. Before proceeding, we need to think about it:
A. Check whether the card number exists in the card table;
B. Insert a recharge record in the recharge table;
C. Update the balance in the card table

Compared with the above registration function, both functions require querying from the card table and inserting a record into the recharge table. So recharge this function, her interface layer (IDAL), D Layer (DAL), Factory-Factory layer, BLL-business logic layer, her code writing method is the same as the above-mentioned registration function, so we don't need to write it once, just call it directly, But how should we write the appearance layer, I can't write any more. According to the previous writing method, I only need to write a method to update the balance in the card table on the appearance layer, to query and insert a recharge record from the card table, you only need to call the registered appearance. However, in this case, the U layer calls two appearance layers, is it the appearance layer? Obviously not. In the big talk Design Model of Dr. Cheng Jie, the appearance is written in a summary of small methods into a general method and written in a large method, how can I write the recharge appearance? As follows:

<Span style = "font-size: 18px; "> '************************************* * ******** 'file Name: rechargeFacade 'namespace: Facade' internal volume: 'function:' file relation: 'OPERATOR: Ding Guohua' small group: Baby scheduler 'generation Date: 22:18:04' version: v2.0 'modify log: 'copyright description: '*************************************** * ***** Public Class RechargeFacade '// <summary>' // depiction: <query card number> '// </summary>' // <param name = "<enCard>"> <card number> </param> '// <returns> '// <return set>' // </returns> Public Function QueryCard (ByVal cardNo As String) as List (Of Entity. cardEntity) Dim cardbll As New BLL. t_CardBLL Dim mylist As List (Of Entity. cardEntity) mylist = cardbll. queryCardNo (cardNo) If mylist. count = 0 Then Throw New Exception ("this card number does not exist") Else Return mylist End If End function' // <summary> '// depiction: <you need to insert a record into the card table to update the balance in the card table. We will write the two into one method, A boolean value> '// </summary>' // <param name = "<enCard>"> <card number> </param> '// /<returns> '// <return set>' // </returns> Public Function Recharge (ByVal enCard As Entity. cardEntity, ByVal enRecharge As Entity. rechargeEntity) As Boolean Dim CardBLL As New BLL. t_CardBLL Dim RechargeBLL As New BLL. t_RechargeBLL Dim Flag (2) As Boolean Flag (0) = RechargeBLL. insertRecharge (enRecharge) Flag (1) = CardBLL. updateCard (enCard) If Flag (0) And Flag (1) Then Return Flag (0) Else Return False End If End FunctionEnd Class </span>
The partner must have doubts. Isn't there still two ways to register the appearance layer above? To explain it simply, when querying the card number, we need to return the object of a card table, find the previous balance from it, and then add the recharge amount, when a new balance is formed, a table entity can be created during update. The recharge party below returns a boolean value. true indicates that the account is successfully recharged. A method cannot return two values, therefore, two methods are written. In general, there are several methods for the specific appearance layer, which are determined by the return value. The second IDC charging system has not been completed. It is to be continued ......



How to write the Anchor attribute of the vbnet control?

. Anchor = AnchorStyles. Bottom or AnchorStyles. Left or AnchorStyles. Right or AnchorStyles. Top

How does VBnet 2008 write user controls?

Refer:
Public Class UserControl1
# Region "variable"
Dim Down_Color As Color = Color. Blue
Dim UP_Color As Color = Color. Gray

Dim Mode As Short = 0
Dim flag As Boolean

Dim offset_X As Integer
Dim offset_Y As Integer

Dim Mouse_P As Point
# End Region

# Region "attributes"
'Press the color
Public Property _ DownColor As Color
Get
Return Down_Color
End Get
Set (ByVal value As Color)
Down_Color = value
End Set
End Property

'Bullet color
Public Property _ UpColor As Color
Get
Return UP_Color
End Get
Set (ByVal value As Color)
UP_Color = value
End Set
End Property

'Sliding Mode 0-horizontal 1-vertical
Public Property _ Mode As Short
Get
Return Mode
End Get
Set (ByVal value As Short)
Mode = value
End Set
End Property
# End Region

Private Sub usercontrol+load (ByVal sender As Object, ByVal e As System. EventArgs) Handles Me. Load
Me. BackColor = UP_Color
End Sub

'Press the mouse
Private Sub usercontrol+mousedown (ByVal sender As Object, ByVal e As System. Windows. Forms. MouseEventArgs) Handles Me. MouseDown
Me. BackColor = Down_Color
Mouse_P = e. Location
Flag = True
End Sub

'Move the mouse
Private Sub usercontrol+mousemove (ByVal sender As Object, ByVal e As System. Windows. Forms. MouseEventArgs) Handles Me. MouseMove
If flag = False Then Ex ...... remaining full text>

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.