After 17 days, the data room charging system was written. Although the daily task volume was not set, the overall feeling was okay, it takes about three hours to listen to English every day.
In fact, I think about the whole process of building a data center charging system, that is, getting stuck when logging on to the form, because this is the first time I used three layers, and to be honest with VB. net is not particularly familiar. After the login form can be run, the heap code is probably followed.
This is the package diagram of the charging system of our IDC. The following process is implemented at the login form write layer:
Dall Layer
Considering the problem of changing the database in the future, the Dal layer uses the abstract factory mode. Therefore, the dataaccess layer, idal interface layer, and sqlhelper are mainly used for classes such as SQL calls.
Abstract The Dal layer in factory mode:
Iuserinfo interface (a class in the idal layer in the package diagram), user client access, and access coupling with specific database access (here only the login form is used as an example, therefore, the number of database operations involved is relatively small)
Public Interface IUserInfo Function UserInsert(ByVal entityuserInfo As Entity.enUserInfo) As BooleanEnd Interface
Sqlserveruserinfo class (a class in DAL), used to access the userinfo of SQL Server (how to access the ACCESS database, you can write an access class here)
Public Function UserInquire(entityuserInfo As Entity.enUserInfo) As Boolean Implements IDAL.IUserInfo.UserInquire ' Dim sql As String = String.Format("select * from UserInfo where userName={0} and passWord={1} and Status={2}", entityuserInfo.UserName, entityuserInfo.Password, entityuserInfo.StatusType) Dim sql As String = String.Format("select * from UserInfo where userName={0} and passWord={1} and Status={2}", _ enUserInfo.DBPARAM_USERNAME, enUserInfo.DBPARAM_PASSWORD, enUserInfo.DBPARAM_STATUSTYPE) Dim sqlHelp As New SQLhelper.daBase Dim conn As SqlConnection = sqlHelp.CreateConn(connStr) Dim cmd As SqlCommand = New SqlCommand(sql, conn) AddSqlParameter(cmd, enUserInfo.DBPARAM_USERNAME, SqlDbType.Char, entityuserInfo.UserName) AddSqlParameter(cmd, enUserInfo.DBPARAM_PASSWORD, SqlDbType.Char, entityuserInfo.Password) AddSqlParameter(cmd, enUserInfo.DBPARAM_STATUSTYPE, SqlDbType.Char, entityuserInfo.Status) Dim sdr As SqlDataReader = Nothing Try conn.Open() sdr = cmd.ExecuteReader() sdr.Read() If (sdr.HasRows = True) Then Return True Else Return False End If Catch ex As Exception Return False Finally Close(conn) Close(cmd) Close(sdr) End TryEnd Function
(Many functions such as shutting down the database, closing the record set, and passing parameters are used here. The specific functions are written in sqlhelp and not listed one by one)
Ifacloud interface (Class in the dataaccess package) defines an abstract factory interface for creating an access userinfo table object.
Public Interface IFactory Function creatUserInfo() As IUserInfoEnd Interface
Sqlserverfactory class that implements the ifacloud interface and instantiates sqlserveruser (how is access? You can directly write it here)
Public Class SqlServerFactory : Implements IFactory Public Function creatUserInfo() As IDAL.IUserInfo Implements IFactory.creatUserInfo Dim dalUser As New DAL.sqlUserInfo Return dalUser End Function
The key here is that if you need to change the database, simply add the access class without modifying the source code.
Below is the BLL Layer
Public Function userQuery(ByVal entityUserInfo As Entity.enUserInfo) As Boolean Dim fatory = New DataAccess.SqlServerFactory Dim userInfo As IDAL.IUserInfo = fatory.creatUserInfo Dim flag As Boolean flag = CBool(userInfo.UserInquire(entityUserInfo)) Return flag End Function
The bll layer I wrote is written from the Dal layer, and can also be written according to the UI Layer.
The appearance layer is used to organize and package the data required by the UI Layer.
Fa C Ade appearance layer:
Public Function Logon(ByVal entityUserInfo As Entity.enUserInfo, ByVal entityWorkLog As Entity.enWorkLog) As Boolean Dim user As New BllUserInfo Dim flag As Boolean flag = user.userQuery(entityUserInfo) Return flagEnd Function
Finally, it is the U layer, because the U layer involves the data transmitted by form login and judgment, which is known to everyone. Therefore, we will only write the following two sentences related to Layer 3 in the U layer:
Dim facade = New BllFacade.Logon facade.Logon(entityUserInfo)
The general process is like this. From the beginning to understanding the three layers to finishing the data center charging system, I found that although the data center charging system is not a big system, however, it is indeed easy to maintain after writing with three layers. From the subsequent debugging, we can see that the debugging is basically not very laborious. Therefore, spend some time studying the next three layers, it is necessary.