📄 frmadd_student.frm
字号:
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000C000&
Height = 255
Left = 3000
TabIndex = 14
Top = 2280
Width = 975
End
End
Begin VB.CommandButton cmdExit
BackColor = &H00FFC0C0&
Caption = "退出"
BeginProperty Font
Name = "华文行楷"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4920
Style = 1 'Graphical
TabIndex = 4
Top = 3720
Width = 1095
End
Begin VB.CommandButton cmdAdd
BackColor = &H00FFC0C0&
Caption = "添加"
BeginProperty Font
Name = "华文行楷"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
MaskColor = &H0000C000&
Style = 1 'Graphical
TabIndex = 3
Top = 3720
Width = 975
End
Begin VB.CommandButton cmdMod
BackColor = &H00FFC0C0&
Caption = "修改"
BeginProperty Font
Name = "华文行楷"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2760
Style = 1 'Graphical
TabIndex = 2
Top = 3720
Width = 975
End
Begin VB.CommandButton cmdDel
BackColor = &H00FFC0C0&
Caption = "删除"
BeginProperty Font
Name = "华文行楷"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3840
Style = 1 'Graphical
TabIndex = 1
Top = 3720
Width = 975
End
Begin VB.CommandButton cmdQuery
BackColor = &H00FFC0C0&
Caption = "查询"
BeginProperty Font
Name = "华文行楷"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 600
Style = 1 'Graphical
TabIndex = 0
Top = 3720
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFC0C0&
Caption = "学生基本信息"
BeginProperty Font
Name = "华文行楷"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF00FF&
Height = 375
Left = 2400
TabIndex = 22
Top = 0
Width = 2295
End
End
Attribute VB_Name = "FrmStudent_Manage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sql As String
Dim rs As ADODB.Recordset
Private Sub cmdOK_Click()
End Sub
Private Sub cmdAdd_Click()
Set rs = New ADODB.Recordset
If Text1.Text = "" Then
MsgBox "请你输入要想添加的学生的学号以及相关的所有信息!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus
Exit Sub
Else
sql = "select * from Student where Sno='" & Trim(Text1.Text)
sql = sql & "' and Sname='" & Trim(Text2.Text) & "' and Ssex='"
sql = sql & Trim(Text3.Text) & "' and Sage='" & Trim(Text4.Text)
sql = sql & "' and Splace='" & Trim(Text5.Text) & "' and Spolity='"
sql = sql & Trim(Text6.Text) & "' and Stime='" & Trim(Text7.Text)
sql = sql & "' and Steleph='" & Trim(Text8.Text) & "'"
Set rs = TransactSQL(sql)
If rs.EOF = False Then
MsgBox "该学生的记录已经存在,请核实后再添加!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus
rs.Close
Else
sql = "select * from Student"
Set rs = TransactSQL(sql)
rs.AddNew
rs.Fields(0) = Trim(Text1.Text)
rs.Fields(1) = Trim(Text2.Text)
rs.Fields(2) = Trim(Text3.Text)
rs.Fields(3) = Trim(Text4.Text)
rs.Fields(4) = Trim(Text5.Text)
rs.Fields(5) = Trim(Text6.Text)
rs.Fields(6) = Trim(Text7.Text)
rs.Fields(7) = Trim(Text8.Text)
rs.Update
rs.Close
MsgBox "该记录已经成功添加!", vbOKOnly + vbExclamation, "添加结束!"
Call init
End If
End If
End Sub
Private Sub init()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub
Private Sub cmdDel_Click()
Set rs = New ADODB.Recordset
If Text1.Text = "" Then
MsgBox "请你输入要删除的学生的学号!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus
Exit Sub
End If
sql = "select * from Student where Sno='" & Trim(Text1.Text) & "'"
Set rs = TransactSQL(sql)
If rs.EOF Then
MsgBox "不存在该学生,请确认之后再删除!", vbOKOnly + vbExclamation, "警告!"
Call init
Text1.SetFocus
rs.Close
Exit Sub
End If
sql = "delete from Student where Sno='" & Trim(Text1.Text) & " '"
If MsgBox("确定要删除学号为" & Text1.Text & "的所有信息吗?", vbOKCancel + vbExclamation, "提示!") = vbOK Then
TransactSQL (sql)
MsgBox "该学生的所有信息已经删除!", vbOKOnly + vbExclamation, "警告!"
End If
Call init
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdMod_Click()
Set rs = New ADODB.Recordset
If Text1.Text = "" Then
MsgBox "请你输入要想修改的学生的学号以及相关的所有信息!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus
Exit Sub
End If
sql = "select * from Student where Sno='" & Trim(Text1.Text) & "'"
Set rs = TransactSQL(sql)
If rs.EOF Then
MsgBox "无法找到该学生的基本信息,请核实后再修改!", vbOKOnly + vbExclamation, "警告!"
Call init
Text1.SetFocus
rs.Close
Exit Sub
End If
If MsgBox("确定要修改学号为" & Text1.Text & "的基本信息吗?", vbOKCancel) = vbOK Then
sql = "update Student set Sname='" & Trim(Text2.Text)
sql = sql & " ',Ssex= '" & Trim(Text3.Text) & "',Sage=" & Text4.Text
sql = sql & ",Splace='" & Trim(Text5.Text) & " ',Spolity='" & Trim(Text6.Text) & "',Stime='" & Trim(Text7.Text)
sql = sql & " ',Steleph='" & Trim(Text8.Text) & " ' where Sno='" & Trim(Text1.Text) & " ';"
TransactSQL (sql)
MsgBox "该学生的基本信息已经修改!", vbOKOnly + vbExclamation, "修改结束!"
End If
Call init
End Sub
Private Sub cmdQuery_Click()
FrmQury.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -