04-11-12, 07:42 PM
,Hi everyone
:I'm facing an issue in my project every time that I'm trying to use "openfiledialog", and you can see the issue below
[ATTACH=CONFIG]1218[/ATTACH]
:And I have the following
.I had "Login Form", and I deleted it
.Changed the startup form to the MDIParent
!Debug the project and it's worked just fine
:The "Login Form" is
[ATTACH=CONFIG]1219[/ATTACH]
:And the code of the "Login Form" is
:I'm facing an issue in my project every time that I'm trying to use "openfiledialog", and you can see the issue below
[ATTACH=CONFIG]1218[/ATTACH]
:And I have the following
.I had "Login Form", and I deleted it
.Changed the startup form to the MDIParent
!Debug the project and it's worked just fine
:The "Login Form" is
[ATTACH=CONFIG]1219[/ATTACH]
:And the code of the "Login Form" is
كود :
Imports System.Data.OleDb
Public Class LoginFrm
Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
If UsersCount() = True Then
MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
AddUserFrm.MdiParent = MainFrmvb
AddUserFrm.Show()
'Me.Hide()
Me.Close()
Exit Sub
End If
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Me.TextBox1.Text = "" Then
MsgBox("You should enter the user name", vbOKOnly, "Login")
Exit Sub
ElseIf Me.TextBox2.Text = "" Then
MsgBox("You should enter the password", vbOKOnly, "Login")
Exit Sub
ElseIf Me.TextBox1.Text = "Administrator" AndAlso Me.TextBox2.Text = "Administrator" Then ' this code I should remove it from here
AfterLogin.MdiParent = MainFrmvb
AfterLogin.Show()
'Me.Hide()
Me.Close()
Else
If UserLoggedIn() = True Then
MsgBox("Wrong username or password", vbCritical, "Login")
Else
'checkpermissions()
MsgBox("You logged in successfully", vbInformation, "Login")
AfterLogin.Label1.Text = test()
AfterLogin.MdiParent = MainFrmvb
AfterLogin.Show()
'Me.Hide()
Me.Close()
End If
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Application.Exit()
End Sub
Function UsersCount()
' get the password from the database
Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
Dim TB = DA.User_Count
If TB = 0 Then
Return True
Else
Return False
End If
End Function
Function UserLoggedIn()
' get the password from the database
Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
Dim TB = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
If TB.Rows.Count = 0 Then
Return True
Else
Return False
End If
End Function
Function test()
Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
Dim TBS = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
Return TBS.Rows(0).Item(1)
End Function
End Class
:I searched all the code, and I did the following
كود :
Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'If UsersCount() = True Then
MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
AddUserFrm.MdiParent = MainFrmvb
AddUserFrm.Show()
Me.Hide()
'Me.Close()
'Exit Sub
'End If
End Sub
!If you noticed that I canceled the calling of the function "UsersCount()" and everything works fine
.I don't know what is the problem in that function
?Do you have any suggestion for me
.I'll appreciate it
.Best
.I don't know what is the problem in that function
?Do you have any suggestion for me
.I'll appreciate it
.Best