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

📄 frmstudentedit.frm

📁 随着学校的规模不断扩大
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmStudentEdit 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "学生资料编辑"
   ClientHeight    =   6720
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9540
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6720
   ScaleWidth      =   9540
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "返回(&R)"
      Height          =   465
      Left            =   7980
      TabIndex        =   31
      Top             =   6090
      Width           =   1425
   End
   Begin VB.CommandButton Command1 
      Caption         =   "保存(&Q)"
      Height          =   465
      Left            =   6330
      TabIndex        =   30
      Top             =   6090
      Width           =   1425
   End
   Begin VB.Frame Frame2 
      Caption         =   "个人履历"
      Height          =   1725
      Left            =   90
      TabIndex        =   28
      Top             =   4290
      Width           =   9315
      Begin VB.TextBox Text11 
         Height          =   1395
         Left            =   90
         TabIndex        =   29
         Top             =   240
         Width           =   9075
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "基础信息"
      Height          =   4125
      Left            =   90
      TabIndex        =   0
      Top             =   120
      Width           =   9315
      Begin VB.ComboBox Combo1 
         Height          =   330
         Left            =   5970
         Style           =   2  'Dropdown List
         TabIndex        =   33
         Top             =   870
         Width           =   1455
      End
      Begin VB.TextBox Text10 
         Height          =   345
         Left            =   5970
         TabIndex        =   27
         Top             =   270
         Width           =   3165
      End
      Begin VB.TextBox Text9 
         Height          =   375
         Left            =   5970
         TabIndex        =   26
         Top             =   2975
         Width           =   3165
      End
      Begin VB.TextBox Text8 
         Height          =   375
         Left            =   1260
         TabIndex        =   25
         Top             =   3510
         Width           =   7875
      End
      Begin VB.TextBox Text7 
         Height          =   375
         Left            =   1260
         TabIndex        =   22
         Top             =   2975
         Width           =   2325
      End
      Begin MSComCtl2.DTPicker DTPicker2 
         Height          =   315
         Left            =   5970
         TabIndex        =   20
         Top             =   2550
         Width           =   3165
         _ExtentX        =   5583
         _ExtentY        =   556
         _Version        =   393216
         Format          =   163184641
         CurrentDate     =   38086
      End
      Begin VB.TextBox Text6 
         Height          =   375
         Left            =   5970
         TabIndex        =   19
         Top             =   1950
         Width           =   3165
      End
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   375
         Left            =   1260
         TabIndex        =   17
         Top             =   2440
         Width           =   2325
         _ExtentX        =   4101
         _ExtentY        =   661
         _Version        =   393216
         Format          =   163184641
         CurrentDate     =   38086
      End
      Begin VB.TextBox Text5 
         Height          =   345
         Left            =   1260
         TabIndex        =   14
         Top             =   1935
         Width           =   2325
      End
      Begin VB.TextBox Text4 
         Height          =   375
         Left            =   5970
         TabIndex        =   12
         Top             =   1410
         Width           =   3165
      End
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   1260
         TabIndex        =   10
         Top             =   1400
         Width           =   2325
      End
      Begin VB.OptionButton Option2 
         Caption         =   "女"
         Height          =   315
         Left            =   8550
         TabIndex        =   8
         Top             =   930
         Width           =   615
      End
      Begin VB.OptionButton Option1 
         Caption         =   "男"
         Height          =   375
         Left            =   8040
         TabIndex        =   7
         Top             =   900
         Value           =   -1  'True
         Width           =   555
      End
      Begin VB.TextBox Text1 
         Height          =   405
         Left            =   1260
         TabIndex        =   2
         Top             =   270
         Width           =   2325
      End
      Begin VB.TextBox Text2 
         Height          =   405
         Left            =   1260
         TabIndex        =   6
         Top             =   835
         Width           =   2325
      End
      Begin VB.Label Label14 
         Caption         =   "班级:"
         Height          =   210
         Left            =   4800
         TabIndex        =   32
         Top             =   930
         Width           =   525
      End
      Begin VB.Label Label13 
         Caption         =   "家庭地址:"
         Height          =   285
         Left            =   120
         TabIndex        =   24
         Top             =   3600
         Width           =   1125
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "邮政编码:"
         Height          =   210
         Left            =   4800
         TabIndex        =   23
         Top             =   3060
         Width           =   945
      End
      Begin VB.Label Label11 
         Caption         =   "联系电话:"
         Height          =   345
         Left            =   120
         TabIndex        =   21
         Top             =   3030
         Width           =   1035
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "出生日期:"
         Height          =   210
         Left            =   4800
         TabIndex        =   18
         Top             =   2610
         Width           =   945
      End
      Begin VB.Label Label9 
         Caption         =   "入学日期:"
         Height          =   345
         Left            =   120
         TabIndex        =   16
         Top             =   2550
         Width           =   1065
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "家长姓名:"
         Height          =   210
         Left            =   4800
         TabIndex        =   15
         Top             =   2100
         Width           =   945
      End
      Begin VB.Label Label7 
         Caption         =   "政治面貌:"
         Height          =   210
         Left            =   120
         TabIndex        =   13
         Top             =   2010
         Width           =   945
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "籍贯:"
         Height          =   210
         Left            =   4800
         TabIndex        =   11
         Top             =   1530
         Width           =   525
      End
      Begin VB.Label Label5 
         Caption         =   "民族:"
         Height          =   315
         Left            =   120
         TabIndex        =   9
         Top             =   1470
         Width           =   615
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "性别:"
         Height          =   210
         Left            =   7500
         TabIndex        =   5
         Top             =   960
         Width           =   525
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "身份证号:"
         Height          =   210
         Left            =   120
         TabIndex        =   4
         Top             =   930
         Width           =   945
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "姓名:"
         Height          =   210
         Left            =   4800
         TabIndex        =   3
         Top             =   360
         Width           =   525
      End
      Begin VB.Label Label1 
         Caption         =   "学籍号:"
         Height          =   315
         Left            =   120
         TabIndex        =   1
         Top             =   420
         Width           =   825
      End
   End
End
Attribute VB_Name = "frmStudentEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private mblnEdit As Boolean
Private mlngID  As Long

Public Sub EditStudent(Optional ByVal lngID As Long = 0)
Dim rst As Recordset
    mlngID = lngID
    mblnEdit = (lngID <> 0)
    Call initCmbClass
    If mblnEdit Then
        Set rst = New Recordset
        rst.ActiveConnection = pCN
        rst.CursorLocation = adUseClient
        rst.LockType = adLockBatchOptimistic
        rst.CursorType = adOpenStatic
        rst.Source = "select * from 学生信息 where ID=" & lngID
        rst.Open
        Text1.Text = rst![学籍号] & ""
        Text10.Text = rst![姓名] & ""
        Text2.Text = rst![身份证号] & ""
        Call SetCmbClassIndex(rst![班级])
        
        If rst![性别] = "男" Then
            Option1.Value = True
        Else
            Option2.Value = False
        End If
        Text3.Text = rst![民族] & ""
        Text4.Text = rst![籍贯] & ""
        Text5.Text = rst![政治面貌] & ""
        Text6.Text = rst![家长姓名] & ""
        DTPicker1.Value = rst![入学日期]
        DTPicker2.Value = rst![出生日期]
        
        Text7.Text = rst![联系电话] & ""
        Text8.Text = rst![邮政编码] & ""
        Text9.Text = rst![家庭地址] & ""
        Text11.Text = rst![个人履历] & ""
        
    End If
    
    Set rst = Nothing
    Me.Show 1
End Sub

Private Sub SetCmbClassIndex(strClassName As String)
Dim i As Integer
    For i = 0 To Combo1.ListCount - 1
        If Combo1.List(i) = strClassName Then
            Combo1.ListIndex = i
            Exit For
        End If
    Next i
End Sub

Private Sub Command1_Click()
Dim rst As Recordset
On Error GoTo Proc_Exit
    If Len(Text1) = 0 Or Len(Text10) = 0 Then
        MsgBox "学生姓名和学籍号不能为空!", vbInformation
        GoTo Proc_Exit
    End If
    ''表示编辑状态
    Set rst = New Recordset
    rst.ActiveConnection = pCN
    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.CursorType = adOpenStatic

    If mblnEdit Then
        rst.Source = "select * from 学生信息 where ID=" & mlngID
        rst.Open
    Else
        rst.Source = "select * from 学生信息"
        rst.Open
        rst.AddNew
    End If
    
    rst![学籍号] = Text1.Text
    rst![姓名] = Text10.Text
    rst![身份证号] = Text2.Text
    
    rst![班级] = Combo1.Text
    
    
    rst![性别] = IIf(Option1.Value, "男", "女")

    rst![民族] = Text3.Text
    rst![籍贯] = Text4.Text
    rst![政治面貌] = Text5.Text
    
    rst![家长姓名] = Text6.Text
    rst![入学日期] = DTPicker1.Value
    rst![出生日期] = DTPicker2.Value
    
    rst![联系电话] = Text7.Text
    rst![邮政编码] = Text8.Text
    rst![家庭地址] = Text9.Text
    rst![个人履历] = Text11.Text
        
    rst.UpdateBatch
    Text1.Text = ""
    Text10.Text = ""
    
    Text1.SetFocus
    
    mblnEdit = False
Proc_Exit:
    Set rst = Nothing
    If Err.Number <> 0 Then
    
        If Err.Number = -2147467259 Then
            MsgBox "学籍号不能重复!", vbInformation
        Else
            MsgBox "发生意外错误,错误号:" & Err.Number & " 错误描述:" & Err.Description, vbInformation
        End If
        Err.Clear
    End If
End Sub

Private Sub initCmbClass()
Dim i As Integer
Dim rst As Recordset
    Set rst = New Recordset
    rst.ActiveConnection = pCN
    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.CursorType = adOpenStatic
    rst.Source = "select * from 班级信息"
    rst.Open
    
    Combo1.Clear
    For i = 1 To rst.RecordCount
        Combo1.AddItem rst![班级名称]
        rst.MoveNext
    Next i
    If Combo1.ListCount > 0 Then
        Combo1.ListIndex = 0
    End If
    
    Set rst = Nothing
    
    
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

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