Vb. NET edition room charge system---Seven fairies system login

Source: Internet
Author: User

VB. NET first edition of the computer room charge system, the completion of the acceptance of the time, the problem is also greatly exist, no use on the design mode, what triggers, stored procedures, are not used to see its small partners, seven layer implementation login? What is that, compared to my three floor, more than twice times plus one, by looking at the information, look at the blog, suppressed for a few days, finally, suppressed a seven fairies---seven layers to achieve system login, seven daughters, their duties, perfect match, derived from many beautiful stories.

From the three floor to jump to seven layers, a kind of crossing the feeling, plainly is not, but also want to escape the feeling, but life, some things can not with their own temperament, like to do, do not like, do not do, no way, has been suppressed, has been suppressed, finally, the system login realized, and then, Summarize the knowledge about seven-tier system login. As the saying goes, a picture, can express the words cannot describe the emotion and the world, now let us look at the computer room charge System Package diagram, as follows:



First, we analyze the system login, what we need to do to determine whether the user exists, determine whether the user name and password is consistent, after the successful login, you need to add a work record in the Worklog table. This blog post on the implementation of a simple description of the system login, add work record again this does not repeat. Next, the Code implementation section:

First layer: idal-Data Interface access layer, place interface function.

<span style= "FONT-SIZE:18PX;" ><span style= "FONT-SIZE:18PX;" > ' ********************************************** ' file name: Iuser ' namespace: Idal ' inner    Capacity: Implement Interface ' Power    : Create interface ' file relationship: '    do By: Ding ' small    Group: Baby plan ' build date: 2014/7/9 8:44:27 ' version number: V2.0 ' Modify log: ' Copyright note: ' ********************************************** Public Interface Iuser    '//<summary> '//    depiction:< Select Users > '///    </summary>    '// <param name= "<enUser>" >< user entities ></param> '///    <returns>    '///< returns a user entity > '///     </returns>    Function Selectuser (ByVal enuser as entity.userentity) as List (of entity.userentity) End interface</span></ Span>

The second layer: Layer D-data access layer, through the transfer of SQL statements to SqlHelper to achieve specific additions and deletions and other functions.

<span style= "FONT-SIZE:18PX;" ><span style= "FONT-SIZE:18PX;" > ' ********************************************** ' file name: T_userdal ' namespace: DAL ' content: User name and password judgment ' function: Query user name and password is correct ' document relationship: ' Author: Ding ' Group: Baby plan ' build date: 2014/7/9 9:03:17 ' version number: V2.0 ' Modify log: ' Copyright note: ' ********************************************** Imports System.Data.SqlClientImports idalpublic Class t_userdal:implements iuser '///<summary> '//Depicti    on:< query username and password correctly > '///</summary> '//<param name= ' <enUser> ' >< user entity ></param> '///<returns> '///< returns a collection of user entities > '///</returns> public Function selectuser (ByVal enuser as Ent ity.  userentity) as List (of entity.userentity) Implements Iuser.selectuser Dim strText as String = "SELECT * FROM T_user where [email protected] and [email protected] "' SQL statement Dim Cmdtype as CommandType = CommandType.Text ' Command type Dim Parameter as SqlParameter () ' Pass parameter Parameter = {New SqLparameter ("@UserID", Enuser.userid), New SqlParameter ("@password", Enuser.password)} Dim Sqlhe Lper as New SqlHelper ' instantiates an object SqlHelper This class Dim dt As New DataTable Dim myList As List (of entity.userentity  ) dt = sqlhelper.executereadertable (StrText, Cmdtype, Parameter) ' Call SqlHelper executereadertable method myList = Entityhelper.converttolist (of Entity.userentity) (DT) Return myList End functionend class</span></span& Gt

The third layer: factory-factory layer, big talk design mode in the abstract factory and configuration file This piece has detailed introduction, do not understand the small partners can query "Liar design mode" Page 141th, the main role of the factory layer is to apply configuration files and reflection to implement the database replacement function.

<span style= "FONT-SIZE:18PX;" ><span style= "FONT-SIZE:18PX;" > ' ********************************************** ' file name: DataAccess ' namespace: Factory ' inner    Capacity: Create interface '    Work energy: Create interface ' file relationship : '    Creator: Ding ' small    Group: Baby plan ' build date: 2014/7/9 8:41:23 ' version number: V2.0 ' Modify log: ' Copyright note: ' ***************************************** Imports system.reflectionpublic Class dataaccess '//<summary> '///    depiction:< Create user interface > '///    </summary> '//    <param name= <> ' ><></param> '///    <returns>    '///< returns iuserdal>    '    //</returns> public Function createiuser () as Idal. Iuser        Return CType (Assembly.Load ("DAL"). CreateInstance ("DAL. T_userdal "), Idal. Iuser)    End functionend class</span></span>

Layer Fourth: The BLL layer-the Business logic layer, query the user name and password is correct, instance chemical factory, then define the interface variable, call the method in the factory, return a collection of user entities.

       

<span style= "FONT-SIZE:18PX;" ><span style= "FONT-SIZE:18PX;" >imports idal ' ********************************************** ' file name: T_userbll ' namespace: BLL ' inner    Capacity: Business Logic Layer '    work energy: Query user name and password are correct ' file relationship: ': '    Ding ' small    Group: Baby plan ' build date: 2014/7/9 9:02:30 ' version number: V2.0 ' Modify log: ' Copyright note: ' ************************ Public Class T_USERBLL    '//<summary>    '///depiction:< Check the correct user name and password >    '///</summary> '//    <param name= <enUser> >< user entity ></param> '///    <returns >    '///< returns a collection of user entities >    '    ///</returns> public Function selectuser (ByVal Enuser as entity.userentity) as List (of entity.userentity)        Dim factory As New factory.dataaccess        Dim iuser as Idal. Iuser        Dim MyList as List (of entity.userentity)        Iuser = Factory. Createiuser ()        myList = Iuser.selectuser (enuser)        Return myList    End functionend class</span>< /SPAN>

Fifth floor: facade-appearance layer, "Big talk design mode" 103 pages have specific related introduction.

<span style= "font-size:18px;" ><span style= "FONT-SIZE:18PX;"    > ' ********************************************** ' filename: Loginfacade ' namespace: Facade ' content: ' function: ' File relationship: ' Author: Ding ' small Group: Baby plan ' build date: 2014/7/9 8:41:05 ' version number: V2.0 ' Modify log: ' Copyright note: ' **********************************************public Class Loginfacade '///<summary> '//depiction:< Select Users > '///</summary> '//<param name= ' <en User> ">< user entities ></param> '//<returns> '///< returns a collection of user entities > '///</returns> Pub Lic Function Selectuser (ByVal enuser as entity.userentity) as List (of entity.userentity) Dim USERBLL as New BLL. T_USERBLL Dim MyList as List (of entity.userentity) myList = Userbll.selectuser (enuser) If Mylist.coun t = 0 Then Throw New Exception ("Username or password input error") Else Return myList end If End Function End Class</span></span> 

Layer Sixth: UI Layer-user display layer, U layer is responsible for data input and output, call Fa?ade layer to verify the User class Query method to confirm the existence of the user, and finally by calling the Fa?ade layer method login.

<span style= "FONT-SIZE:18PX;" ><span style= "FONT-SIZE:18PX;"    >imports System.Windows.Forms ' ********************************************** ' file name: Frmlogin ' namespace: UI ' content: User display layer ' function Can: Confirm that the user exists ' file relation: ' Author: Ding ' Group: Baby plan ' build date: 2014/7/8 17:51:07 ' version number: V2.0 ' changelog: ' Copyright note: ' ********************************* Public Class Frmlogin Public Shared enlogin as New entity.userentity '///<summary> '///Depic tion:< confirm that the user exists > '///</summary> '//<param name= ' <> ' ><></param> '///<ret  Urns> '///< Login failed to prompt, login successfully into main interface > '///</returns> Private Sub Btnconfirm_click (sender as Object, E as EventArgs) Handles Btnconfirm.click Dim facade As New Facade.loginfacade Dim myList As New List (of entity.u Serentity) Dim enuser As New entity.userentity ' package entity Dim flag As Boolean Try enuser.u Serid = TxtUserName.Text.Trim () Enuser.password = txtpassword.text.tRim () MyList = facade. Selectuser (enuser) If mylist.count > 0 Then MsgBox ("Login Successful") Dim Enworklog as Ne W entity.worklogentity enworklog.userid = TxtUserName.Text.Trim () enworklog.logindate = CStr (Format (now (), "Yyyy-mm-dd")) Enworklog.logintime = CSTR (Format (now (), "HH:mm:ss")) Enworklo  G.status = "on duty" Enworklog.computer = Environment.getenvironmentvariable ("USERNAME") flag = Façade. Insertworklog (enworklog) Enlogin.userid = Mylist.item (0). UserID enlogin.level = Mylist.item ( 0). Level End If Catch ex as Exception MessageBox.Show (ex.        Message.tostring ()) Txtusername.focus () txtusername.selectall () txtPassword.Text = "" End Try End Sub Private Sub Btncancel_click (sender as Object, e as EventArgs) Handles Btncancel.click Me. Close () End Subend class</span></span> 

The seventh floor: SqlHelper, the previous blog post has the related introduction, here, does not introduce each one. Since then, a small login function has been achieved, in the seven-layer login has not been formed, a variety of entanglements, a variety of do not want to do, a quick to the point of the feeling, but after the discovery, this critical point is open three bounded boundary, opened, found the world so beautiful and colorful. As the story of the Seven fairies, our seven-level login is also their own duties, in their own jobs to fulfill their responsibilities.

Second Edition computer room charge system, not finished, to be continued ...

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.