📄 frmeditstudent.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FrmEditStudent
Caption = "学生资料"
ClientHeight = 7800
ClientLeft = 60
ClientTop = 390
ClientWidth = 7455
LinkTopic = "Form1"
ScaleHeight = 7800
ScaleWidth = 7455
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 5160
TabIndex = 3
Top = 7200
Width = 975
End
Begin VB.CommandButton cmdOk
Caption = "确定修改"
Height = 375
Left = 3480
TabIndex = 2
Top = 7200
Width = 1095
End
Begin VB.CommandButton CmdDel
Caption = "删除"
Height = 375
Left = 1920
TabIndex = 1
Top = 7200
Width = 975
End
Begin VB.Frame Frame1
Caption = "修改个人信息"
Height = 6735
Left = 120
TabIndex = 0
Top = 120
Width = 7095
Begin MSComCtl2.DTPicker DtpBirthday
Bindings = "FrmEditStudent.frx":0000
DataField = "出生日期"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 4800
TabIndex = 28
Top = 2160
Width = 1695
_ExtentX = 2990
_ExtentY = 503
_Version = 393216
Format = 19726337
CurrentDate = 39658
End
Begin VB.ComboBox cmbSex
DataField = "性别"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 300
ItemData = "FrmEditStudent.frx":0020
Left = 1200
List = "FrmEditStudent.frx":002A
TabIndex = 27
Text = "男"
Top = 1560
Width = 855
End
Begin VB.Frame Frame2
Caption = "备注"
Height = 2175
Left = 480
TabIndex = 25
Top = 4320
Width = 6255
Begin VB.TextBox txtMemo
DataField = "备注"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 1575
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 26
Top = 360
Width = 5775
End
End
Begin VB.TextBox txtEmail
DataField = "电子邮件"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 23
Top = 3780
Width = 5295
End
Begin VB.TextBox txtZipCode
DataField = "邮编"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 4755
TabIndex = 21
Top = 2685
Width = 1680
End
Begin VB.TextBox txtAddress
DataField = "家庭住址"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 19
Top = 3270
Width = 5295
End
Begin VB.TextBox txtPhone
DataField = "电话"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 17
Top = 2640
Width = 1740
End
Begin VB.TextBox txtNative
DataField = "籍贯"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 15
Top = 2145
Width = 1695
End
Begin VB.TextBox txtClass
DataField = "班级"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 4755
TabIndex = 12
Top = 1140
Width = 1650
End
Begin VB.TextBox txtDepartment
DataField = "所属院系"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 10
Top = 1125
Width = 1650
End
Begin VB.TextBox txtName
DataField = "姓名"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 7
Top = 720
Width = 1650
End
Begin VB.TextBox txtID
DataField = "学号"
DataMember = "dbo_stu_GetAllStudent"
DataSource = "DataEnvironment1"
Height = 285
Left = 1155
TabIndex = 5
Top = 345
Width = 1650
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Height = 180
Index = 11
Left = 1035
TabIndex = 24
Top = 4575
Width = 90
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "E-MAIL:"
Height = 180
Index = 10
Left = 465
TabIndex = 22
Top = 3825
Width = 630
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "邮编:"
Height = 255
Index = 9
Left = 3990
TabIndex = 20
Top = 2730
Width = 735
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "住址:"
Height = 180
Index = 8
Left = 675
TabIndex = 18
Top = 3315
Width = 450
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "电话:"
Height = 255
Index = 7
Left = 240
TabIndex = 16
Top = 2685
Width = 855
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "籍贯:"
Height = 255
Index = 6
Left = 390
TabIndex = 14
Top = 2190
Width = 735
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "生日:"
Height = 180
Index = 5
Left = 4275
TabIndex = 13
Top = 2175
Width = 450
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "班级:"
Height = 255
Index = 4
Left = 3990
TabIndex = 11
Top = 1185
Width = 735
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "系别:"
Height = 180
Index = 3
Left = 675
TabIndex = 9
Top = 1170
Width = 450
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "性别:"
Height = 255
Index = 2
Left = 390
TabIndex = 8
Top = 1635
Width = 735
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "姓名:"
Height = 255
Index = 1
Left = 270
TabIndex = 6
Top = 765
Width = 855
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "学号:"
Height = 255
Index = 0
Left = 150
TabIndex = 4
Top = 390
Width = 975
End
End
End
Attribute VB_Name = "FrmEditStudent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public iCurrentPos As Integer ' 记录的当前位置
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub CmdDel_Click() '删除命令
DelRecord
FrmEditStudent.Refresh
End Sub
Private Sub cmdok_Click()
UpdateAllStudent
End Sub
' 窗体加载时初始化连接设置
Private Sub Form_Load()
cnn.Open strCnn
End Sub
' 退出当前窗体时,关闭及释放连接
Private Sub Form_Unload(Cancel As Integer)
If cnn.State = adStateOpen Then
cnn.Close
Set cnn = Nothing
End If
FrmMain.Visible = True
End Sub
Private Sub UpdateAllStudent()
On Error GoTo ErrHandle
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc ' 将命令类型设置为存储过程
cmd.CommandText = "stu_UpdateAllStudent" ' 要执行的存储过程
' 以下添加存储过程stu_UpdateAllStudent所需的参数
cmd.Parameters.Append cmd.CreateParameter("@stuNo", adChar, adParamInput, 6)
cmd.Parameters.Append cmd.CreateParameter("@name", adVarChar, adParamInput, 20)
cmd.Parameters.Append cmd.CreateParameter("@sex", adChar, adParamInput, 2)
cmd.Parameters.Append cmd.CreateParameter("@departName", adVarChar, adParamInput, 50)
cmd.Parameters.Append cmd.CreateParameter("@className", adVarChar, adParamInput, 50)
cmd.Parameters.Append cmd.CreateParameter("@birthday", adDBDate)
cmd.Parameters.Append cmd.CreateParameter("@native", adVarChar, adParamInput, 50)
cmd.Parameters.Append cmd.CreateParameter("@phone", adChar, adParamInput, 20)
cmd.Parameters.Append cmd.CreateParameter("@address", adVarChar, adParamInput, 100)
cmd.Parameters.Append cmd.CreateParameter("@zipCode", adChar, adParamInput, 8)
cmd.Parameters.Append cmd.CreateParameter("@email", adVarChar, adParamInput, 50)
cmd.Parameters.Append cmd.CreateParameter("@memo", adVarChar, adParamInput, 1000)
' 输入值
cmd.Parameters("@stuNo").Value = txtID.Text
cmd.Parameters("@name").Value = txtName.Text
cmd.Parameters("@sex").Value = cmbSex.Text
cmd.Parameters("@departName").Value = txtDepartment.Text
cmd.Parameters("@className").Value = txtClass.Text
cmd.Parameters("@birthday").Value = DtpBirthday.Value
cmd.Parameters("@native").Value = txtNative.Text
cmd.Parameters("@phone").Value = txtPhone.Text
cmd.Parameters("@address").Value = txtAddress.Text
cmd.Parameters("@zipCode").Value = txtZipCode.Text
cmd.Parameters("@email").Value = txtEmail.Text
cmd.Parameters("@memo").Value = txtMemo.Text
cmd.Execute ' 执行存储过程
MsgBox "更新成功"
Exit Sub
ErrHandle:
MsgBox "更新出错" + Err.Description ' 出错处理
End Sub
Private Sub DelRecord() '删除子函数
On Error GoTo ErrHandle
Dim cmd As New Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "stu_DelStudent"
cmd.Parameters.Append cmd.CreateParameter("@stuNo", adChar, adParamInput, 6)
cmd.Parameters("@stuNo").Value = txtID.Text
' 注意,是级联删除
If MsgBox("即将删除此记录及其级联的所有记录!此操作将不可复原!", vbOKCancel, "删除确认") = VbMsgBoxResult.vbOK Then
cmd.Execute
MsgBox "成功删除!"
End If
Exit Sub
ErrHandle:
MsgBox "删除出错!" + Err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -