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

📄 student_frm.frm

📁 一套很不错的学生选课系统及学生信息管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
               Width           =   855
            End
            Begin VB.Label Label8 
               Alignment       =   2  'Center
               Caption         =   "年"
               BeginProperty Font 
                  Name            =   "宋体"
                  Size            =   10.5
                  Charset         =   134
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   960
               TabIndex        =   16
               Top             =   240
               Width           =   375
            End
            Begin VB.Label Label9 
               Alignment       =   2  'Center
               Caption         =   "月"
               BeginProperty Font 
                  Name            =   "宋体"
                  Size            =   10.5
                  Charset         =   134
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   2280
               TabIndex        =   15
               Top             =   240
               Width           =   255
            End
            Begin VB.Label Label10 
               Alignment       =   2  'Center
               Caption         =   "日"
               BeginProperty Font 
                  Name            =   "宋体"
                  Size            =   10.5
                  Charset         =   134
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   3480
               TabIndex        =   14
               Top             =   240
               Width           =   375
            End
         End
         Begin VB.TextBox Text4 
            Height          =   375
            Left            =   1440
            TabIndex        =   9
            Top             =   2040
            Width           =   4095
         End
         Begin VB.ComboBox Combo4 
            Height          =   300
            ItemData        =   "student_frm.frx":032B
            Left            =   1440
            List            =   "student_frm.frx":0335
            TabIndex        =   7
            Top             =   960
            Width           =   1335
         End
         Begin RichTextLib.RichTextBox RichTextBox1 
            Height          =   1215
            Left            =   1440
            TabIndex        =   8
            Top             =   2640
            Width           =   4575
            _ExtentX        =   8070
            _ExtentY        =   2143
            _Version        =   393217
            TextRTF         =   $"student_frm.frx":0341
         End
         Begin VB.Label Label1 
            Caption         =   "学号:"
            Height          =   375
            Left            =   240
            TabIndex        =   26
            Top             =   360
            Width           =   975
         End
         Begin VB.Label Label2 
            Caption         =   "性别:"
            Height          =   375
            Left            =   240
            TabIndex        =   25
            Top             =   960
            Width           =   975
         End
         Begin VB.Label Label3 
            Caption         =   "出生年月:"
            Height          =   375
            Left            =   240
            TabIndex        =   24
            Top             =   1440
            Width           =   975
         End
         Begin VB.Label Label4 
            Caption         =   "家庭地址:"
            Height          =   375
            Left            =   240
            TabIndex        =   23
            Top             =   2040
            Width           =   975
         End
         Begin VB.Label Label5 
            Caption         =   "备注:"
            Height          =   375
            Left            =   240
            TabIndex        =   22
            Top             =   2520
            Width           =   975
         End
         Begin VB.Label Label6 
            Caption         =   "姓名:"
            Height          =   375
            Left            =   3120
            TabIndex        =   21
            Top             =   360
            Width           =   975
         End
         Begin VB.Label Label7 
            Caption         =   "电话:"
            Height          =   375
            Left            =   3120
            TabIndex        =   20
            Top             =   960
            Width           =   975
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "编辑"
         Height          =   735
         Left            =   -73920
         TabIndex        =   1
         Top             =   4560
         Width           =   5295
         Begin VB.CommandButton Command1 
            Caption         =   "添加"
            Height          =   375
            Left            =   360
            TabIndex        =   5
            Top             =   240
            Width           =   855
         End
         Begin VB.CommandButton Command2 
            Caption         =   "取消"
            Height          =   375
            Left            =   1560
            TabIndex        =   4
            Top             =   240
            Width           =   855
         End
         Begin VB.CommandButton Command3 
            Caption         =   "保存"
            Height          =   375
            Left            =   2880
            TabIndex        =   3
            Top             =   240
            Width           =   855
         End
         Begin VB.CommandButton Command4 
            Caption         =   "退出"
            Height          =   375
            Left            =   4080
            TabIndex        =   2
            Top             =   240
            Width           =   855
         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 qn As String
Dim con As ADODB.Connection


Private Sub Command1_Click()
 
    Text1.Text = Empty
    Text2.Text = Empty
    Text3.Text = Empty
    Text4.Text = Empty
    RichTextBox1.Text = Empty
    Combo1.Text = Empty
    Combo2.Text = Empty
    Combo3.Text = Empty
    Combo4.Text = Empty
End Sub



Private Sub Command10_Click()
Dim rs As New ADODB.Recordset
Dim query As String
Dim query1 As String
Dim query2 As String
Dim query3 As String
Dim query4 As String
Dim query5 As String

query = "SELECT * FROM studentinfo WHERE "
If Check1.Value = 1 Then
    query1 = "sno" & " like '%" & Text6 & "%'" & " and "
    query = query & query1
End If
If Check2.Value = 1 Then
    query2 = "address" & " like '%" & Text7 & "%'" & " and "
    query = query & query2
End If
If Check3.Value = 1 Then
    query3 = "sname" & " like '%" & Text8 & "%'" & " and "
    query = query & query3
    End If

If Check4.Value = 1 Then
    query4 = "birth" & " like '%" & Combo6.Text & "%-%" & Combo7.Text & "%-%" & Combo8.Text & "%'" & " And """
    query = query & query4
End If
If Check5.Value = 1 Then
    query5 = "m" & " like '%" & text9 & "%'" & " and "
    query = query & query5
End If
query = Left(query, Len(query) - 5)

        
rs.Open query, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
If Not (rs.EOF And rs.BOF) Then
    rs.MoveFirst
    rs.MoveLast
End If
If rs.RecordCount > 0 Then
    Set DataGrid1.DataSource = rs
    MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
Else
    MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
End Sub



Private Sub Form_Load()
    Set con = New ADODB.Connection
    con.ConnectionString = Adodc1.ConnectionString
    con.CursorLocation = adUseClient
    con.Open

End Sub

Private Sub Command11_Click()
Unload Me
MDIForm1.Show
End Sub

Private Sub Command3_Click()
    '保存记录
    Dim myrs As New ADODB.Recordset

    myrs.Open "SELECT * FROM studentinfo", con, adOpenDynamic, adLockOptimistic, adCmdText
    myrs.AddNew

    If Text1.Text = Empty Then
        MsgBox "学号不能为空!"
        Text1.SetFocus
        Exit Sub
    End If
    If Text2.Text = Empty Then
        MsgBox "姓名不能为空!"
        Text2.SetFocus
        Exit Sub
    End If
    If Combo1.Text > 2300 And Combo1.Text < 1900 Then
        MsgBox "请输入1900到2300之间的年份!"
        Exit Sub
    End If
    If Combo2.Text > 12 Then
        MsgBox "月份不能大于12,小朋友!"
        Exit Sub
    Else
        Select Case Combo2.Text
            Case 1, 3, 5, 7, 8, 10, 12
                If Combo3.Text > 31 Then
                    MsgBox Combo2.Text & "月不能多于31天!"
                    Exit Sub
                End If
            Case 4, 6, 9, 11
                If Combo3.Text > 30 Then
                    MsgBox Combo2.Text & "月不能多于30天!"
                    Exit Sub
                End If
            Case 2
                If Val(Combo1.Text) \ 400 = Val(Combo1.Text) / 400 _
                   Or Val(Combo1.Text) \ 4 = Val(Combo1.Text) / 4 Then
                    If Combo3.Text > 28 Then
                        MsgBox "闰年2月不能多于28天!"
                    Exit Sub
                    End If
                Else
                    If Combo3.Text > 29 Then
                        MsgBox "平年2月不能多于29天!"
                    Exit Sub
                    End If
                End If
        End Select
    End If
    myrs.Fields(0) = Text1.Text
    myrs.Fields(1) = Text2.Text
    myrs.Fields(2) = Combo4.Text
    myrs.Fields(3) = Combo1.Text & "-" & Combo2.Text & "-" & Combo3.Text
    myrs.Fields(4) = Text3.Text
    myrs.Fields(5) = Text4.Text
    myrs.Fields(6) = RichTextBox1.Text

    myrs.Update     '调用Recordset对象Update方法保存数据
    Set DataGrid2.DataSource = myrs
    
    Text1.Text = Empty
    Text2.Text = Empty
    Text3.Text = Empty
    Text4.Text = Empty
    RichTextBox1.Text = Empty
    MsgBox "添加成功!"
End Sub

Private Sub Command4_Click()
Unload Me
End Sub



Private Sub Command5_Click()
Adodc1.Recordset.MoveFirst
End Sub

Private Sub Command6_Click()
   Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveLast
End Sub

Private Sub Command7_Click()
   Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveFirst
End Sub

Private Sub Command8_Click()
Adodc1.Recordset.MoveLast
End Sub

Private Sub Command9_Click()
Select Case Combo5.Text
    Case "学生编号"
        qn = "sno"
    Case "学生姓名"
        qn = "sname"
    Case "性别"
        qn = "sex"
    Case "电话号码"
        qn = "tel"
    Case "地址"
        qn = "address"
End Select

'Dim rs As New ADODB.Recordset
'Dim query1 As String
'
'query1 = "SELECT * FROM studentinfo WHERE " & qn & " like '%" & Text5.Text & "%'"
'
'rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
'Set DataGrid1.DataSource = Nothing
'If Not (rs.EOF And rs.BOF) Then
'    rs.MoveFirst
'    rs.MoveLast
'End If
'If rs.RecordCount > 0 Then
'    Set DataGrid1.DataSource = rs
'    MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
'Else
'    MsgBox "没有找到记录,请重新输入查询数据", vbInformation
'End If
        Adodc1.CommandType = adCmdText
        Adodc1.RecordSource = "select  * from studentinfo where " & qn & " like '%" & Text5.Text & "%'"
        Adodc1.Refresh
        If Adodc1.Recordset.EOF = True Then
           MsgBox "没有该学生,请重新查找!", vbInformation + vbOKOnly, "查询提示"
           Text5.Text = ""
           Text5.SetFocus
        End If

End Sub

⌨️ 快捷键说明

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