📄 frmsinfo.frm
字号:
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 17
Top = 960
Width = 855
End
Begin VB.Label Label1
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "学号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 16
Top = 360
Width = 975
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "家庭地址"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4200
TabIndex = 15
Top = 2640
Width = 975
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "联系电话"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4200
TabIndex = 14
Top = 1680
Width = 975
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "出生日期"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4200
TabIndex = 13
Top = 1080
Width = 975
End
Begin VB.Label Label2
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4200
TabIndex = 12
Top = 480
Width = 615
End
End
Attribute VB_Name = "frmsinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdcancel_Click()
FrmMain.StatusBarmy.Panels.Item(1).Text = ""
Unload Me
End Sub
Private Sub cmdclear_Click()
txtid.Text = ""
txtname.Text = ""
cbogender.ListIndex = 0
txtbirthday.Text = ""
cboclassnumber.ListIndex = 0
txtphone.Text = ""
txtdate.Text = "'"
txtaddress.Text = ""
txtcomment.Text = ""
FrmMain.StatusBarmy.Panels.Item(1).Text = ""
End Sub
Private Sub cmdOK_Click()
Dim mrc As Adodb.Recordset
Dim txtsql As String, msgtext As String
If Not testtxt(txtid.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入学号!"
txtname.SetFocus: Exit Sub
End If
If Not testtxt(txtname.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入姓名!"
txtname.SetFocus: Exit Sub
End If
If Not testtxt(cbogender.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入性别!"
cbogender.SetFocus: Exit Sub
End If
If Not testtxt(txtbirthday.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入出生日期!"
txtbirthday.SetFocus: Exit Sub
End If
If Not testtxt(cboclassnumber.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请选择班级!"
cboclassnumber.SetFocus: Exit Sub
End If
If Not testtxt(txtphone.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入联系电话!"
txtphone.SetFocus: Exit Sub
End If
If Not testtxt(txtdate.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入入校时间!"
txtdate.SetFocus: Exit Sub
End If
If Not testtxt(txtaddress.Text) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入家庭地址!"
txtaddress.SetFocus: Exit Sub
End If
If Not IsNumeric(Trim(txtphone.Text)) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "联系电话应该是数字型!"
txtphone.SelStart = 0: txtphone.SelLength = Len(txtphone.Text)
txtphone.SetFocus: Exit Sub
End If
If Not IsNumeric(Trim(txtid.Text)) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "学号应该是数字型!"
txtid.SelStart = 0: txtid.SelLength = Len(txtid.Text)
txtid.SetFocus: Exit Sub
End If
If Not IsDate(Trim(txtbirthday.Text)) Then
MsgBox "出生日期输入有误!" & Chr(13) & "举例:(2003-01-01)", vbOKOnly + vbExclamation, "提示"
txtbirthday.SelStart = 0: txtbirthday.SelLength = Len(txtbirthday.Text)
txtbirthday.SetFocus: Exit Sub
Else
txtbirthday = Format(txtbirthday, "yyyy-mm-dd")
End If
If Not IsDate(Trim(txtdate.Text)) Then
MsgBox "入校日期输入有误!" & Chr(13) & "举例:(2003-1-1)", vbOKOnly + vbExclamation, "提示"
txtdate.SelStart = 0: txtdate.SelLength = Len(txtdate.Text)
txtdate.SetFocus: Exit Sub
Else
txtdate = Format(txtdate, "yyyy-mm-dd")
End If
txtsql = "select * from student_info where student_id=' " & Trim(txtid.Text) & " ' " & " and class_no=' " & Trim(cboclassnumber.Text) & "'"
Set mrc = executesql(txtsql, msgtext)
If mrc.EOF = False Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "该班级中已经存在此学号,请重新输入!"
mrc.Close: txtid.SelStart = 0
txtid.SelLength = Len(txtid.Text)
txtid.SetFocus: Exit Sub
Else
mrc.AddNew: mrc.Fields(0) = Trim(txtid.Text)
mrc.Fields(1) = Trim(txtname.Text)
mrc.Fields(2) = Trim(cbogender.Text)
mrc.Fields(3) = Trim(txtbirthday.Text)
mrc.Fields(4) = Trim(cboclassnumber.Text)
mrc.Fields(5) = Trim(txtphone.Text)
mrc.Fields(6) = Trim(txtdate.Text)
mrc.Fields(7) = Trim(txtaddress.Text)
mrc.Fields(8) = Trim(txtcomment.Text)
mrc.Update
FrmMain.StatusBarmy.Panels.Item(1).Text = "添加学籍信息成功!"
End If
End Sub
Private Sub Form_Load()
Dim mrc As Adodb.Recordset: Dim txtsql As String
Dim msgtext As String: Dim i As Integer
cbogender.AddItem ""
cbogender.AddItem "男"
cbogender.AddItem "女"
txtsql = "select * from class_info"
Set mrc = executesql(txtsql, msgtext)
mrc.MoveFirst
cboclassnumber.AddItem ""
For i = 1 To mrc.RecordCount
cboclassnumber.AddItem mrc.Fields(0)
mrc.MoveNext
Next
mrc.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -