In this function I used two forms, one to get the original user number, and the other to get the current password, I would like to elaborate:
Similarly, the entity layer:
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" > ' <summary> ' entity layer, storing multiple properties ' </summary> ' ' <remarks></remarks>public Class User ' Defines the UserName property Private _username As String public property UserName As String Get Return _username End Get Set (value as String) _username = value End Set End Property ' Define password attribute Private _ PassWord As String ' public property PassWord As String get Return _password End Get Set (value As String) _password = value end Set end Propertyend class</span>
UI Layer:
First form:
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" >public Class Form1 ' Private Sub btnchange_click (sender as Object, e as EventArgs) Handles btnchange.click
frmchange.show () ' Call the changed form End subend class</span>
a second form:
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" >public Class frmchange Private Sub button1_click (sender as Object, e as EventArgs) Handles Btnchange.click Tr Y ' get data for the presentation layer Dim Nuser as new Loginmodel.user ' instantiates a new entity that is used to pass the entity nuser of Layer B . UserName = TxtUserName.Text.Trim ' passes the user name to the UserName nuser of the entity layer . PassWord = TxtPassWord.Text.Trim ' Pass the password to the entity layer PassWord ' call layer B, login to determine Dim Mgr as New Loginbll.usermananger Call Mgr. CHANGEBLL (nuser) Catch ex as Exception MessageBox.Show (ex. Message.tostring ()) ' Error handling end Try End SubEnd class</span>
BLL layer:
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" >public Class usermananger ' change public Sub CHANGEBLL (ByVal User as Loginmodel.user) Dim Udao as New logindal . Sqlserveruser ' query if the user exists, if there is a change password, if there is no prompt box Dim muser as Loginmodel.user call udao.changdal (user) if IsNothing (muser.username) then MsgBox ("User not present, re-enter", "warning") Else call udao.changdal (user) Invoke Modify function end If End SubEnd class</span>
<span style= "Background-color:rgb (255, 255, 255); ><span style= "Font-family:kaiti_gb2312;font-size:24px;color: #3333ff;" ><strong>dal Layer:</strong></span></span>
<span style= "Background-color:rgb (255, 255, 255);" ></span><pre name= "code" class= "VB" ><span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" > ' Reference namespaces Imports System.dataimports System.Data.SqlClientImports loginmodelpublic Class sqlserveruser Public Conn as New SqlConnection ("Server=zy-pc;database=login;user Id=sa;password = 1") ' Create database connection ' to public Sub changdal (B Yval user as user) Dim sql as String = "Update t_users set [email protected] where [email protected]" The SQL statement for the update number library is Dim cmd as New SqlCommand (SQL, conn) cmd. CommandText = sql cmd. CommandType = CommandType.Text cmd. Parameters.Add (New SqlParameter ("@User", User.username)) cmd. Parameters.Add (New SqlParameter ("@PassWord", User.password)) Conn. Open () cmd. ExecuteNonQuery () ' performs an operation on the database Conn. Close () End subend Class</span>
The "change" of the four key weapons of three-tier database