⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webfrmsignup.aspx.vb

📁 网络版教务管理系统.rar
💻 VB
字号:
Public Class WebfrmSignUpaspx
    Inherits System.Web.UI.Page

#Region " Web 窗体设计器生成的代码 "

    Protected WithEvents Image2 As System.Web.UI.WebControls.Image
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents Image1 As System.Web.UI.WebControls.Image
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents Label4 As System.Web.UI.WebControls.Label
    Protected WithEvents DropDownList3 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents DropDownList4 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    Protected WithEvents Label7 As System.Web.UI.WebControls.Label
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub

#End Region

    Public sqlstr As String
    Public DS As DataSet
    Public DR As DataRow

    Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If IsPostBack = False Then
            LoadCurse()
            Dim curse As String
            Dim Places As String
            curse = Me.DropDownList1.SelectedItem.Text.Trim
            LoadPlace(curse)
            Places = Me.DropDownList2.Items(0).Text.Trim
            LoadMount(curse, Places)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim strSign As New Sign()
        strSign = DataFromForm
        sqlstr = "INSERT INTO tbapplyinfo (学号,课程编号,考试时间,考试地点) " & _
        "VALUES('" & strSign.No & "','" & strSign.Curse & "'," & _
        "'" & strSign.TestDay & "','" & strSign.Place & "')"
        If UpdateDataBase(sqlstr) = True Then
            Dim Curse As String
            Dim Place As String
            Curse = Me.DropDownList1.SelectedItem.Text.Trim
            Place = Me.DropDownList2.SelectedItem.Text.Trim
            sqlstr = "UPDATE tbtestplaceinfo SET 座位余额=" & _
            "'" & CInt(Val(Me.DropDownList4.SelectedItem.Text)) & "'-1 " & _
            "WHERE 课程编号='" & Curse & "' AND 考试地点='" & Place & "'"
            If UpdateDataBase(sqlstr) = True Then
                LoadCurse()
                Dim Curses As String
                Curse = Me.DropDownList1.SelectedItem.Text.Trim
            End If
            No = Me.TextBox1.Text.Trim
            Me.Response.Redirect("WebFrmSignDetails.aspx")
        End If
    End Sub

    Public Sub LoadCurse()
        sqlstr = "SELECT DISTINCT 课程编号 FROM tbtestplaceinfo "
        DS = New DataSet()
        DS.Clear()
        DS = GetDataFromDB(sqlstr)
        Dim temp As String
        Me.DropDownList1.Items.Clear()
        For Each DR In DS.Tables(0).Rows
            temp = Trim(DR.Item(0))
            Me.DropDownList1.Items.Add(temp)
        Next
    End Sub

    Public Sub LoadPlace(ByVal Curse As String)
        sqlstr = "SELECT 考试地点,考试时间 FROM tbtestplaceinfo " & _
        "WHERE 课程编号='" & Curse & "'"
        DS = New DataSet()
        DS.Clear()
        DS = GetDataFromDB(sqlstr)
        Dim temp1 As String
        Dim temp2 As String
        Me.DropDownList2.Items.Clear()
        Me.DropDownList3.Items.Clear()
        For Each DR In DS.Tables(0).Rows
            temp1 = Trim(DR.Item("考试地点"))
            temp2 = Trim(DR.Item("考试时间"))
            Me.DropDownList2.Items.Add(temp1)
            Me.DropDownList3.Items.Add(temp2)
        Next
    End Sub

    Public Sub LoadMount(ByVal Curse As String, ByVal Place As String)
        sqlstr = "SELECT 座位余额 FROM tbtestplaceinfo " & _
              "WHERE 课程编号='" & Curse & "' AND 考试地点='" & Place & "'"
        DS = New DataSet()
        DS.Clear()
        DS = GetDataFromDB(sqlstr)
        Dim temp3 As Integer
        Me.DropDownList4.Items.Clear()
        For Each DR In DS.Tables(0).Rows
            temp3 = DR.Item("座位余额")
            Me.DropDownList4.Items.Add(temp3.ToString)
        Next
    End Sub

    Private Sub DropDownList1_SelectedIndexChanged _
    (ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles DropDownList1.SelectedIndexChanged
        Dim temp As String
        temp = Me.DropDownList1.SelectedItem.Text.Trim
        LoadPlace(temp)
        Dim place As String
        place = Me.DropDownList2.SelectedItem.Text.Trim
        LoadMount(temp, place)
    End Sub

    Public ReadOnly Property DataFromForm() As Sign
        Get
            Dim Sings As New Sign()
            Sings.Curse = Me.DropDownList1.SelectedItem.Text.Trim
            Sings.Place = Me.DropDownList2.SelectedItem.Text.Trim
            Sings.TestDay = Me.DropDownList3.SelectedItem.Text.Trim
            Sings.No = Me.TextBox1.Text.Trim
            Return Sings
        End Get
    End Property

    Private Sub DropDownList2_SelectedIndexChanged _
    (ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles DropDownList2.SelectedIndexChanged
        Dim temp1 As String
        Dim temp2 As String
        temp1 = Me.DropDownList1.SelectedItem.Text.Trim
        temp2 = Me.DropDownList2.SelectedItem.Text.Trim
        LoadMount(temp1, temp2)
    End Sub
End Class

Public Class Sign
    Public Curse As String
    Public Place As String
    Public TestDay As Date
    Public No As String
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -