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

📄 frmaddstu.frm

📁 学生学籍管理系统是一个教育单位不可缺少的部分,它的内容对于学校的决策者和管理者来说都至关重要,所以学生学籍管理系统应该能够为用户提供充足的信息和快捷的查询手段。但一直以来人们使用传统人工的方式管理文件
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmAddStu 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   5400
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7695
   Icon            =   "FrmAddStu.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5400
   ScaleWidth      =   7695
   StartUpPosition =   1  '所有者中心
   Begin VB.TextBox EditStu 
      Height          =   915
      Index           =   8
      Left            =   660
      MultiLine       =   -1  'True
      TabIndex        =   23
      Top             =   3480
      Width           =   6375
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      Left            =   5040
      Style           =   2  'Dropdown List
      TabIndex        =   18
      Top             =   1560
      Width           =   1395
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "FrmAddStu.frx":08CA
      Left            =   5040
      List            =   "FrmAddStu.frx":08CC
      Style           =   2  'Dropdown List
      TabIndex        =   14
      Top             =   735
      Width           =   1395
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   3
      Left            =   1320
      TabIndex        =   17
      Top             =   1560
      Width           =   2595
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   5
      Left            =   5040
      TabIndex        =   20
      Top             =   1980
      Width           =   1395
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   7
      Left            =   1320
      TabIndex        =   22
      Top             =   2820
      Width           =   1815
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   4
      Left            =   1320
      TabIndex        =   19
      Top             =   1980
      Width           =   2595
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   1
      Left            =   1320
      TabIndex        =   13
      Top             =   735
      Width           =   1515
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定(&O)"
      Default         =   -1  'True
      Height          =   375
      Left            =   4560
      TabIndex        =   24
      Top             =   4920
      Width           =   1155
   End
   Begin VB.CommandButton Command2 
      Cancel          =   -1  'True
      Caption         =   "取消(&C)"
      Height          =   375
      Left            =   6000
      TabIndex        =   25
      Top             =   4920
      Width           =   1035
   End
   Begin VB.TextBox EditStu 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   "0"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   0
      EndProperty
      Height          =   315
      Index           =   0
      Left            =   1320
      MaxLength       =   8
      TabIndex        =   12
      Top             =   335
      Width           =   1275
   End
   Begin VB.TextBox EditStu 
      Height          =   315
      Index           =   6
      Left            =   1320
      TabIndex        =   21
      Top             =   2400
      Width           =   2235
   End
   Begin VB.TextBox EditStu 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   "yyyy""年""M""月""d""日"""
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   3
      EndProperty
      Height          =   315
      Index           =   2
      Left            =   1320
      TabIndex        =   15
      Top             =   1140
      Width           =   1695
   End
   Begin VB.ComboBox Combo3 
      Height          =   300
      Left            =   5040
      TabIndex        =   16
      Top             =   1140
      Width           =   1395
   End
   Begin VB.Line Line1 
      BorderColor     =   &H00808080&
      BorderStyle     =   6  'Inside Solid
      X1              =   0
      X2              =   7680
      Y1              =   4680
      Y2              =   4680
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "备注"
      Height          =   180
      Left            =   420
      TabIndex        =   1
      Top             =   3240
      Width           =   360
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "邮政编码:"
      Height          =   180
      Left            =   4140
      TabIndex        =   2
      Top             =   2040
      Width           =   900
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "籍贯:"
      Height          =   180
      Left            =   780
      TabIndex        =   8
      Top             =   1620
      Width           =   540
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "性别:"
      Height          =   180
      Left            =   4500
      TabIndex        =   5
      Top             =   795
      Width           =   540
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "寝室号码:"
      Height          =   180
      Left            =   420
      TabIndex        =   0
      Top             =   2880
      Width           =   900
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "家庭住址:"
      Height          =   180
      Left            =   420
      TabIndex        =   7
      Top             =   2040
      Width           =   900
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "政治面貌:"
      Height          =   180
      Left            =   4140
      TabIndex        =   3
      Top             =   1620
      Width           =   900
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "姓名:"
      Height          =   180
      Left            =   720
      TabIndex        =   10
      Top             =   795
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "学号:"
      Height          =   180
      Left            =   780
      TabIndex        =   11
      Top             =   435
      Width           =   540
   End
   Begin VB.Label Label12 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "联系电话:"
      Height          =   180
      Left            =   420
      TabIndex        =   6
      Top             =   2460
      Width           =   900
   End
   Begin VB.Label Label13 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "出生年月:"
      Height          =   180
      Left            =   420
      TabIndex        =   9
      Top             =   1200
      Width           =   900
   End
   Begin VB.Label Label14 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "民族:"
      Height          =   180
      Left            =   4500
      TabIndex        =   4
      Top             =   1200
      Width           =   540
   End
End
Attribute VB_Name = "FrmAddStu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim EditNum As String
Dim temp As String

Public Sub LoadStu(temp)
EditNum = temp
Me.Show 1
End Sub


Private Sub Command1_Click()

'On Error Resume Next
'检测输入的数据
If Trim(EditStu(0).Text) = "" Or Val(Trim(EditStu(0).Text)) > 99999999 Or Val(Trim(EditStu(0).Text)) <= 0 Or Len(EditStu(0)) <> 8 Then
     MsgBox "学号输入有错误!请重新输入学号(xxxxxxxx)!", vbInformation
    EditStu(0).SetFocus
    Exit Sub
End If

If Trim(EditStu(1).Text) = "" Then
    MsgBox "必须输入学生的姓名!", vbInformation
    EditStu(1).Text = ""
    EditStu(1).SetFocus
    Exit Sub
End If

If IsDate(EditStu(2).Text) = False Then
   MsgBox "请按照(YYYY-MM-DD)的格式输入出生年月!", vbOKOnly + vbExclamation, "警告"
   EditStu(2).SelLength = Len(EditStu(2).Text)
   EditStu(2).SetFocus
   Exit Sub
End If
 
Dim i As Integer
For i = 0 To 8
    If InStr(1, EditStu(i).Text, "'", 1) Then
        MsgBox "添加的资料有非法字符(不允许输入'号)!", vbInformation
        Exit Sub
        EditStu(i).SetFocus
    End If
Next

If EditStu(0).Enabled Then
    '添加资料
    sqlstr = "select * from StuInfo where SID='" & EditStu(0).Text & "'"
    rs.Open sqlstr, con, 1, 1
    If Not rs.EOF Then
        MsgBox "已经存在学号为" & EditStu(0).Text & "的学生资料,请重新输入!", vbInformation
        EditStu(0).SetFocus
        Exit Sub
    End If
    rs.Close: Set rs = Nothing
    
    sqlstr = "insert into StuInfo(SID,SName,SGender,SPlace,SBirthday,SMinzu,SZhengzhi,SDormitory,SAddress,SCode,STel,SRemark)"
    sqlstr = sqlstr & "values('" & EditStu(0).Text & "','" & EditStu(1).Text & "','" & Combo1.Text & "',"
    sqlstr = sqlstr & "'" & EditStu(3).Text & "','" & EditStu(2).Text & "','" & Combo3.Text & "','" & Combo2.Text & "','" & EditStu(7).Text & "',"
    sqlstr = sqlstr & "'" & EditStu(4).Text & "','" & EditStu(5).Text & "','" & EditStu(6).Text & "','" & EditStu(8).Text & "')"
    
Else
  ' '修改资料
   sqlstr = "update StuInfo set SName='" & EditStu(1).Text & "',SBirthday='" & EditStu(2).Text & "',SGender='" & Combo1.Text & "',"
   sqlstr = sqlstr & "SPlace='" & EditStu(3).Text & "',SMinzu='" & Combo3.Text & "',SZhengzhi='" & Combo2.Text & "',SAddress='" & EditStu(4).Text & "',"
   sqlstr = sqlstr & "SCode='" & EditStu(5).Text & "',STel='" & EditStu(6).Text & "',SDormitory='" & EditStu(7).Text & "',SRemark='" & EditStu(8).Text & "' "
   sqlstr = sqlstr & "where SID='" & EditStu(0).Text & "'"
End If

con.Execute sqlstr

If EditStu(0).Enabled Then
    If MsgBox("添加学号为" & EditStu(0).Text & "的学生资料成功!是否继续?", vbYesNo) = vbYes Then
      For i = 0 To 8
          EditStu(i).Text = ""
      Next
      EditStu(0).SetFocus
    Else
      Call Frmstu.ListviewLoad(classid)
      Unload Me
    End If
Else
           '修改操作提交后退出窗体
         MsgBox "修改学号为" & EditStu(0).Text & "的学生资料成功!", vbInformation
           Call Frmstu.ListviewLoad(classid)
          Unload Me
    End If
End Sub

Private Sub Command2_Click()
   Unload Me
End Sub

Private Sub Form_Load()
  On Error Resume Next
'确定添加或者修改,保存数据
Combo1.Clear
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo1.ListIndex = 0

Combo2.Clear
Combo2.AddItem ""
Combo2.AddItem "团员"
Combo2.AddItem "党员"
Combo2.AddItem "预备党员"
Combo2.ListIndex = 1

Combo3.Clear
Combo3.AddItem "汉族"
Combo3.AddItem "瑶族"
Combo3.AddItem "土家族"
Combo3.AddItem "侗族"
Combo3.AddItem "白族"
Combo3.AddItem "苗族"
Combo3.AddItem "回族"
Combo3.AddItem "壮族"
Combo3.ListIndex = 0

If EditNum = "00000000" Then
    Me.Caption = "添加学生资料(班级:" & classid & ")"
    Command1.Caption = "添加(&A)"
    EditStu(0).Text = classid
    EditStu(0).SelStart = 6
Else
    Me.Caption = "修改学号为" & EditNum & "的学生资料"
    EditStu(0).Enabled = False
    Command1.Caption = "修改(&M)"
    Dim rs As New ADODB.Recordset, sqlstr As String
     
    sqlstr = "select * from StuInfo where SID='" & EditNum & "'"
    rs.Open sqlstr, con
    '把数据代入文本框中
    
    EditStu(0).Text = rs.Fields("SID")
    EditStu(1).Text = rs.Fields("SName")
    EditStu(2).Text = rs.Fields("SBirthday")
    EditStu(3).Text = rs.Fields("SPlace")
    EditStu(4).Text = rs.Fields("SAddress")
    EditStu(5).Text = rs.Fields("SCode")
    EditStu(6).Text = rs.Fields("STel")
    EditStu(7).Text = rs.Fields("SDormitory")
    EditStu(8).Text = rs.Fields("SRemark")
    
          
    If rs.Fields("SGender") = "男" Then
        Combo1.ListIndex = 0
    ElseIf rs.Fields("SGender") = "女" Then
        Combo1.ListIndex = 1
    End If
    
    If rs.Fields("SZhengzhi") = "" Then
        Combo2.ListIndex = 0
    ElseIf rs.Fields("SZhengzhi") = "团员" Then
        Combo2.ListIndex = 1
    ElseIf rs.Fields("SZhengzhi") = "党员" Then
        Combo2.ListIndex = 2
    ElseIf rs.Fields("SZhengzhi") = "预备党员" Then
        Combo2.ListIndex = 3
    End If
    
    Select Case rs.Fields("SMinzu")
    Case "汉族": Combo3.ListIndex = 0
    Case "瑶族": Combo3.ListIndex = 1
    Case "土家族": Combo3.ListIndex = 2
    Case "侗族": Combo3.ListIndex = 3
    Case "白族": Combo3.ListIndex = 4
    Case "苗族": Combo3.ListIndex = 5
    Case "回族": Combo3.ListIndex = 6
    Case "壮族": Combo3.ListIndex = 7
    End Select
    
    rs.Close: Set rs = Nothing
End If
End Sub

⌨️ 快捷键说明

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