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

📄 frmcurriculum.vb

📁 我大2做的一个关于面向对象的课程设计
💻 VB
字号:
Imports System.Data
Imports System.Data.OleDb
Public Class frmCurriculum
    Inherits System.Windows.Forms.Form

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

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents cmdsubmit As System.Windows.Forms.Button
    Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents tb1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.cmdsubmit = New System.Windows.Forms.Button
        Me.DataGrid1 = New System.Windows.Forms.DataGrid
        Me.Label1 = New System.Windows.Forms.Label
        Me.tb1 = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'cmdsubmit
        '
        Me.cmdsubmit.Location = New System.Drawing.Point(224, 272)
        Me.cmdsubmit.Name = "cmdsubmit"
        Me.cmdsubmit.TabIndex = 1
        Me.cmdsubmit.Text = "提交"
        '
        'DataGrid1
        '
        Me.DataGrid1.AlternatingBackColor = System.Drawing.Color.OldLace
        Me.DataGrid1.BackColor = System.Drawing.Color.OldLace
        Me.DataGrid1.BackgroundColor = System.Drawing.Color.Tan
        Me.DataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.DataGrid1.CaptionBackColor = System.Drawing.Color.SaddleBrown
        Me.DataGrid1.CaptionForeColor = System.Drawing.Color.OldLace
        Me.DataGrid1.DataMember = ""
        Me.DataGrid1.FlatMode = True
        Me.DataGrid1.Font = New System.Drawing.Font("Tahoma", 8.0!)
        Me.DataGrid1.ForeColor = System.Drawing.Color.DarkSlateGray
        Me.DataGrid1.GridLineColor = System.Drawing.Color.Tan
        Me.DataGrid1.HeaderBackColor = System.Drawing.Color.Wheat
        Me.DataGrid1.HeaderFont = New System.Drawing.Font("Tahoma", 8.0!, System.Drawing.FontStyle.Bold)
        Me.DataGrid1.HeaderForeColor = System.Drawing.Color.SaddleBrown
        Me.DataGrid1.LinkColor = System.Drawing.Color.DarkSlateBlue
        Me.DataGrid1.Location = New System.Drawing.Point(0, 40)
        Me.DataGrid1.Name = "DataGrid1"
        Me.DataGrid1.ParentRowsBackColor = System.Drawing.Color.OldLace
        Me.DataGrid1.ParentRowsForeColor = System.Drawing.Color.DarkSlateGray
        Me.DataGrid1.ReadOnly = True
        Me.DataGrid1.SelectionBackColor = System.Drawing.Color.SlateGray
        Me.DataGrid1.SelectionForeColor = System.Drawing.Color.White
        Me.DataGrid1.Size = New System.Drawing.Size(336, 200)
        Me.DataGrid1.TabIndex = 3
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(104, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(144, 23)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "请根据您的需要选择课程"
        '
        'tb1
        '
        Me.tb1.Location = New System.Drawing.Point(112, 272)
        Me.tb1.Name = "tb1"
        Me.tb1.TabIndex = 5
        Me.tb1.Text = ""
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(48, 272)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(56, 23)
        Me.Label2.TabIndex = 6
        Me.Label2.Text = "课程号:"
        '
        'frmCurriculum
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(344, 306)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.tb1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.DataGrid1)
        Me.Controls.Add(Me.cmdsubmit)
        Me.MaximizeBox = False
        Me.Name = "frmCurriculum"
        Me.Text = "frmCurriculum"
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim SqlConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source=计算机选课系统.mdb"
    Dim Conn As New OleDbConnection(SqlConn)
    Dim ds As New DataSet
    Dim comm As OleDbCommand
    Dim t1 As Double
    Private m_prevForm As Form
    Public Sub New(ByRef pForm As Form)
        MyBase.New()
        InitializeComponent()
        m_prevForm = pForm
    End Sub
    Public Sub updatenow()
        Try
            ds.Clear()
            Dim sql1 As String = frmLogin.strStrdentNumber

            Dim sql As String = "select * from 课程 where 课程号"

            Dim com As New OleDbCommand(sql)

            Dim Comm As New OleDbDataAdapter(sql, Conn)
            Comm.Fill(ds, "课程")
            Conn.Open()
            DataGrid1.DataSource = ds.Tables("课程").DefaultView
            DataGrid1.Refresh()
            Conn.Close()


        Catch ex As Exception
            MsgBox(Err.Description, MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "出错")
            Exit Try
        End Try
    End Sub
   
    Private Sub frmCurriculum_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        updatenow()
    End Sub

    Private Sub cmdsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsubmit.Click

        inser()
        tb1.Text = ""
        MsgBox("操作完成")
      
    End Sub
    Sub inser()

        Try
            Dim lblNumber As String = frmLogin.strStrdentNumber
            Conn.Open()
            Dim StrSql As String = "Insert into 选课表 (课程号,学号) values ('" & tb1.Text & "','" & lblNumber & "')"   '进行插入操作
            comm = New OleDbCommand(StrSql, Conn)
            comm.ExecuteNonQuery()

            Conn.Close()


        Catch ex As Exception
            Conn.Close()
        End Try
    End Sub
End Class

⌨️ 快捷键说明

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