The last time we saw how the D layer worked, I now briefly demonstrate how my appearance and Layer B are dealing with the U and D layers.
First of all, I told you that my appearance is in accordance with the interface function division, the granularity is a little small, we do, remember the appearance of a few on the line, but not without, u layer can not directly call B layer, this will increase the U layer and B-layer coupling:
' ************************** ' file name: Userinfo_bll ' namespace: BLL ' content: ' function: ' File relationship: ' Author: Qiu Xia ' group: Qiu-Summer ' Generation Date: 2014-06-07 17:36: 40 ' Version number: V1.0.0.0 ' changelog: ' Copyright note: ' ***************************imports idalpublic Class loginbll '//<summary> '// depiction:< Query the user table for the existence of the username and password > '///</summary> '//<param name= ' < parameter name > ' >< parameter Description ></p Aram> '///<returns> '///< to return an entity,entity> '///</returns> public Function isexits (Byva L user as entity.loginentity, ByVal Worklog as entity.worklogentity) as Boolean Dim Iuser as Idal. Iuser Dim Factory As New Factory.dataaccess Dim iworklog as Idal. Iworklog Iuser = Factory. Createuserinfo () Iworklog = Factory. Createworklog () Dim table As New DataTable Dim table1 As new DataTable table = Iuser.user_login (User) If table. Rows.Count = 0 Then Return False Else Entity.LoginEntity.UserLevel = table. Rows (0) (3) If Iworklog.saveworklog (Worklog) then return True End If return True End If End FunctionEnd Class
The B-layer is not only used to invoke the D-layer, but we often forget that theB-layer is used to make logical judgments .
Look at the appearance layer:
' ************************** ' file name: Flogin ' namespace: Facade ' inner capacity: ' work Energy: ' File relationship: ' creator: Qiu Xia ' small Group: Qiu Xia ' build date: 2014-06-07 17:41:39 ' version number: V1.0.0.0 ' Modify log: ' Copyright note: ' ***************************imports bllpublic Class Fa_ Login ' ///<summary>//depiction:< to determine if the user name and password are incorrect > '///</summary> '/// < param name= "< parameter name >" >< parameter Description ></param> '/// <returns> '///< returns a string type, Can be used directly in MsgBox > ' ///</returns> public Function flogin (ByVal user as entity.loginentity, worklog as entity.worklogentity) as String Dim confirmuserbll as New BLL. LOGINBLL If confirmuserbll.isexits (user, Worklog) = False then return "wrong input" Else return "Login Successful" End If End FunctionEnd Class
In fact, if this is not a class, but a function is more perfect, it should be noted here: the appearance of this work:
This figure is very obscure in design mode, but I only remember this diagram. Essence.
How does the U-layer call the appearance?
' ************************** ' file name: Frmlogin ' namespace: UI ' content: ' function: ' File relationship: ' Author: Qiu Xia ' group: Qiu-Xia ' date generated: 2014-06-07 16:53:46 ' edition Number: V1.0.0.0 ' changelog: ' Copyright note: ' ***************************public Class frmlogin Private Sub btnlogin_click (sender as Object, e as EventArgs) Handles Btnlogin.click Dim Login As New Entity.loginentity Dim flogin As New Facade.fa_logi n Dim strresult as String login. UserID = TxtUserID.Text.Trim () login. Password = TxtPassword.Text.Trim () Entity.LoginEntity.UserHead = TxtUserID.Text.Trim () Dim Worklog as New En Tity. Worklogentity Worklog. Logindatetime = DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss") Worklog. Status = "on duty" Worklog. UserID = Entity.LoginEntity.UserHead Worklog.computer = System.Net.Dns.GetHostName (). ToString () strresult = Flogin.flogin (login, Worklog) ' Insert worklog data Select Case strresult case ' input has Error "MsgBox (" input error, please re-enter ") TXTUSERID.FOCUS () case "landing Success" MsgBox ("Landing success") Entity.WorkLogEntity.Login_DateTime = Worklog. Logindatetime me.hide () frmmain.show () End Select End Sub Private Sub Btnquit_c Lick (sender as Object, e as EventArgs) Handles Btnquit.click me.close () End subend Class
Notice that when you call, take a good look at the return value, the facade layer returns a string type, then the call, that is:
Dim str As String =fa_login (Login,worklog)
So that's it, U-layer Select Case STR, you can determine whether it is successful.
About the appearance of the layer I was good to say, the design of the appearance in:
http://blog.csdn.net/qiumuxia0921/article/details/33738319
The writing is very clear, say more useless.