Advertisement
tiffprag

Default Page

Dec 3rd, 2019
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.05 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.  
  15.     End Sub
  16.  
  17.     Private Sub DefaultPage_Unload(ByVal sender As Object) Handles Me.Unload
  18.         conn.Close()
  19.     End Sub
  20.  
  21.     Protected Sub ProgrammesGridView_SelectedIndexChanged(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.SelectedIndexChanged
  22.         Session("programmeId") = ProgrammesGridView.SelectedRow.Cells(1).Text
  23.  
  24.     End Sub
  25.  
  26.     Protected Sub CoursesGridView_SelectedIndexChanged(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.SelectedIndexChanged
  27.         Session("courseId") = CoursesGridView.SelectedRow.Cells(1).Text
  28.  
  29.         If  CoursesGridView.SelectedValue != null Then
  30.             LecturerTableLable.Visible = True
  31.             NameLable.Visible = True
  32.             GenderLable.Visible = True
  33.             DobLable.Visible = True
  34.             PhoneNoLable.Visible = True
  35.             LecturerEditButton.Visible = True
  36.  
  37.             NameTextBox.Text = "Name : " & CoursesGridView.SelectedRow.Cells(2).Text
  38.             GenderLable.Text = "Gender : " & CoursesGridView.SelectedRow.Cells(3).Text
  39.             DOBTextBox.Text = "DOB : " & CoursesGridView.SelectedRow.Cells(4).Text
  40.             PhoneNoTextBox.Text = "Phone No. : " & CoursesGridView.SelectedRow.Cells(5).Text
  41.  
  42.             ' Dim getLecturerSQL As String = "SELECT Lecturer.id, Lecturer.name, Lecturer.dateOfBirth FROM Lecturer WHERE Lecturer.id= (SELECT LecturerId FROM Programme_Setup WHERE CourseId = @id)"
  43.             ' Dim getLecturerCmd As SqlCommand = New SqlCommand(getLecturerSQL, conn)
  44.             ' getLecturerCmd.Parameters.AddWithValue("@id", currentCourseID)
  45.             ' Dim reader As SqlDataReader = getLecturerCmd.ExecuteReader()
  46.  
  47.             ' NameTextBox.Text = "Name : " & reader.GetString(1)
  48.  
  49.             ' Do While reader.Read()
  50.             '   If reader.IsDBNull(2) Then
  51.             '       GenderLable.Text = "Gender : " & "-"
  52.             '   Else
  53.             '       GenderTextBox.Text = "Gender : " & reader.GetString(1)
  54.             '   End If
  55.  
  56.             '   If reader.IsDBNull(3) Then
  57.             '       DOBTextBox.Text = "DOB : " & "-"
  58.             '   Else
  59.             '       DOBTextBox.Text = "DOB : " & reader.GetString(3)
  60.             '   End If
  61.  
  62.             '   If reader.IsDBNull(4) Then
  63.             '       PhoneNoTextBox.Text = "Phone No. : " & "-"
  64.             '   Else
  65.             '       PhoneNoTextBox.Text = "Phone No. : " & reader.GetString(4)
  66.             '   End If
  67.  
  68.             '   Exit Do
  69.             ' Loop
  70.             ' reader.Close()
  71.         Else
  72.             LecturerTableLable.Visible = False
  73.             NameLable.Visible = False
  74.             GenderLable.Visible = False
  75.             DobLable.Visible = False
  76.             PhoneNoLable.Visible = False
  77.             LecturerEditButton.Visible = False
  78.         End If
  79.     End Sub
  80.  
  81.     Protected Sub ProgrammesCreateButton_Click(sender As Object, e As EventArgs) Handles ProgrammeCreateButton.Click
  82.         If  ProgrammesGridView.SelectedValue != null Then
  83.             Session("table") = "Programme"
  84.             Session("mode") = "Create"
  85.  
  86.             Response.Redirect("Update.aspx")
  87.         Else
  88.             Msgbox("There are no rows currently selected.",,"ERROR!")
  89.         End If
  90.     End Sub
  91.  
  92.     Protected Sub ProgrammesEditButton_Click(sender As Object, e As EventArgs) Handles ProgrammeEditButton.Click
  93.         If  ProgrammesGridView.SelectedValue != null Then
  94.             Session("table") = "Programme"
  95.             Session("mode") = "Edit"
  96.  
  97.             Response.Redirect("Update.aspx")
  98.         Else
  99.             Msgbox("There are no rows currently selected.",,"ERROR!")
  100.         End If
  101.     End Sub
  102.  
  103.     Protected Sub ProgrammesDeleteButton_Click(sender As Object, e As EventArgs) Handles ProgrammeDeleteButton.Click
  104.         If  ProgrammesGridView.SelectedValue != null Then
  105.             Session("table") = "Programme"
  106.             Session("mode") = "Delete"
  107.  
  108.             Response.Redirect("Update.aspx")
  109.         Else
  110.             Msgbox("There are no rows currently selected.",,"ERROR!")
  111.         End If
  112.     End Sub
  113.  
  114.     Protected Sub CoursesCreateButton_Click(sender As Object, e As EventArgs) Handles CoursesCreateButton.Click
  115.         If  CoursesGridView.SelectedValue != null Then
  116.             Session("table") = "Course"
  117.             Session("mode") = "Create"
  118.  
  119.             Response.Redirect("Update.aspx")
  120.         Else
  121.             Msgbox("There are no rows currently selected.",,"ERROR!")
  122.         End If
  123.     End Sub
  124.  
  125.     Protected Sub CoursesEditButton_Click(sender As Object, e As EventArgs) Handles CoursesEditButton.Click
  126.         If  CoursesGridView.SelectedValue != null Then
  127.             Session("table") = "Course"
  128.             Session("mode") = "Edit"
  129.  
  130.             Response.Redirect("Update.aspx")
  131.         Else
  132.             Msgbox("There are no rows currently selected.",,"ERROR!")
  133.         End If
  134.     End Sub
  135.  
  136.     Protected Sub CoursesDeleteButton_Click(sender As Object, e As EventArgs) Handles CoursesDeleteButton.Click
  137.         If  CoursesGridView.SelectedValue != null Then
  138.             Session("table") = "Course"
  139.             Session("mode") = "Delete"
  140.  
  141.             Response.Redirect("Update.aspx")
  142.         Else
  143.             Msgbox("There are no rows currently selected.",,"ERROR!")
  144.         End If
  145.     End Sub
  146.  
  147.     Protected Sub LecturerEditButton_Click(sender As Object, e As EventArgs) Handles LecturerEditButton.Click
  148.             Session("table") = "Lecturer"
  149.             Session("mode") = "Edit"
  150.  
  151.             Response.Redirect("Update.aspx")
  152.     End Sub
  153.  
  154. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement