Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub ListView_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles ListView.SelectionChanged
- If ListView.SelectedItems.Count = 1 Then
- Try
- ebu = ListView.SelectedItem
- If EditorType = "Update" Or EditorType = "View" Then
- ViewGrp.IsEnabled = True
- TitleField.Text = ebu.Title
- FirstNameField.Text = ebu.FirstName
- LastNameField.Text = ebu.LastName
- EmailField.Text = ebu.Email
- PhoneNoField.Text = ebu.PhoneNo
- DepartmentField.Text = ebu.DepartmentID
- If EditorType = "View" Then ViewGrp.IsEnabled = False
- End If
- Catch ex As Exception
- MessageBox.Show("An error occured while trying to retrieve employee details from the database. Please try again",
- "Error - Details Not Retrieved!", MessageBoxButton.OK, MessageBoxImage.Error)
- End Try
- End If
- End Sub
- Private Sub MainBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MainBtn.Click
- If EditorType = "Add" Then
- Dim status As Int32 = -1
- Try
- status = ebu.Create()
- Catch ex As Exception
- status = -1
- End Try
- If status <= 0 Then
- MessageBox.Show("An error occured while trying to alter the database. Please try again.",
- "Error - Employee Not Created!",
- MessageBoxButton.OK, MessageBoxImage.Error)
- Else : MessageBox.Show("Employee Created Successfully!: " & vbCrLf &
- "EmployeeID - " & Convert.ToString(status) & vbCrLf &
- "FirstName - " & FirstNameField.Text & vbCrLf &
- "LastName - " & LastNameField.Text & vbCrLf &
- "Email - " & EmailField.Text & vbCrLf &
- "PhoneNo - " & PhoneNoField.Text & vbCrLf &
- "DepartmentID - " & DepartmentField.Text,
- MessageBoxButton.OK,
- MessageBoxImage.Information)
- End If
- ElseIf EditorType = "Update" Then
- Try
- ebu.Title = TitleField.Text
- ebu.FirstName = FirstNameField.Text
- ebu.LastName = LastNameField.Text
- ebu.Email = EmailField.Text
- ebu.PhoneNo = PhoneNoField.Text
- ebu.DepartmentID = Convert.ToInt32(DepartmentField.Text)
- ebu.Update()
- Catch ex As Exception
- MessageBox.Show("Unable to update employee, please check the error log for more details.",
- "Error - Update Not Completed", MessageBoxButton.OK, MessageBoxImage.Error)
- End Try
- ElseIf EditorType = "Delete" Then
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement