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

📄 webfrmclass.aspx.vb

📁 网络版教务管理系统.rar
💻 VB
字号:
Public Class WebfrmClass
    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 DropDownList1 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button4 As System.Web.UI.WebControls.Button
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents Button2 As System.Web.UI.WebControls.Button
    Protected WithEvents Button3 As System.Web.UI.WebControls.Button
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents Label4 As System.Web.UI.WebControls.Label
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents Button5 As System.Web.UI.WebControls.Button
    '该调用是 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 count As Integer

    Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If IsPostBack = False Then
            LoadData()
            Indexs = 0
            ShowData(ShowData(Indexs))
        End If
    End Sub

    Public Function LoadData() As DataSet
        sqlstr = "SELECT * FROM classInfo"
        DS = New DataSet()
        DS.Clear()
        DS = GetDataFromDB(sqlstr)
        count = DS.Tables(0).Rows.Count
        Return DS
    End Function

    Public Function ShowData(ByVal index As Integer) As ClsInfo
        Dim cls As New ClsInfo()
        DS = New DataSet()
        DS = LoadData()
        If index >= DS.Tables(0).Rows.Count Then
            index = 0
        End If
        If index < 0 Then
            index = DS.Tables(0).Rows.Count - 1
        End If
        cls.ClsNo = Trim(DS.Tables(0).Rows(index)("班号"))
        cls.ClsTch = Trim(DS.Tables(0).Rows(index)("班主任"))
        cls.ClsGrd = Trim(DS.Tables(0).Rows(index)("年级"))
        cls.ClsRm = Trim(DS.Tables(0).Rows(index)("教室"))
        Me.Label6.Text = index + 1 & "      OF    " & DS.Tables(0).Rows.Count
        Return cls
    End Function

    Public Sub ShowData(ByVal cls As ClsInfo)
        Me.TextBox1.Text = cls.ClsNo
        Me.TextBox2.Text = cls.ClsTch
        Me.TextBox3.Text = cls.ClsRm
        Me.DropDownList1.SelectedItem.Text = cls.ClsGrd
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button4.Click
        Indexs = Indexs + 1
        ShowData(ShowData(Indexs))
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button5.Click
        Indexs = Indexs - 1
        ShowData(ShowData(Indexs))
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        If IsPostBack Then
            Dim cls As New ClsInfo()
            cls = GainData()
            If cls.ClsNo = "" Then
                Exit Sub
            End If
            sqlstr = "INSERT INTO classinfo (班号,班主任,年纪,教室) " & _
            "VALUES ('" & cls.ClsNo & "','" & cls.ClsTch & "'," & _
            "'" & cls.ClsGrd & "','" & cls.ClsRm & "')"
            If UpdateDataBase(sqlstr) = True Then
                LoadData()
                Indexs = 0
                ShowData(ShowData(Indexs))
            End If
        End If
    End Sub

    Public Function GainData() As ClsInfo
        Dim cls As New ClsInfo()
        cls.ClsNo = Me.TextBox1.Text.Trim
        cls.ClsTch = Me.TextBox2.Text.Trim
        cls.ClsRm = Me.TextBox3.Text.Trim
        cls.ClsGrd = Me.DropDownList1.SelectedItem.Text.Trim
        Return cls
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click
        If IsPostBack Then
            Dim cls As New ClsInfo()
            cls = GainData()
            If cls.ClsNo = "" Then
                Exit Sub
            End If
            sqlstr = "UPDATE classinfo SET 班主任='" & cls.ClsTch & "' " & _
            ",年纪='" & cls.ClsGrd & "' ,教室= '" & cls.ClsRm & "', " & _
            "WHERE 班号= '" & cls.ClsNo & "')"
            If UpdateDataBase(sqlstr) = True Then
                LoadData()
                Indexs = 0
                ShowData(ShowData(Indexs))
            End If
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button3.Click
        If IsPostBack Then
            sqlstr = "DELETE FROM classInfo WHERE (班号='" & Trim(Me.TextBox1.Text) & "')"
            If UpdateDataBase(sqlstr) = True Then
                LoadData()
                Indexs = 0
                ShowData(ShowData(Indexs))
            End If
        End If
    End Sub

End Class

Public Class ClsInfo
    Public ClsNo As String
    Public ClsTch As String
    Public ClsGrd As String
    Public ClsRm As String
End Class

⌨️ 快捷键说明

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