📄 frmmodiess.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmmodiess
Caption = "修改学籍信息"
ClientHeight = 5265
ClientLeft = 60
ClientTop = 345
ClientWidth = 7230
LinkTopic = "Form1"
ScaleHeight = 5265
ScaleWidth = 7230
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc adograde
Height = 375
Left = 2400
Top = 4680
Visible = 0 'False
Width = 2775
_ExtentX = 4895
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc adoedit
Align = 2 'Align Bottom
Height = 375
Left = 0
Top = 4890
Width = 7230
_ExtentX = 12753
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 学籍"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 495
Left = 5520
TabIndex = 6
Top = 4080
Width = 1575
End
Begin VB.CommandButton cmddelect
Caption = "删除记录"
Height = 495
Left = 4080
TabIndex = 5
Top = 4080
Width = 1455
End
Begin VB.CommandButton cmdcancel
Caption = "取消修改"
Height = 495
Left = 2640
TabIndex = 4
Top = 4080
Width = 1455
End
Begin VB.CommandButton cmdupdate
Caption = "更新数据"
Height = 495
Left = 1320
TabIndex = 3
Top = 4080
Width = 1335
End
Begin VB.CommandButton cmdedit
Caption = "修改记录"
Height = 495
Left = 0
TabIndex = 2
Top = 4080
Width = 1335
End
Begin VB.Frame Frame2
Caption = "选择班级"
Height = 3135
Left = 4200
TabIndex = 1
Top = 360
Width = 2895
Begin VB.ComboBox cboselclass
DataField = "班级"
DataSource = "adoedit"
Height = 2700
ItemData = "frmmodiess.frx":0000
Left = 120
List = "frmmodiess.frx":0002
Style = 1 'Simple Combo
TabIndex = 17
Top = 240
Width = 2655
End
End
Begin VB.Frame Frame1
Caption = "修改记录"
Height = 3135
Left = 120
TabIndex = 0
Top = 360
Width = 3855
Begin VB.ComboBox cboclass
DataField = "班级"
DataSource = "adoedit"
Height = 300
Left = 1320
TabIndex = 16
Top = 2640
Width = 1815
End
Begin VB.ComboBox cbosex
DataField = "性别"
DataSource = "adoedit"
Height = 300
ItemData = "frmmodiess.frx":0004
Left = 1320
List = "frmmodiess.frx":000E
TabIndex = 15
Top = 1560
Width = 1815
End
Begin VB.TextBox txtborn
DataField = "出生日期"
DataSource = "adoedit"
Height = 375
Left = 1320
TabIndex = 14
Top = 2040
Width = 1815
End
Begin VB.TextBox txtname
DataField = "姓名"
DataSource = "adoedit"
Height = 375
Left = 1320
TabIndex = 13
Top = 840
Width = 1815
End
Begin VB.TextBox txtsid
DataField = "学号"
DataSource = "adoedit"
Height = 375
Left = 1320
TabIndex = 12
Top = 360
Width = 1815
End
Begin VB.Label Label5
Caption = "班 级"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 11
Top = 2640
Width = 1095
End
Begin VB.Label Label4
Caption = "出生日期"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 10
Top = 2160
Width = 1215
End
Begin VB.Label Label3
Caption = "性 别"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 9
Top = 1560
Width = 1215
End
Begin VB.Label Label2
Caption = "姓 名"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 8
Top = 960
Width = 1215
End
Begin VB.Label Label1
Caption = "学 号"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 7
Top = 480
Width = 1095
End
End
End
Attribute VB_Name = "frmmodiess"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim sno As String
Private Sub mylock(ByVal block As Boolean)
txtsid.Locked = block 'true
txtname.Locked = block 'true
txtborn.Locked = block 'true
cbosex.Locked = block 'true
cboclass.Locked = block 'true
cboselclass.Locked = Not block 'true
cmdedit.Enabled = block 'true
cmdcancel.Enabled = Not block 'true
cmdupdate.Enabled = Not block 'true
cmddelect.Enabled = block 'true
adoedit.Enabled = block 'true
End Sub
Private Sub adoedit_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'移动记录指针时显示当前记录位置/总记录数
adoedit.Caption = "record:" & CStr(adoedit.Recordset.AbsolutePosition) & "/" & adoedit.Recordset.RecordCount
End Sub
Private Sub cboclass_Click()
If cboclass.Locked = True Then Exit Sub
Call newclassitem(cboclass)
End Sub
Private Sub cboselclass_Click()
Dim sqln As String
Dim strclass As String
strclass = cboselclass.Text
If strclass = "全部" Then strclass = "%"
sqln = "select * from 学籍 where 班级 like '" & strclass & "'order by 学号"
adoedit.RecordSource = sqln
adoedit.Refresh
End Sub
Private Sub cmdcancel_Click()
With adoedit.Recordset
.CancelUpdate '取消更新
.MoveNext
.MovePrevious
End With
Call mylock(True)
End Sub
Private Sub cmddelect_Click()
Dim response As Integer
response = MsgBox("删除当前记录吗?", vbQuestion + vbYesNo, "询问")
If response = vbYes Then
With adoedit.Recordset
.Delete
.MoveNext
If .EOF And .RecordCount > 0 Then .MoveLast
End With
'删除成绩表中的相应记录
Dim sqlg As String
sqlg = "select * from 成绩 where 学号='" & Trim$(txtsid.Text) & "'"
adograde.RecordSource = sqlg
adograde.Refresh
With adograde.Recordset
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Delete
.MoveNext
Loop
End If
End With
MsgBox "删除成功。", vbInformation, "提示"
End If
End Sub
Private Sub cmdedit_Click()
sno = Trim$(txtsid.Text)
Call mylock(False) '用于输入信息的控件解锁
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdupdate_Click()
On Error Resume Next
'各输入框若为空白,提示重新输入
If Trim(txtsid.Text) = "" Then
MsgBox "请输入学号!", vbExclamation
txtsid.SetFocus
Exit Sub
End If
If Trim(txtname.Text) = "" Then
MsgBox "请输入姓名!", vbExclamation
txtname.SetFocus
Exit Sub
End If
If Trim(txtborn.Text) = "" Then
MsgBox "请输入出生日期!", vbExclamation
txtborn.SetFocus
Exit Sub
End If
If Trim(cboclass.Text) = "" Then
MsgBox "请选择或输入班级!", vbExclamation
cboclass.SetFocus
Exit Sub
End If
If Not IsDate(txtborn.Text) Then '出生日期若非日期型,重新输入
MsgBox "出生日期应按日期格式(yyyy-mm-dd)输入!", vbExclamation
With txtborn
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Else '若日期格式正确
txtborn.Text = Format(txtborn.Text, "yyyy-mm-dd")
adoedit.Recordset.Update
If Err = -2147467259 Then
adoedit.Recordset.CancelUpdate
MsgBox "学号重复,请重新输入!", vbExclamation
Call focusback(txtsid)
Exit Sub
End If
If Trim$(txtsid.Text) <> sno Then
Dim sqlg As String
sqlg = "select * from 成绩 where 学号='" & sno & "'"
adograde.RecordSource = sqlg
adograde.Refresh
With adograde.Recordset
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Fields("学号") = Trim$(txtsid.Text)
.MoveNext
Loop
End If
End With
End If
MsgBox "学籍信息已成功修改!", vbInformation
Call mylock(True) '锁定
End If
End Sub
Private Sub Form_Initialize()
ChDrive App.Path
ChDir App.Path
End Sub
Private Sub Form_Load()
adoedit.RecordSource = "select * from 学籍"
Call mylock(True)
Call addclassitem(cboclass)
Call addclassitem(cboselclass)
cboselclass.AddItem "全部"
cboselclass.ListIndex = cboselclass.NewIndex
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Show
End Sub
Private Sub Label3_Click()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -