Entrusted login of the data room charging system and the data room Charging System
I forgot the specific time. The specific location should be 511. The teacher said, "in the future, your code cannot be called, and all of them are delegated ". If I remember correctly, it may be that I heard the mistake ......
Recently, I started the cooperative version of the data center charging system. Then I thought about whether I could add the entrusted item to our data center. Then I checked the information there and checked the information! I checked it for more than a day... at last, I got it done!
Although the function is implemented, I am not sure whether this is correct or wrong! This is a valuable comment to our teachers and sisters!
I will not talk about delegation. If you don't understand it, you can look at the C # delegation. Although it is not particularly detailed, you can also understand it. Now let's take a look at the specific code implementation:
The familiar D-Layer Code:
Imports System. data. sqlClientPublic Class DAL Public Function Login (ByVal strUserID As String, ByVal strPassword As String) As Boolean create a SqlConnection Dim conn As New SqlConnection ("server = .; database = ChargeSystem; uid = sa; pwd = 123456 ") 'create a SqlCommand to check whether the user name and password have Dim cmd As New SqlCommand (" select count (*) from T_User where userID = '"& strUserID &"' and password = '"& strPassword &"' ", conn) conn. open () Dim count As Integer = cmd. executeScalar () conn. close () If count> 0 Then Return True 'user name and password are correct Else Return False End If End FunctionEnd Class
Let's look at the new B layer:
Public Class BLL 'declares the Delegate LoginEventHandler. The Delegate represents two parameters and the return value is Public Delegate Function LoginEventHandler (ByVal strUserID As String, ByVal strPassword As String) as Boolean Public Function Login (ByVal strUserID As String, ByVal strPassword As String) as Boolean Dim dal As New DAL 'add the Login method in the DAL class to delegate loginEventHandler Dim loginEventHandler As LoginEventHandler = AddressOf dal. login Dim flag As Boolean flag = loginEventHandler (strUserID, strPassword) Return flag End FunctionEnd Class
Finally, let's look at the new U layer:
Public Class Form1 'declares the Delegate LoginEventHandler. The Delegate represents two parameters and the return value is Public Delegate Function LoginEventHandler (ByVal strUserID As String, ByVal strPassword As String) as Boolean Private Sub button#click (sender As Object, e As EventArgs) Handles btnLogin. click Dim bll As New BLL Dim loginEventHandler As LoginEventHandler Dim strUserID As String = txtUserID. text. trim () Dim strPassword As String = txtP Assword. text. trim () Dim flag As Boolean 'add the Login method in the DAL class to the delegate loginEventHandler = AddressOf bll. login flag = loginEventHandler (strUserID, strPassword) If flag = True Then MsgBox ("Login successful at last! ") Else MsgBox (" incorrect user name or password! ") TxtPassword. text = "" txtUserID. focus () txtUserID. selectAll () End If End Sub Private Sub btnExit_Click (sender As Object, e As EventArgs) Handles btnExit. click Me. close () End SubEnd Class
Finally, let's look at our results:
In VB. NET, events cannot be declared by a delegate type with a return type, which is different from that in C! Then it took me a lot of effort to make the difference! But finally, I was very happy to make it! Hey ......
IDC charging system source code
Add me to help you
How to crack the school data room Charging System
You can check the charging system and find it on the computer. You can also go to the computer of the charging system to check the disk on which the installation directory is located and the files,
What kind of floppy disk are you using, the CD, the USB flash disk, boot the computer, and delete these files under DOS, so the boot will not boot ..