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

📄 frmaddess.frm

📁 大学数据库原理的课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmAddEss 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "添加学籍信息"
   ClientHeight    =   2325
   ClientLeft      =   2910
   ClientTop       =   2130
   ClientWidth     =   5085
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2325
   ScaleWidth      =   5085
   Begin VB.ComboBox cboClass 
      Height          =   300
      Left            =   1440
      TabIndex        =   10
      Top             =   1710
      Width           =   1815
   End
   Begin MSAdodcLib.Adodc adoAdd 
      Height          =   375
      Left            =   3720
      Top             =   1800
      Visible         =   0   'False
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   312
      Left            =   3600
      TabIndex        =   9
      Top             =   720
      Width           =   1215
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "确认添加"
      Default         =   -1  'True
      Height          =   312
      Left            =   3600
      TabIndex        =   8
      Top             =   240
      Width           =   1215
   End
   Begin VB.ComboBox cboSex 
      Height          =   300
      ItemData        =   "frmAddEss.frx":0000
      Left            =   1440
      List            =   "frmAddEss.frx":000A
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   960
      Width           =   1812
   End
   Begin VB.TextBox txtBorn 
      Height          =   264
      Left            =   1440
      TabIndex        =   6
      Top             =   1350
      Width           =   1812
   End
   Begin VB.TextBox txtName 
      Height          =   264
      Left            =   1440
      TabIndex        =   5
      Top             =   600
      Width           =   1812
   End
   Begin VB.TextBox txtSID 
      Height          =   264
      Left            =   1440
      TabIndex        =   4
      Top             =   240
      Width           =   1812
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "班    级"
      Height          =   180
      Left            =   480
      TabIndex        =   11
      Top             =   1770
      Width           =   720
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "出生日期"
      Height          =   180
      Left            =   480
      TabIndex        =   3
      Top             =   1392
      Width           =   720
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "性    别"
      Height          =   180
      Left            =   480
      TabIndex        =   2
      Top             =   1005
      Width           =   750
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "姓    名"
      Height          =   180
      Left            =   480
      TabIndex        =   1
      Top             =   645
      Width           =   750
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "学    号"
      Height          =   180
      Left            =   480
      TabIndex        =   0
      Top             =   288
      Width           =   744
   End
End
Attribute VB_Name = "frmAddEss"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'添加学籍信息窗体frmAddEss
Option Explicit

Private Sub cboClass_LostFocus()    '班级组合框失去焦点时检查列表,添加新项
    Call NewClassItem(cboClass)     '调用标准模块中的过程
End Sub

Private Sub cmdExit_Click() '退出
    Unload Me
End Sub

Private Sub cmdOk_Click() '确认添加
    '各文本框若为空白,提示重新输入
    If Trim$(txtSID.Text) = "" Then
        MsgBox "请输入学号!", vbExclamation
        txtSID.SetFocus
        Exit Sub
    End If
    If Trim$(txtName.Text) = "" Then
        MsgBox "请输入姓名!", vbExclamation
        txtName.SetFocus
        Exit Sub
    End If
    If Trim$(txtBorn.Text) = "" Then
        MsgBox "请输入出生日期!", vbExclamation
        txtBorn.SetFocus
        Exit Sub
    End If
    If Trim$(cboClass.Text) = "" Then
        MsgBox "请选择或输入班级!", vbExclamation
        cboClass.SetFocus
        Exit Sub
    End If
    
    adoAdd.Refresh                  '刷新记录集(关键语句)
    '检查是否有重复学号(利用记录集的Find方法)
    adoAdd.Recordset.Find ("学号='" & txtSID.Text & "'")
    If Not adoAdd.Recordset.EOF Then              '若已有该学号
        MsgBox "学号重复,请重新输入!", vbExclamation
        Call FocusBack(txtSID)      '焦点返回学号框
        Exit Sub
    End If
    If Not IsDate(txtBorn.Text) Then '出生日期若非日期型,重新输入
        MsgBox "出生日期应按日期格式(yyyy-mm-dd)输入!", vbExclamation
        Call FocusBack(txtBorn)      '焦点返回出生日期框
        Exit Sub
    Else '若日期格式正确
        txtBorn.Text = Format(txtBorn.Text, "yyyy-mm-dd") '转换为4位年份
        With adoAdd.Recordset
            .AddNew                           '添加记录
            '为各字段赋值
            .Fields(0) = Trim$(txtSID.Text)        '学号
            .Fields(1) = Trim$(txtName.Text)       '姓名
            .Fields(2) = Trim$(cboSex.Text)   '性别
            .Fields(3) = Trim$(txtBorn.Text)       '出生日期
            .Fields(4) = Trim$(cboClass.Text) '班级
            .Update                           '更新数据库
        End With
        MsgBox "学籍信息已成功添加!", vbInformation
    End If
End Sub

Private Sub Form_Load() '窗体加载
    Dim sql As String
    sql = "SELECT * FROM 学籍"  'SQL语句用于创建记录集(源)
    adoAdd.RecordSource = sql   '设置记录源
    adoAdd.Refresh
    Call AddClassItem(cboClass) '调用标准模块中的过程填充班级组合框
End Sub

Private Sub Form_Unload(Cancel As Integer) '窗体卸载
    frmMain.Show        '显示主窗体
End Sub

Private Sub txtSID_KeyPress(KeyAscii As Integer) '学号文本框
    '按键非数字或回删键,取消
    If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
        KeyAscii = 0
    End If
End Sub

⌨️ 快捷键说明

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