Advertisement
sciexie

delete code

Mar 9th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1.  
  2. Private Sub pdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pdelete.Click
  3.  
  4.  
  5.  
  6.  
  7. connect = New OdbcConnection("driver=MySQL ODBC 5.2 ANSI Driver;localhost;port=3306;uid='root';pwd=;database=enrollment")
  8. connect.Open()
  9.  
  10. If cbprof.Text = "" Then
  11. MessageBox.Show("Please fill up the form", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning)
  12.  
  13. Else
  14.  
  15.  
  16. Dim myConnection As OleDbConnection = New OleDbConnection
  17. Dim okToDelete As MsgBoxResult = MsgBox("Are you sure you want to delete?", MsgBoxStyle.YesNo)
  18.  
  19.  
  20. If okToDelete = MsgBoxResult.Yes Then
  21.  
  22.  
  23. End If
  24.  
  25.  
  26. Dim ID As String
  27. Dim time As String
  28. Dim subjects As String
  29. Dim room_number As String
  30. Dim days As String
  31. Dim building_number As String
  32.  
  33. Dim grade As String
  34. Dim section As String
  35.  
  36. Dim semester As String
  37. Dim professor As String
  38.  
  39.  
  40.  
  41. ID = txtid.Text.ToUpper.Trim
  42. time = cbtime.Text.ToUpper.Trim
  43. subjects = cbsubj.Text.ToUpper.Trim
  44. room_number = cbroom.Text.ToUpper.Trim
  45. days = cbday.Text.ToUpper.Trim
  46. building_number = cbbldg.Text.ToUpper.Trim
  47.  
  48. grade = cbgrade.Text.ToUpper.Trim
  49. section = cbsec.Text.ToUpper.Trim
  50.  
  51. semester = cbsem.Text.ToUpper.Trim
  52. professor = cbprof.Text.ToUpper.Trim()
  53.  
  54. connectMe()
  55.  
  56.  
  57.  
  58.  
  59. With myCmd
  60. .Connection = Con
  61. .CommandText = " delete from class_scheduler where ID = '" & ID & "'"
  62. .ExecuteNonQuery()
  63.  
  64.  
  65.  
  66.  
  67.  
  68. End With
  69.  
  70.  
  71.  
  72. txtid.Enabled = False
  73. cbtime.Enabled = True
  74. cbsubj.Enabled = True
  75. cbroom.Enabled = True
  76. cbday.Enabled = True
  77. cbbldg.Enabled = True
  78.  
  79. cbgrade.Enabled = True
  80. cbsec.Enabled = True
  81.  
  82. cbsem.Enabled = True
  83. cbprof.Enabled = True
  84.  
  85.  
  86. cbprof.Focus()
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. MessageBox.Show(" Successfully deleted.")
  96.  
  97. txtid.Clear()
  98. cbtime.Text = String.Empty
  99. cbsubj.Text = String.Empty
  100. cbroom.Text = String.Empty
  101. cbday.Text = String.Empty
  102. cbbldg.Text = String.Empty
  103.  
  104. cbgrade.Text = String.Empty
  105. cbsec.Text = String.Empty
  106.  
  107. cbsem.Text = String.Empty
  108. cbprof.Text = String.Empty
  109. cbprof.Focus()
  110.  
  111. Me.refreshMe()
  112.  
  113.  
  114.  
  115. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement