Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
70 views15 pages

ElseIf Len

The document describes the code for login and user management forms. It includes code for validating login credentials, adding and searching for users, and saving user data. Functions are provided for buttons like login, exit, add new, save, next, previous, delete, clear fields and search. Validation checks fields are not empty on saving. The code also handles loading initial user data from a database.

Uploaded by

stacy matsheza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views15 pages

ElseIf Len

The document describes the code for login and user management forms. It includes code for validating login credentials, adding and searching for users, and saving user data. Functions are provided for buttons like login, exit, add new, save, next, previous, delete, clear fields and search. Validation checks fields are not empty on saving. The code also handles loading initial user data from a database.

Uploaded by

stacy matsheza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Login Form

 Login Button
If txtUserName.Text = "" Then
DialogResult = MessageBox.Show("Username textbox cannot be empty.", "Stop",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Not Regex.Match(txtUserName.Text, "^[a-z]*$").Success Then
DialogResult = MessageBox.Show("Username can only contain 15 or less lower
case letters.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Len(txtUserName.Text) > 15 Then
DialogResult = MessageBox.Show("Username can only contain 15 or less lower
case letters.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Char.IsUpper(txtUserName.Text) Then
DialogResult = MessageBox.Show("Username can only contain 15 or less lower
case letters.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf txtPassword.Text = "" Then
DialogResult = MessageBox.Show("Password textbox cannot be empty.", "Stop",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Len(txtPassword.Text) > 8 Then
DialogResult = MessageBox.Show("Password should be 8 or less characters
long.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf txtUserName.Text = "munashe" And txtPassword.Text = "47494749" Then
DialogResult = MessageBox.Show("Login Was Successful.", "Welcome",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Form3.Show()
Me.Hide()
Else
DialogResult = MessageBox.Show("Invalid Username or Password.", "Error",
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
End If

 Exit Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles iExit.Click
Dim iExit As DialogResult
iExit = MessageBox.Show("Confirm if you want to exit system.", "Login
Form", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iExit = DialogResult.Yes Then
Me.Close()
Else
Me.Show()

End If
End Sub
 CLEAR BUTTON

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
txtUserName.Clear()
txtPassword.Clear()
End Sub

ADDING USERS
Search Button
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button6.Click
Me.UsersBindingSource.Filter = "FullName LIKE'" & TextBox14.Text & "%'"
If TextBox14.Text = "" Then
DialogResult = MessageBox.Show("Search textbox should not be empty", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Not Regex.Match(TextBox14.Text, "^[a-z]*$").Success Then
DialogResult = MessageBox.Show("Only enter user's name.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub

View Report Button


Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button9.Click
Spar_Users_Form_Report.Show()
Me.Hide()

End Sub

Clear (Search) Button

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button8.Click
TextBox14.Clear()
End Sub
Exit Button
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles iExit.Click
Dim iExit As DialogResult
iExit = MessageBox.Show("Confirm if you want to exit", "Users Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iExit = DialogResult.Yes Then
Me.Hide()
Form3.Show()
Else
Me.Show()
End If
End Sub

CLEAR BUTTON

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
TextBox1.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox9.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox12.Clear()
TextBox13.Clear()

UserBindingNavigatorSaveItem_Click
Private Sub UsersBindingNavigatorSaveItem_Click_6(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles UsersBindingNavigatorSaveItem.Click
Me.Validate()
Me.UsersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Spar_Users_FormDataSet)
Form 2

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the 'Spar_Users_FormDataSet.Users'
table. You can move, or remove it, as needed.
Me.UsersTableAdapter.Fill(Me.Spar_Users_FormDataSet.Users)

End Sub

ADDNEW BUTTON
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
BindingNavigatorAddNewItem.PerformClick()

SAVE BUTTON
Public Class Form2

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
UsersBindingNavigatorSaveItem.PerformClick()
If TextBox4.Text = "" Then
DialogResult = MessageBox.Show("ID textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox5.Text = "" Then
DialogResult = MessageBox.Show("FullName textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox13.Text = "" Then
DialogResult = MessageBox.Show("Username textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox6.Text = "" Then
DialogResult = MessageBox.Show("Password textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox7.Text = "" Then
DialogResult = MessageBox.Show("Gender textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox8.Text = "" Then
DialogResult = MessageBox.Show("Date Of Birth textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox3.Text = "" Then
DialogResult = MessageBox.Show("Age textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox9.Text = "" Then
DialogResult = MessageBox.Show("Address textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox10.Text = "" Then
DialogResult = MessageBox.Show("Email textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox11.Text = "" Then
DialogResult = MessageBox.Show("Phone Number textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox1.Text = "" Then
DialogResult = MessageBox.Show("Job Category textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox12.Text = "" Then
DialogResult = MessageBox.Show("Branch textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox2.Text = "" Then
DialogResult = MessageBox.Show("Country textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

NEXT BUTTON
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
BindingNavigatorMoveNextItem.PerformClick()

PREVIOUS BUTTON

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
BindingNavigatorMovePreviousItem.PerformClick()

DELETE BUTTON
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button7.Click
BindingNavigatorDeleteItem.PerformClick()

End Sub
ADDING CANDIDATES
FORM 6
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'TODO: This line of code loads data into the
'Spar_Candidates_Recruit_FormDataSet.Candidates' table. You can move, or remove it, as
needed.

Me.CandidatesTableAdapter1.Fill(Me.Spar_Candidates_Recruit_FormDataSet.Candidates)

SEARCH BUTTON
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button6.Click
Me.CandidatesBindingSource.Filter = "FullName LIKE'" & TextBox2.Text & "%'"
If TextBox2.Text = "" Then
DialogResult = MessageBox.Show("Search textbox cannot be empty.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Not Regex.Match(TextBox2.Text, "^[a-z]*$").Success Then
DialogResult = MessageBox.Show("Only enter candidates name.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)

End If
End Sub

SHOW REPORT BUTTON


Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button9.Click
Spar_Candidates_Form_Report.Show()
Me.Hide()

End Sub

CLEAR (SEARCH) BUTTON


Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button8.Click
TextBox2.Clear()

End Sub
Candidates BindingNavigator Save Item_Click
Private Sub CandidatesBindingNavigatorSaveItem_Click_4(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CandidatesBindingNavigatorSaveItem.Click

Me.Validate()
Me.CandidatesBindingSource.EndEdit()
Me.TableAdapterManager1.UpdateAll(Me.Spar_Candidates_Recruit_FormDataSet)

End Sub
End Class

ADDNEW BUTTON
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
BindingNavigatorAddNewItem.PerformClick()

End Sub

PREVIOUS BUTTON

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
BindingNavigatorMovePreviousItem.PerformClick()
End Sub

SAVE BUTTON
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
CandidatesBindingNavigatorSaveItem.PerformClick()

NEXT BUTTON
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
BindingNavigatorMoveNextItem.PerformClick()
End Sub
CLEAR BUTTON

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
TextBox1.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox9.Clear()
TextBox10.Clear()

End Sub

EXIT BUTTON
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles iExit.Click
Dim iExit As DialogResult
iExit = MessageBox.Show("Confirm if you want to exit", "Candidates Recruitment
Form", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iExit = DialogResult.Yes Then
Form3.Show()
Me.Hide()
Else
Me.Show()
End If

End Sub

DELETE BUTTON

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button7.Click
BindingNavigatorDeleteItem.PerformClick()

End Sub

JOB PROFILE LINKING FORM


txtJobTitle TextBox

Private Sub txtJobTitle_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtJobTitle.SelectedIndexChanged
If txtJobTitle.Text = "Manager" Then
txtJobDescription.Text = "To authorise all business transactions."
txtJobQualifications.Text = "Good social ,communicating and leadership
skills. A diploma in business studies and accounting. A two year experience at the
position."
txtBenefits.Text = "Free paid school fees for two of your kids."
txtHours.Text = "15hours"
txtSalary.Text = "$20,000.00"
ElseIf txtJobTitle.Text = "Sales Accountant" Then
txtJobDescription.Text = "Required to balance the legder book after each
working day and assist customers with any information they want to know about their
transactions."
txtJobQualifications.Text = "A minimum of 5 O-Levels passed. At Least a two
year experience in the position."
txtBenefits.Text = "6 months raise every year."
txtHours.Text = "10hours"
txtSalary.Text = "$5,000.00"
ElseIf txtJobTitle.Text = "Clerk" Then
txtJobDescription.Text = "Reception"
txtJobQualifications.Text = "Two year experince at the job position."
txtBenefits.Text = "None"
txtHours.Text = "8hours"
txtSalary.Text = "$2,500.00"

End If
End Sub

Form 8
Public Class Form8

Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the
'Spar_Candidates_Recruit_FormDataSet.Candidates' table. You can move, or remove it, as
needed.

Me.CandidatesTableAdapter1.Fill(Me.Spar_Candidates_Recruit_FormDataSet.Candidates)

txtJobTitle.Items.Add("Manager")
txtJobTitle.Items.Add("Sales Accountant")
txtJobTitle.Items.Add("Clerk")

End Sub

Search Button
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button8.Click
If TextBox1.Text Then
DialogResult = MessageBox.Show("Search textbox cannot be empty.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Not Regex.Match(TextBox1.Text, "^[a-z]*$").Success Then
DialogResult = MessageBox.Show("Only enter candidate's name.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub

Show Report Button


Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button9.Click
Spar_Job_Profile_Linking_Form_Report.Show()
Me.Hide()

End Sub

Clear (SEARCH) Button


Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button10.Click

TextBox1.Clear()

End Sub

Addnew Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
BindingNavigatorAddNewItem.PerformClick()
End Sub

Save Button
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click

CandidatesBindingNavigatorSaveItem.PerformClick()
End Sub

Previous Button
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
BindingNavigatorMovePreviousItem.PerformClick()

End Sub
Next Button
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button6.Click

BindingNavigatorMoveNextItem.PerformClick()

End Sub

Delete Button
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button7.Click

BindingNavigatorDeleteItem.PerformClick()

End Sub

Link Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
If TextBox14.Text = txtJobQualifications.Text Then
DialogResult = MessageBox.Show(txtFullName.Text & " qualified for job
position.", "Match Found", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
DialogResult = MessageBox.Show("Candidate is not a match for the job
position.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
End If
End Sub

Exit Button
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles iExit.Click
Dim iExit As DialogResult
iExit = MessageBox.Show("Confirm if you want to exit", "Job Profile Linking
Form", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iExit = DialogResult.Yes Then
Form3.Show()
Me.Hide()
Else
Me.Show()
End If
End Sub
CandidatesBindingNavigatorSaveItem_Click
Private Sub CandidatesBindingNavigatorSaveItem_Click_4(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CandidatesBindingNavigatorSaveItem.Click
Me.Validate()
Me.CandidatesBindingSource.EndEdit()
Me.TableAdapterManager1.UpdateAll(Me.Spar_Candidates_Recruit_FormDataSet)

End Sub

Work Placement FORM

Search Button
Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
Me.Placement_FormBindingSource.Filter = "FullName LIKE'" & TextBox3.Text & "%'"
If TextBox3.Text = "" Then
DialogResult = MessageBox.Show("Search textbox cannot be empty.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ElseIf Not Regex.Match(TextBox3.Text, "^[a-z]*$").Success Then
DialogResult = MessageBox.Show("Only enter applicant's name.", "Wait",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub

View Report Button


Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button9.Click

Clients_form_report.Show()

Me.Hide()

End Sub

Clear Button
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click

TextBox1.Clear()
TextBox2.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox9.Clear()
TextBox10.Clear()

End Sub

Save Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
ClientsBindingNavigatorSaveItem.PerformClick()
If TextBox1.Text = "" Then
DialogResult = MessageBox.Show("ID textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox2.Text = "" Then
DialogResult = MessageBox.Show("FullName textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox9.Text = "" Then
DialogResult = MessageBox.Show("Gender textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)

ElseIf TextBox4.Text = "" Then


DialogResult = MessageBox.Show("Company Name textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox5.Text = "" Then
DialogResult = MessageBox.Show("Branch textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox6.Text = "" Then
DialogResult = MessageBox.Show("Date Of Birth textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox7.Text = "" Then
DialogResult = MessageBox.Show("Phone Number textbox cannot be empty.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf TextBox8.Text = "" Then
DialogResult = MessageBox.Show("Email textbox cannot be empty.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If

End Sub

Next Button
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click

BindingNavigatorMoveNextItem.PerformClick()

End Sub
Previous Button
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
BindingNavigatorMovePreviousItem.PerformClick()
End Sub

Delete Button
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button7.Click
BindingNavigatorDeleteItem.PerformClick()
End Sub

Exit Button

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles iExit.Click
Dim iExit As DialogResult
iExit = MessageBox.Show("Confirm if you want to exit", "Clients Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iExit = DialogResult.Yes Then
Form3.Show()
Me.Hide()
Else
Me.Show()
End If
End Sub

You might also like