Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Public Class _Default
- Inherits System.Web.UI.Page
- 'Create Connection'
- Dim conn As SqlConnection
- Protected Sub DefaultPage_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Dim connStr As String = "(INSERT CONNECTION STRING)"
- conn = New SqlConnection(connStr)
- 'open the connection to the database'
- conn.Open()
- End Sub
- Private Sub DefaultPage_Unload(ByVal sender As Object) Handles Me.Unload
- conn.Close()
- End Sub
- Protected Sub ProgrammesGridView_SelectedIndexChanged(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.SelectedIndexChanged
- Session("programmeId") = ProgrammesGridView.SelectedRow.Cells(1).Text
- End Sub
- Protected Sub CoursesGridView_SelectedIndexChanged(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.SelectedIndexChanged
- Session("courseId") = CoursesGridView.SelectedRow.Cells(1).Text
- If CoursesGridView.SelectedValue != null Then
- LecturerTableLable.Visible = True
- NameLable.Visible = True
- GenderLable.Visible = True
- DobLable.Visible = True
- PhoneNoLable.Visible = True
- LecturerEditButton.Visible = True
- NameTextBox.Text = "Name : " & CoursesGridView.SelectedRow.Cells(2).Text
- GenderLable.Text = "Gender : " & CoursesGridView.SelectedRow.Cells(3).Text
- DOBTextBox.Text = "DOB : " & CoursesGridView.SelectedRow.Cells(4).Text
- PhoneNoTextBox.Text = "Phone No. : " & CoursesGridView.SelectedRow.Cells(5).Text
- ' Dim getLecturerSQL As String = "SELECT Lecturer.id, Lecturer.name, Lecturer.dateOfBirth FROM Lecturer WHERE Lecturer.id= (SELECT LecturerId FROM Programme_Setup WHERE CourseId = @id)"
- ' Dim getLecturerCmd As SqlCommand = New SqlCommand(getLecturerSQL, conn)
- ' getLecturerCmd.Parameters.AddWithValue("@id", currentCourseID)
- ' Dim reader As SqlDataReader = getLecturerCmd.ExecuteReader()
- ' NameTextBox.Text = "Name : " & reader.GetString(1)
- ' Do While reader.Read()
- ' If reader.IsDBNull(2) Then
- ' GenderLable.Text = "Gender : " & "-"
- ' Else
- ' GenderTextBox.Text = "Gender : " & reader.GetString(1)
- ' End If
- ' If reader.IsDBNull(3) Then
- ' DOBTextBox.Text = "DOB : " & "-"
- ' Else
- ' DOBTextBox.Text = "DOB : " & reader.GetString(3)
- ' End If
- ' If reader.IsDBNull(4) Then
- ' PhoneNoTextBox.Text = "Phone No. : " & "-"
- ' Else
- ' PhoneNoTextBox.Text = "Phone No. : " & reader.GetString(4)
- ' End If
- ' Exit Do
- ' Loop
- ' reader.Close()
- Else
- LecturerTableLable.Visible = False
- NameLable.Visible = False
- GenderLable.Visible = False
- DobLable.Visible = False
- PhoneNoLable.Visible = False
- LecturerEditButton.Visible = False
- End If
- End Sub
- Protected Sub ProgrammesCreateButton_Click(sender As Object, e As EventArgs) Handles ProgrammeCreateButton.Click
- If ProgrammesGridView.SelectedValue != null Then
- Session("table") = "Programme"
- Session("mode") = "Create"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub ProgrammesEditButton_Click(sender As Object, e As EventArgs) Handles ProgrammeEditButton.Click
- If ProgrammesGridView.SelectedValue != null Then
- Session("table") = "Programme"
- Session("mode") = "Edit"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub ProgrammesDeleteButton_Click(sender As Object, e As EventArgs) Handles ProgrammeDeleteButton.Click
- If ProgrammesGridView.SelectedValue != null Then
- Session("table") = "Programme"
- Session("mode") = "Delete"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub CoursesCreateButton_Click(sender As Object, e As EventArgs) Handles CoursesCreateButton.Click
- If CoursesGridView.SelectedValue != null Then
- Session("table") = "Course"
- Session("mode") = "Create"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub CoursesEditButton_Click(sender As Object, e As EventArgs) Handles CoursesEditButton.Click
- If CoursesGridView.SelectedValue != null Then
- Session("table") = "Course"
- Session("mode") = "Edit"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub CoursesDeleteButton_Click(sender As Object, e As EventArgs) Handles CoursesDeleteButton.Click
- If CoursesGridView.SelectedValue != null Then
- Session("table") = "Course"
- Session("mode") = "Delete"
- Response.Redirect("Update.aspx")
- Else
- Msgbox("There are no rows currently selected.",,"ERROR!")
- End If
- End Sub
- Protected Sub LecturerEditButton_Click(sender As Object, e As EventArgs) Handles LecturerEditButton.Click
- Session("table") = "Lecturer"
- Session("mode") = "Edit"
- Response.Redirect("Update.aspx")
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement