SirReadAlot
asked on
How to stop an if statement
Hi experts,
i have these two if statements. if a the updateUser.text = "Add User" And LicenseDB.AddUser(userProf ile) then step
one should run
========================== ========== =========o ne======== ==
If btnUpdateUser.Text = "Add User" And LicenseDB.AddUser(userProf ile) Then
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That user details already exists."
End If
else two should run
========================== two======= ========== ========== =
If btnUpdateUser.Text = "Update User" And LicenseDB.UpdateUser(userP rofile) Then
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That user details already exists."
End If
Me.SetControlState(Control State.NoSe lection)
LoadData()
the proble is that when i add a user it displays
lblmsg.Text = "That user details already exists." ============from step two.
How can I stop it from running into step two
==========full code=========
Private Sub btnUpdateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateUser.Click
'Initialing the controls
Dim userProfile As New UserProfile
userProfile.userProfileID = txtUserID.Text
userProfile.userLoginID = txtUserID.Text
userProfile.state = ddlEmp.SelectedItem.Value
userProfile.firstName = txtFirstName.Text
userProfile.lastName = txtLastName.Text
userProfile.address1 = txtAddress1.Text
userProfile.address2 = txtAddress2.Text
userProfile.city = txtCity.Text
userProfile.state = ddlState.SelectedValue
userProfile.email = txtEmail.Text
userProfile.phone = txtphone.Text
userProfile.zip = txtZip.Text
userProfile.employeeflag = ddlEmp.SelectedValue
userProfile.username = txtUserName.Text
userProfile.password = txtCreatePass.Text
'update users
If btnUpdateUser.Text = "Add User" And LicenseDB.AddUser(userProf ile) Then
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That user details already exists."
End If
If btnUpdateUser.Text = "Update User" And LicenseDB.UpdateUser(userP rofile) Then
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That user details already exists."
End If
Me.SetControlState(Control State.NoSe lection)
LoadData()
End Sub
#End Region
thanks
i have these two if statements. if a the updateUser.text = "Add User" And LicenseDB.AddUser(userProf
one should run
==========================
If btnUpdateUser.Text = "Add User" And LicenseDB.AddUser(userProf
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That user details already exists."
End If
else two should run
==========================
If btnUpdateUser.Text = "Update User" And LicenseDB.UpdateUser(userP
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That user details already exists."
End If
Me.SetControlState(Control
LoadData()
the proble is that when i add a user it displays
lblmsg.Text = "That user details already exists." ============from step two.
How can I stop it from running into step two
==========full code=========
Private Sub btnUpdateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateUser.Click
'Initialing the controls
Dim userProfile As New UserProfile
userProfile.userProfileID = txtUserID.Text
userProfile.userLoginID = txtUserID.Text
userProfile.state = ddlEmp.SelectedItem.Value
userProfile.firstName = txtFirstName.Text
userProfile.lastName = txtLastName.Text
userProfile.address1 = txtAddress1.Text
userProfile.address2 = txtAddress2.Text
userProfile.city = txtCity.Text
userProfile.state = ddlState.SelectedValue
userProfile.email = txtEmail.Text
userProfile.phone = txtphone.Text
userProfile.zip = txtZip.Text
userProfile.employeeflag = ddlEmp.SelectedValue
userProfile.username = txtUserName.Text
userProfile.password = txtCreatePass.Text
'update users
If btnUpdateUser.Text = "Add User" And LicenseDB.AddUser(userProf
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That user details already exists."
End If
If btnUpdateUser.Text = "Update User" And LicenseDB.UpdateUser(userP
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That user details already exists."
End If
Me.SetControlState(Control
LoadData()
End Sub
#End Region
thanks
ASKER
i will try this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
will try this as well
ASKER
THANKS
ASKER
I USED THIS
#Region " btnUpdateUser Subroutine "
Private Sub btnUpdateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateUser.Click
'Initialing the controls
Dim userProfile As New UserProfile
userProfile.userProfileID = txtUserID.Text
userProfile.userLoginID = txtUserID.Text
userProfile.state = ddlEmp.SelectedItem.Value
userProfile.firstName = txtFirstName.Text
userProfile.lastName = txtLastName.Text
userProfile.address1 = txtAddress1.Text
userProfile.address2 = txtAddress2.Text
userProfile.city = txtCity.Text
userProfile.state = ddlState.SelectedValue
userProfile.email = txtEmail.Text
userProfile.phone = txtphone.Text
userProfile.zip = txtZip.Text
userProfile.employeeflag = ddlEmp.SelectedValue
userProfile.username = txtUserName.Text
userProfile.password = txtCreatePass.Text
'update users
Select Case btnUpdateUser.Text
Case "Add User"
If LicenseDB.AddUser(userProf ile) Then
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That username already exists."
End If
Case "Update User"
If LicenseDB.UpdateUser(userP rofile) Then
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That username already exists."
End If
End Select
Me.SetControlState(Control State.NoSe lection)
LoadData()
End Sub
#End Region
#Region " btnUpdateUser Subroutine "
Private Sub btnUpdateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateUser.Click
'Initialing the controls
Dim userProfile As New UserProfile
userProfile.userProfileID = txtUserID.Text
userProfile.userLoginID = txtUserID.Text
userProfile.state = ddlEmp.SelectedItem.Value
userProfile.firstName = txtFirstName.Text
userProfile.lastName = txtLastName.Text
userProfile.address1 = txtAddress1.Text
userProfile.address2 = txtAddress2.Text
userProfile.city = txtCity.Text
userProfile.state = ddlState.SelectedValue
userProfile.email = txtEmail.Text
userProfile.phone = txtphone.Text
userProfile.zip = txtZip.Text
userProfile.employeeflag = ddlEmp.SelectedValue
userProfile.username = txtUserName.Text
userProfile.password = txtCreatePass.Text
'update users
Select Case btnUpdateUser.Text
Case "Add User"
If LicenseDB.AddUser(userProf
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That username already exists."
End If
Case "Update User"
If LicenseDB.UpdateUser(userP
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That username already exists."
End If
End Select
Me.SetControlState(Control
LoadData()
End Sub
#End Region
if LicenseDB.AddUser(userProf
Me.ClearFields()
lblmsg.Text = "The user has been added."
Else
lblmsg.Text = "That user details already exists."
end if
End If
If btnUpdateUser.Text = "Update User" then
if LicenseDB.UpdateUser(userP
Me.ClearFields()
lblmsg.Text = "The user has been updated."
Else
lblmsg.Text = "That user details already exists."
end if
End If