Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 KB | None | 0 0
  1. Private Sub ListView_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles ListView.SelectionChanged
  2.     If ListView.SelectedItems.Count = 1 Then
  3.         Try
  4.             ebu = ListView.SelectedItem
  5.             If EditorType = "Update" Or EditorType = "View" Then
  6.                 ViewGrp.IsEnabled = True
  7.                 TitleField.Text = ebu.Title
  8.                 FirstNameField.Text = ebu.FirstName
  9.                 LastNameField.Text = ebu.LastName
  10.                 EmailField.Text = ebu.Email
  11.                 PhoneNoField.Text = ebu.PhoneNo
  12.                 DepartmentField.Text = ebu.DepartmentID
  13.                 If EditorType = "View" Then ViewGrp.IsEnabled = False
  14.             End If
  15.         Catch ex As Exception
  16.             MessageBox.Show("An error occured while trying to retrieve employee details from the database. Please try again",
  17.                             "Error - Details Not Retrieved!", MessageBoxButton.OK, MessageBoxImage.Error)
  18.         End Try
  19.     End If
  20. End Sub
  21.  
  22. Private Sub MainBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MainBtn.Click
  23.     If EditorType = "Add" Then
  24.         Dim status As Int32 = -1
  25.  
  26.         Try
  27.             status = ebu.Create()
  28.         Catch ex As Exception
  29.             status = -1
  30.         End Try
  31.  
  32.         If status <= 0 Then
  33.             MessageBox.Show("An error occured while trying to alter the database. Please try again.",
  34.                              "Error - Employee Not Created!",
  35.                              MessageBoxButton.OK, MessageBoxImage.Error)
  36.         Else : MessageBox.Show("Employee Created Successfully!: " & vbCrLf &
  37.                              "EmployeeID - " & Convert.ToString(status) & vbCrLf &
  38.                              "FirstName - " & FirstNameField.Text & vbCrLf &
  39.                              "LastName - " & LastNameField.Text & vbCrLf &
  40.                              "Email - " & EmailField.Text & vbCrLf &
  41.                              "PhoneNo - " & PhoneNoField.Text & vbCrLf &
  42.                              "DepartmentID - " & DepartmentField.Text,
  43.                              MessageBoxButton.OK,
  44.                              MessageBoxImage.Information)
  45.         End If
  46.     ElseIf EditorType = "Update" Then
  47.         Try
  48.             ebu.Title = TitleField.Text
  49.             ebu.FirstName = FirstNameField.Text
  50.             ebu.LastName = LastNameField.Text
  51.             ebu.Email = EmailField.Text
  52.             ebu.PhoneNo = PhoneNoField.Text
  53.             ebu.DepartmentID = Convert.ToInt32(DepartmentField.Text)
  54.             ebu.Update()
  55.         Catch ex As Exception
  56.             MessageBox.Show("Unable to update employee, please check the error log for more details.",
  57.                             "Error - Update Not Completed", MessageBoxButton.OK, MessageBoxImage.Error)
  58.         End Try
  59.     ElseIf EditorType = "Delete" Then
  60.  
  61.     End If
  62. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement