مواد لازم : 3 تا فرم -( ايجاد حساب كاربري - تغيير و حذف حساب كاربري - تغيير رمز ورود ) ، يك بانك اطلاعاتي با فيلد به مقدار لازم ، توابع Query و ...

ابتدا فرم ها رو به اين ترتيب بسازيد كه كدهاشونو اينجا گذاردم مي تونيد Copy‌ كنيد و استفاده كنيد:

ايجاد حساب كاربري:



كد فرم :


Public Class CreateAccount
Enum UserTypes
Limit = 0
Admin = 1
End Enum
Public Property UserName() As String
Get
Return UserNameBox.Text
End Get
Set(ByVal value As String)
UserNameBox.Text = value
End Set
End Property
Public Property Password() As String
Get
Return PasswordBox.Text
End Get
Set(ByVal value As String)
PasswordBox.Text = value
End Set
End Property
Public Property ConfirmPassword() As String
Get
Return ConfirmPasswordBox.Text
End Get
Set(ByVal value As String)
ConfirmPasswordBox.Text = value
End Set
End Property
Public Property Description() As String
Get
Return DescriptionBox.Text
End Get
Set(ByVal value As String)
DescriptionBox.Text = value
End Set
End Property
Dim UserTP As UserTypes
Public Property UserType() As UserTypes
Get
Return UserTP
End Get
Set(ByVal value As UserTypes)
UserTP = value
End Set
End Property
Public Property SavePass() As Boolean
Get
Return SaveUserPassBox.Checked
End Get
Set(ByVal value As Boolean)
SaveUserPassBox.Checked = value
End Set
End Property


Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
ErrorProvider1.Clear()
If Len(UserNameBox.Text) = 0 Then
ErrorProvider1.SetError(UserNameBox, "نام کاربري را وارد کنيد")
Exit Sub
End If

FirstForm.UsersTableAdapter1.Fill(FirstForm.UserAc countsDataSet1.Users)
With FirstForm.UserAccountsDataSet1.Users
For I = 0 To .Count - 1
If Me.UserName = Trim(.Item(I).UserName) Then
ErrorProvider1.SetError(UserNameBox, "اين نام کاربري قبلا استفاده شده است")
Exit Sub
End If

Next
End With
If Not PasswordBox.Text = ConfirmPasswordBox.Text Then
If Len(PasswordBox.Text) > 0 Or Len(ConfirmPasswordBox.Text) > 0 Then
ErrorProvider1.SetError(PasswordBox, "رمز ورود و تائيد آن با هم همخواني ندارد")
ErrorProvider1.SetError(ConfirmPasswordBox, "رمز ورود و تائيد آن با هم همخواني ندارد")
Exit Sub
End If

End If

Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FBD As New OpenFileDialog With {.Title = "Select an image file..."}
With FBD

If .ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then Exit Sub
'ROSTAM Statements
UserPhotoBOX.Tag = .FileName
UserPhotoBOX.ImageLocation = .FileName
' UserPhotoBOX.Image = Image.FromFile(.FileName)
End With
End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
UserTP = UserTypes.Limit
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
UserTP = UserTypes.Admin
End Sub

Private Sub CreateAccount_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If UserTP = UserTypes.Admin Then
RadioButton2.Checked = True
Else
RadioButton1.Checked = True
End If
End Sub
End Class