Advertisement
tiffprag

Default Page

Dec 2nd, 2019
3,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 3.21 KB | None | 0 0
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class _Default
  4.     Inherits System.Web.UI.Page
  5.  
  6.     'Create Connection'
  7.     Dim conn As SqlConnection
  8.  
  9.     Protected Sub DefaultPage_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  10.         Dim connStr As String = "(INSERT CONNECTION STRING)"
  11.         conn = New SqlConnection(connStr)
  12.         'open the connection to the database'
  13.         conn.Open()
  14.     End Sub
  15.  
  16.     Private Sub DefaultPage_Unload(ByVal sender As Object) Handles Me.Unload
  17.         conn.Close()
  18.     End Sub
  19.  
  20.     Protected Sub ProgrammesGridView_CellClick(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.CellClick
  21.         Dim indexNumber As Integer
  22.         indexNumber = e.RowIndex    'Index number of the row that is selected'
  23.  
  24.         Session("programmeId") = ProgrammesGridView.Rows(indexNumber).Cells(0).Text
  25.     End Sub
  26.  
  27.     Protected Sub CoursesGridView_CellClick(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.CellClick
  28.         Dim indexNumber As Integer
  29.         indexNumber = e.RowIndex    'Index number of the row that is selected'
  30.  
  31.         Session("courseId") = CoursesGridView.Rows(indexNumber).Cells(0).Text
  32.     End Sub
  33.  
  34.     Protected Sub ProgrammesCreateButton_Click(sender As Object, e As EventArgs) Handles ProgrammeCreateButton.Click
  35.         If  ProgrammesGridView.SelectedValue != null Then
  36.             Session("table") = "Programme"
  37.             Session("mode") = "Create"
  38.  
  39.             Response.Redirect("Update.aspx")
  40.         Else
  41.             Msgbox("There are no rows currently selected.",,"ERROR!")
  42.         End If
  43.     End Sub
  44.  
  45.     Protected Sub ProgrammesEditButton_Click(sender As Object, e As EventArgs) Handles ProgrammeEditButton.Click
  46.         If  ProgrammesGridView.SelectedValue != null Then
  47.             Session("table") = "Programme"
  48.             Session("mode") = "Edit"
  49.  
  50.             Response.Redirect("Update.aspx")
  51.         Else
  52.             Msgbox("There are no rows currently selected.",,"ERROR!")
  53.         End If
  54.     End Sub
  55.  
  56.     Protected Sub ProgrammesDeleteButton_Click(sender As Object, e As EventArgs) Handles ProgrammeDeleteButton.Click
  57.         If  ProgrammesGridView.SelectedValue != null Then
  58.             Session("table") = "Programme"
  59.             Session("mode") = "Delete"
  60.  
  61.             Response.Redirect("Update.aspx")
  62.         Else
  63.             Msgbox("There are no rows currently selected.",,"ERROR!")
  64.         End If
  65.     End Sub
  66.  
  67.     Protected Sub CoursesCreateButton_Click(sender As Object, e As EventArgs) Handles CoursesCreateButton.Click
  68.         If  ProgrammesGridView.SelectedValue != null Then
  69.             Session("table") = "Course"
  70.             Session("mode") = "Create"
  71.  
  72.             Response.Redirect("Update.aspx")
  73.         Else
  74.             Msgbox("There are no rows currently selected.",,"ERROR!")
  75.         End If
  76.     End Sub
  77.  
  78.     Protected Sub CoursesEditButton_Click(sender As Object, e As EventArgs) Handles CoursesEditButton.Click
  79.         If  ProgrammesGridView.SelectedValue != null Then
  80.             Session("table") = "Course"
  81.             Session("mode") = "Edit"
  82.  
  83.             Response.Redirect("Update.aspx")
  84.         Else
  85.             Msgbox("There are no rows currently selected.",,"ERROR!")
  86.         End If
  87.     End Sub
  88.  
  89.     Protected Sub CoursesDeleteButton_Click(sender As Object, e As EventArgs) Handles CoursesDeleteButton.Click
  90.         If  ProgrammesGridView.SelectedValue != null Then
  91.             Session("table") = "Course"
  92.             Session("mode") = "Delete"
  93.  
  94.             Response.Redirect("Update.aspx")
  95.         Else
  96.             Msgbox("There are no rows currently selected.",,"ERROR!")
  97.         End If
  98.     End Sub
  99.  
  100. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement