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

📄 student_frm.frm

📁 学生选课系统。VB+Access。可进行学生信息的管理
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Width           =   975
         End
         Begin VB.CommandButton cmdadd 
            Caption         =   "添加"
            Height          =   375
            Left            =   360
            TabIndex        =   22
            Top             =   360
            Width           =   975
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "数据录入或显示"
         Height          =   3495
         Left            =   240
         TabIndex        =   6
         Top             =   480
         Width           =   6015
         Begin VB.TextBox txtborndate 
            Height          =   495
            Left            =   1320
            TabIndex        =   44
            Top             =   1560
            Width           =   2295
         End
         Begin VB.TextBox txtm 
            Height          =   495
            Left            =   1320
            TabIndex        =   43
            Top             =   2880
            Width           =   4095
         End
         Begin VB.TextBox txtaddress 
            Height          =   495
            Left            =   1320
            TabIndex        =   19
            Top             =   2280
            Width           =   4095
         End
         Begin VB.TextBox txttel 
            Height          =   375
            Left            =   3000
            TabIndex        =   16
            Top             =   840
            Width           =   1335
         End
         Begin VB.ComboBox Combosex 
            Height          =   300
            Left            =   960
            TabIndex        =   14
            Top             =   960
            Width           =   975
         End
         Begin VB.PictureBox Picture1 
            Height          =   1095
            Left            =   4680
            ScaleHeight     =   1035
            ScaleWidth      =   915
            TabIndex        =   12
            Top             =   240
            Width           =   975
         End
         Begin VB.TextBox txtname 
            Height          =   375
            Left            =   2880
            TabIndex        =   10
            Top             =   240
            Width           =   975
         End
         Begin VB.TextBox txtid 
            Height          =   375
            Left            =   960
            TabIndex        =   8
            Top             =   240
            Width           =   975
         End
         Begin VB.Label Label11 
            AutoSize        =   -1  'True
            Caption         =   "备注:"
            Height          =   180
            Left            =   240
            TabIndex        =   20
            Top             =   3000
            Width           =   540
         End
         Begin VB.Label Label10 
            AutoSize        =   -1  'True
            Caption         =   "家庭地址:"
            Height          =   180
            Left            =   120
            TabIndex        =   18
            Top             =   2400
            Width           =   900
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            Caption         =   "出生年月:"
            Height          =   180
            Left            =   120
            TabIndex        =   17
            Top             =   1680
            Width           =   900
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            Caption         =   "电话:"
            Height          =   180
            Left            =   2280
            TabIndex        =   15
            Top             =   960
            Width           =   540
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "性别:"
            Height          =   180
            Left            =   240
            TabIndex        =   13
            Top             =   1080
            Width           =   540
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            Caption         =   "照片:"
            Height          =   180
            Left            =   4080
            TabIndex        =   11
            Top             =   360
            Width           =   540
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            Caption         =   "姓名:"
            Height          =   180
            Left            =   2280
            TabIndex        =   9
            Top             =   360
            Width           =   540
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            Caption         =   "学号:"
            Height          =   180
            Left            =   240
            TabIndex        =   7
            Top             =   360
            Width           =   540
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "编辑"
         Height          =   1095
         Left            =   -72000
         TabIndex        =   1
         Top             =   4320
         Width           =   6015
         Begin VB.CommandButton cmdlast 
            Caption         =   "最后一条记录"
            Height          =   495
            Left            =   4320
            TabIndex        =   5
            Top             =   360
            Width           =   1575
         End
         Begin VB.CommandButton cmdprevious 
            Caption         =   "上一条记录"
            Height          =   495
            Left            =   3000
            TabIndex        =   4
            Top             =   360
            Width           =   1215
         End
         Begin VB.CommandButton cmdnext 
            Caption         =   "下一条记录"
            Height          =   495
            Left            =   1560
            TabIndex        =   3
            Top             =   360
            Width           =   1215
         End
         Begin VB.CommandButton cmdfirst 
            Caption         =   "第一条记录"
            Height          =   495
            Left            =   120
            TabIndex        =   2
            Top             =   360
            Width           =   1215
         End
      End
   End
End
Attribute VB_Name = "student_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As ADODB.Connection
Private Sub cmdsimply_Click()
'查找记录
    Dim rs As New ADODB.Recordset
    Dim query As String
    If Combosimply.Text = "学号" Then
        query = "SELECT * FROM studentinfo WHERE " & "sno" & " = '" & Trim(txtsimply.Text) & "'"
    Else
        query = "SELECT * FROM studentinfo WHERE " & "sname" & " = '" & Trim(txtsimply.Text) & "'"
    End If
     rs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
    If Not (rs.EOF And rs.BOF) Then
        rs.MoveFirst
        rs.MoveLast
    End If
    If rs.RecordCount > 0 Then
        Set DataGrid2.DataSource = rs
        DataGrid2.Refresh
        MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
    Else
        MsgBox "没有找到记录,请重新输入查询数据", vbInformation
    End If
   txtsimply.Text = ""
End Sub
Private Sub cmdmh_Click()
'组合查询
Dim shenri As String
Dim myrs As New ADODB.Recordset
Dim query As String
If Check1.Value = 1 Then
'按学号查询
    query = "SELECT * FROM studentinfo WHERE " & "sno" & " = '" & Trim(txtid2.Text) & "'"
    myrs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
End If
If Check3.Value = 1 Then
'按姓名查询
    query = "SELECT * FROM studentinfo WHERE " & "sname" & " = '" & Trim(txtname2.Text) & "'"
    myrs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
End If
If Check5.Value = 1 Then
'按备注查询
    query = "SELECT * FROM studentinfo WHERE " & "m" & " = '" & Trim(txtm2.Text) & "'"
    myrs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
End If
If Check2.Value = 1 Then
'按地址查询
    query = "SELECT * FROM studentinfo WHERE " & "address" & " = '" & Trim(txtaddress2.Text) & "'"
    myrs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
End If
If Check4.Value = 1 Then
'按出生日期查询
    query = "SELECT * FROM studentinfo WHERE " & "birth" & " = '" & Trim(txtborndate2.Text) & "'"
    myrs.Open query, con, adOpenForwardOnly, adLockReadOnly
    Set DataGrid2.DataSource = Nothing
End If

If myrs.RecordCount > 0 Then
        Set DataGrid2.DataSource = myrs
        MsgBox "总共查到" & myrs.RecordCount & "记录", vbInformation
Else
        MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
End Sub
 Private Sub cmdsave_Click()
  '保存记录
    Dim myrs As New ADODB.Recordset
    myrs.Open "SELECT * FROM studentinfo", con, adOpenDynamic, adLockOptimistic, adCmdText
    myrs.AddNew

    If Not Testtxt(txtid.Text) Then
        MsgBox "学号不能为空!"
        txtid.SetFocus
        Exit Sub
    End If
    If Not Testtxt(txtname.Text) Then
        MsgBox "姓名不能为空!"
        txtname.SetFocus
        Exit Sub
    End If
    If Not Testtxt(txttel.Text) Then
        MsgBox "请输入联系电话!"
        txttel.SetFocus
        Exit Sub
    End If
    If Not Testtxt(txtaddress.Text) Then
        MsgBox "请输入家庭地址!"
        txtaddress.SetFocus
        Exit Sub
    End If
    If Not Testtxt(txtborndate.Text) Then
        MsgBox "请输入生日!"
        txtborndate.SetFocus
        Exit Sub
    End If
    
    myrs.Fields(0) = txtid.Text
    myrs.Fields(1) = txtname.Text
    myrs.Fields(2) = Combosex.Text
    myrs.Fields(3) = txtborndate.Text
    myrs.Fields(4) = txttel.Text
    myrs.Fields(5) = txtaddress.Text
    myrs.Fields(6) = txtm.Text
    myrs.Update
  Set DataGrid1.DataSource = myrs
   MsgBox "添加学生信息成功!", vbOKOnly + vbExclamation, "警告"
End Sub
Private Sub cmdfirst_Click()
'移动到首记录
    Adodc1.Recordset.MoveFirst
End Sub
Private Sub cmdlast_Click()
 '移动到尾记录
  Adodc1.Recordset.MoveLast
End Sub
Private Sub cmdprevious_Click()
    '移动到上一条记录
    If Not Adodc1.Recordset.BOF = True Then
        Adodc1.Recordset.MovePrevious
    Else
        Adodc1.Recordset.MoveLast
    End If
End Sub
Private Sub cmdnext_Click()
   '移动到下一条记录
    If Not Adodc1.Recordset.EOF = True Then
        Adodc1.Recordset.MoveNext
    Else
        Adodc1.Recordset.MoveFirst
    End If
End Sub
Private Sub cmdcancel_Click()
'添加
If MsgBox("是否取消对信息的修改?", vbYesNo + vbExclamation, "警告") = vbYes Then
Combosex.Clear
txtid = ""
txtname = ""
txttel = ""
txtaddress = ""
txtm = ""
txtborndate = ""
txtid.SetFocus
End If
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdadd_Click()
'添加记录前清空文本框
Combosex.Clear
Combosex.AddItem "男"
Combosex.AddItem "女"
txtid = ""
txtname = ""
txttel = ""
txtaddress = ""
txtborndate = ""
txtm = ""
End Sub

Private Sub Form_Load()
 '创建连接,并打开
    Set con = New ADODB.Connection
    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\050531123贾晨微\db1.mdb;Persist Security Info=False"
    con.CursorLocation = adUseClient
    con.Open
Combosex.AddItem "男"
Combosex.AddItem "女"
Combosimply.AddItem "学号"
Combosimply.AddItem "姓名"
End Sub

⌨️ 快捷键说明

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