Vb. NET edition room charge system---appearance layer how to write

Source: Internet
Author: User

design mode, "Big talk design mode" on the 103th page detailed explanation, do not remember this piece of knowledge of the small partners can flip through, read the design pattern, knocked over the book example, just learning the first step, and then, if in our project flexible application, the design pattern with flowers, is the king, some people always say, Paper on the end of light, I know this matter to preach, but really to preach time, always does not work, the language does not come over, the design pattern is C # language, The room charge is vb.net version, books on the mode and the computer room is not connected, do not know how to apply, no way, suppress Bai, look at the blog, ask people, online search information, so, suppress a appearance, although not too perfect, but very valuable, because that is my tangled long time from the dust out of the flower, on the appearance of the application of the small summary here.
In the case of a registration function in the computer room charge system, we need to do the following thinking before proceeding:
A, from the Student table query, whether there is the school number;
b, from the card table query, whether there is the card number;
C, insert a record in the student's table;
D, insert a record in the card table;
E, insert a record in the recharge table;
In the appearance layer My code is as follows: (this blog post, focus on the appearance of the layer of writing, her layer will not repeat it again)
<span style= "FONT-SIZE:18PX;" > ' ********************************************** ' file name: Registerfacade ' namespace: Facade ' content: Query from card-table and student tables for the existence of the card number and number, existence , give a hint, do not exist, after registering successfully, write the relevant information to the card table, student table and top-up table once, ' function: Register ' file relationship: ' Author: Ding ' Group: Baby plan ' build date: 2014/7/17 15:06:56 ' version number: V2.0 ' edit log: ' Copyright note : ' **********************************************public Class registerfacade '///<summary> '///depiction:< Check the student form for the number > '///</summary> '//<param name= ' <enStudent> ' >< student entity ></param> ' <returns> '///< Returns a collection 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 ("The number already exists") Else Return myList End If End Function '///<summary>    '////depiction:< from the card form to check the existence of the card number > '///</summary> '//<param name= <enCard> >< card entity >& Lt;/param> '///<returns> '///< returns a collection of card entities > '///</returns> public Function Querycardno (by Val 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.cou NT > 0 Then Throw New Exception ("The card number already exists") Else Return myList end If End Functio n '///<summary> '///depiction:< Insert a Student information > '///</summary> '//<param name= ' <enstuden T> >< Student Entities ></param> '//<returns> '///< returns a Boolean value > '///</returns> public funct Ion Insertstudent (ByVal enstudent as entity.studententity) as a 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 > '///&LT;/SUMMARY&G    T '///<param name= ' <enCard> >< card entity ></param> '///<returns> '///< return boolean > '///&LT ;/returns> public Function Insertcard (ByVal Encard as entity.cardentity) as a 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> ' gt;< Recharge Entity ></param> '////<returns> '///< returns a Boolean value > '///</returns> public Function Ins Ertrecharge (ByVal Enrecharge as entity.rechargeentity) as a Boolean Dim rechargebll as New BLL. T_RECHARGEBLL Dim flag as Boolean flag = Rechargebll.insertrecharge (enrecharge) Return Flag End Fu Nctionend class</span>
Then, let's look at the next recharge function, before we start, we need to do a bit of thinking:
A, from the card table inside query, whether there is the card number;
B, insert a top-up record in the recharge list;
C, the balance in the Update card table

Compared with the above registration function, two functions need to be queried from the card table and insert a record into the top-up list. So recharge this function, her interface layer (idal), D layer (DAL), factory-factory layer, bll-business logic layer, her code writing and the above registration function is the same, we do not need to write once, directly call on it, but how to write the appearance layer, It's written, it's not going to go down, according to the previous wording, only need to write an Update card table in the appearance of the balance of the method on the line, from the card table and insert a top-up record in the recharge table, only need to call the registration of the appearance can be, but, so write, U layer on the call of two appearance layer, that or the appearance layer? Obviously not, look at people geoscience Teacher's big talk design pattern, the appearance is the small method to summarize into a total method, written in a large method inside, that recharge the appearance of how to write it? As follows:

<span style= "FONT-SIZE:18PX;"    > ' ********************************************** ' filename: Rechargefacade ' namespace: Facade ' content: ' function: ' File relationship: ' Author: Ding ' small Group: Baby plan ' build date: 2014/7/18 22:18:04 ' version number: V2.0 ' Modify log: ' Copyright note: ' **********************************************public Class Rechargefacade '///<summary> '//depiction:< Enquiry Card number > '///</summary> '//<param name= ' &lt ;encard> ">< card number ></param> '//<returns> '///< return collection > '///</returns> public Fu Nction 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 ("The card number does not exist") Else Return mylist end If End Function '///<summary> '///depiction:< need to insert a record into the card table, update the balance in the card table, we write these two as a method, because all need to return a Boolean value > '///</summary&gt    ; '///<param NamE= "<enCard>" >< card number ></param> '///<returns> '///< back to set > '///</returns> Pub LIC 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) = Cardb LL.        Updatecard (Encard) If flag (0) and flag (1) then return flag (0) Else return False End If End FunctionEnd class</span>
Small partners must have doubts, the above registered appearance layer is not still there are two methods? Simple, explain, because, when the query card number, we need to return a card table of the entity, and then find the previous balance from the inside, and then add the amount of recharge, form a new balance, the update can have a card table entity, the following recharge of the side of our return value Boolean, True to recharge successfully, a method can not have two return value, so write two methods, in general, the concrete appearance layer has several methods, is determined by the return value. Second time computer room charge system, not finished, to be continued ...


Vb. NET edition room charge system---appearance layer how to write

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.