📄 frmstudentadd.frm
字号:
VERSION 5.00
Begin VB.Form frmStudentADD
Caption = "学生登记"
ClientHeight = 4365
ClientLeft = 60
ClientTop = 345
ClientWidth = 4800
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4365
ScaleWidth = 4800
StartUpPosition = 1 '所有者中心
Begin VB.Frame frmNavigator
Height = 1335
Left = 480
TabIndex = 8
Top = 2760
Width = 3855
Begin VB.CommandButton cmdReturn
Caption = "返回"
Height = 375
Left = 1920
TabIndex = 13
Top = 720
Width = 615
End
Begin VB.CommandButton cmdModify
Caption = "修改"
Height = 375
Left = 960
TabIndex = 12
Top = 720
Width = 735
End
Begin VB.CommandButton cmdDelete
Caption = "删除"
Height = 375
Left = 960
TabIndex = 11
Top = 240
Width = 735
End
Begin VB.CommandButton cmdSave
Caption = "保存"
Height = 375
Left = 120
TabIndex = 10
Top = 720
Width = 735
End
Begin VB.CommandButton cmdADD
Caption = "添加"
Height = 375
Left = 120
TabIndex = 9
Top = 240
Width = 735
End
End
Begin VB.Frame fraADD
Height = 2055
Left = 480
TabIndex = 1
Top = 600
Width = 3855
Begin VB.TextBox txtSName
Appearance = 0 'Flat
Height = 375
Left = 1800
TabIndex = 4
Text = "Text2"
Top = 840
Width = 1575
End
Begin VB.TextBox txtSID
Appearance = 0 'Flat
Height = 375
Left = 1800
TabIndex = 3
Text = "Text1"
Top = 240
Width = 1575
End
Begin VB.TextBox txtSPSW
Appearance = 0 'Flat
Height = 375
Left = 1800
TabIndex = 2
Text = "Text1"
Top = 1440
Width = 1575
End
Begin VB.Label Label3
Caption = "借阅密码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 7
Top = 1440
Width = 1455
End
Begin VB.Label Label2
Caption = "学生姓名:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 6
Top = 840
Width = 1455
End
Begin VB.Label Label1
Caption = "学生学号:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 5
Top = 240
Width = 1455
End
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "学 生 管 理"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 0
Top = 120
Width = 2775
End
End
Attribute VB_Name = "frmStudentADD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bModify As Boolean
Private Sub cmdAdd_Click()
txtSName.Enabled = True
txtSID.Enabled = True
txtSPSW.Enabled = True
txtSID.SetFocus
txtSName.Text = ""
txtSID.Text = ""
txtSPSW.Text = ""
bModify = False
cmdADD.Enabled = False
cmdSave.Enabled = True
End Sub
Private Sub cmdDelete_Click()
Dim strsql As String
bModify = False
If txtSID.Text <> "" Then
If MsgBox("您真的想删除吗?删除将无法恢复!", vbYesNo, "提示") = vbYes Then
strsql = "delete from tblstudents where sid='" & Trim(txtSID.Text) & "'"
conLIB.Execute strsql
cmdAdd_Click
End If
End If
End Sub
Private Sub cmdModify_Click()
Dim strsql As String
If txtSID.Text <> "" Then
txtSName.Enabled = True
txtSPSW.Enabled = False
cmdSave.Enabled = True
bModify = True
End If
End Sub
Private Sub cmdReturn_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
If bModify = False Then
If txtSID.Text = "" Then
MsgBox "学号不能为空", vbOKOnly, "提示"
txtSID.SetFocus
Else
If txtSName = "" Then
MsgBox "姓名不能为空", vbOKOnly, "提示"
txtSName.SetFocus
Else
If txtSPSW.Text = "" Then
MsgBox "密码不能为空", vbOKOnly, "提示"
txtSPSW.SetFocus
Else
strsql = "insert into tblstudents values('" & txtSID.Text & "','" & txtSName.Text & "','" & txtSPSW.Text & "')"
conLIB.Execute strsql
cmdAdd_Click
End If
End If
End If
Else
If txtSName.Text = "" Then
MsgBox "姓名不能为空", vbOKOnly, "提示"
txtSName.SetFocus
Else
strsql = "update tblstudents set sname='" & txtSName.Text & "' where sid='" & txtSID.Text & "'"
conLIB.Execute strsql
cmdADD.Enabled = True
cmdDelete.Enabled = True
cmdReturn.Enabled = True
cmdSave.Enabled = False
cmdModify.Enabled = False
End If
End If
End Sub
Private Sub Form_Load()
txtSName.Text = ""
txtSID.Text = ""
txtSPSW.PasswordChar = "*"
txtSPSW.Text = ""
bModify = False
cmdSave.Enabled = False
End Sub
Private Sub txtSID_LostFocus()
'此学号学生是否存在
Dim strsql As String
Dim rsStudents As New ADODB.Recordset
strsql = "select * from tblstudents where sid='" & Trim(txtSID.Text) & "'"
rsStudents.Open strsql, conLIB, adOpenDynamic, adLockOptimistic
If rsStudents.EOF And rsStudents.BOF Then
cmdSave.Enabled = True
txtSName.SetFocus
Else
txtSID.Enabled = False
txtSName.Text = rsStudents!sname
txtSPSW.Text = rsStudents!spsw
txtSName.Enabled = False
txtSPSW.Enabled = False
cmdADD.Enabled = True
cmdDelete.Enabled = True
cmdModify.Enabled = True
cmdReturn.Enabled = True
cmdSave.Enabled = False
End If
rsStudents.Close
Set rsStudents = Nothing
End Sub
Private Sub txtSPSW_GotFocus()
' If bModify = True Then
' bModify = False
' frmPSW.Show vbNormal, Me
'
' End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -