📄 frmpeoplesae.frm
字号:
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "*"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 195
Index = 1
Left = 4800
TabIndex = 14
Top = 2040
Width = 105
End
Begin VB.Label Label6
Caption = "图片:"
Height = 255
Left = 240
TabIndex = 13
Top = 3720
Width = 1215
End
Begin VB.Label Label5
Caption = "班级:"
Height = 255
Left = 240
TabIndex = 12
Top = 1920
Width = 1215
End
Begin VB.Label Label4
Caption = "性别:"
Height = 255
Left = 240
TabIndex = 11
Top = 2280
Width = 1215
End
Begin VB.Label Label3
Caption = "姓名:"
Height = 255
Left = 240
TabIndex = 10
Top = 1560
Width = 1215
End
Begin VB.Label Label1
Caption = "学生编号:"
Height = 255
Left = 240
TabIndex = 9
Top = 1200
Width = 1215
End
Begin VB.Line Line2
BorderColor = &H80000014&
X1 = 120
X2 = 5040
Y1 = 975
Y2 = 975
End
Begin VB.Image Image1
Height = 480
Left = 120
Stretch = -1 'True
Top = 240
Width = 480
End
Begin VB.Line Line3
BorderColor = &H80000014&
X1 = 120
X2 = 5040
Y1 = 5955
Y2 = 5955
End
Begin VB.Line Line1
BorderColor = &H80000010&
BorderWidth = 2
X1 = 120
X2 = 5040
Y1 = 975
Y2 = 975
End
Begin VB.Line Line4
BorderColor = &H80000010&
BorderWidth = 2
X1 = 120
X2 = 5040
Y1 = 5955
Y2 = 5955
End
End
Attribute VB_Name = "frmMembersAE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'-------------------------------------------------------------------
'Members Add/Edit Form
'With this form it is possible to add/modify the members table.
'
'AddState is the bool value that decides whether the form will update
'or modify a record. When AddState = True then Add
' When AddState = False then Modify
'-------------------------------------------------------------------
Private RS As ADODB.RecordSet
Public OldID As String, AddState As Boolean
Private Sub Form_Load()
On Error GoTo Err
Set RS = New ADODB.RecordSet
If AddState Then
Image1.Picture = frmMembers.cmdAMod(1).Picture
RS.Open "SELECT * FROM tblMembers", CN, adOpenStatic, adLockOptimistic
Me.Caption = "添加记录"
Else 'NOT AddState...
Image1.Picture = frmMembers.cmdAMod(0).Picture
Me.Caption = "Modify Record"
cmdAddSave.Caption = "保存"
RS.Open "SELECT * FROM tblMembers WHERE [学生编号] = '" & OldID & "'", CN, adOpenStatic, adLockOptimistic
If Len(RS!Picture) > 0 Then
Photo1.LoadPhoto RS!Picture
End If
End If
Exit Sub
Err:
If Err.Number = 94 Or Err.Number = 3265 Then
Resume Next 'If a null value is encountered
Else
Handler Err 'Unexpected error
End If
End Sub
Private Sub cmdAddSave_Click()
'Add or save data in the recordset according to AddState
On Error GoTo hell
If txtC.Text = "" Then txtC.SetFocus: Exit Sub
If txtName.Text = "" Then txtName.SetFocus: Exit Sub
If cmbP.Text = "" Then cmbP.SetFocus: Exit Sub
If cmbSection.Text = "" Then cmbSection.SetFocus: Exit Sub
If txtRoll.Text = "" Then txtRoll.SetFocus: Exit Sub
If IsNumeric(txtRoll.Text) <> True Then MsgBox "Roll Numbers must be numeric and between 1 and 99", vbExclamation, "Type Mismatch": HighLight txtRoll: Exit Sub
txtRoll.Text = Int(txtRoll.Text)
If txtRoll.Text < 1 Or txtRoll.Text > 99 Then MsgBox "Roll numbers must be between 1 and 99", vbExclamation, "Type Mismatch": HighLight txtRoll: Exit Sub
If AddState Then
If RecordExists("tblMembers", "学生编号", txtCode.Text, txtCode) = True Then Exit Sub
Else 'NOT AddState...
If txtCode.Text <> OldID Then
If RecordExists("tblMembers", "学生编号", txtCode.Text, txtCode) = True Then Exit Sub
End If
End If
CN.BeginTrans
With RS
If AddState Then RS.AddNew
.Fields(0) = txtCode.Text
.Fields(1) = txtName.Text
.Fields(2) = IIf(txtM.Text = "", " ", txtM.Text)
.Fields(3) = cmbP.Text
.Fields(4) = txtC.Text
.Fields(5) = cmbSection.Text
.Fields(6) = txtRoll.Text
Photo1.SavePhoto .Fields("Picture")
RS.Update
End With
CN.CommitTrans
If AddState Then
FindRecord RS, RS.Fields(0).Name, True, txtCode.Text, 0
MsgBox "一个记录已经被成功添加", vbInformation
If MsgBox("你确定要添加一个新的记录吗?", vbQuestion + vbYesNo + vbDefaultButton1) = vbYes Then
cmdReset_Click
Else
Unload Me
End If
Else 'NOT AddState...
FindRecord RS, RS.Fields(0).Name, True, txtCode.Text, 0
MsgBox "修改的记录将被成功保存!", vbInformation
Unload Me
End If
Exit Sub
hell:
On Error Resume Next
CN.RollbackTrans
Handler Err
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdPicInsert_Click()
'Open photo from disk
Photo1.OpenPhotoFile
End Sub
Private Sub cmdPicSave_Click()
'Save photo to disk
On Error GoTo hell
cmdlg.ShowSave
If cmdlg.Filename <> "" Then
SavePicture Photo1.Picture, cmdlg.Filename
End If
hell:
End Sub
Private Sub cmdPicShow_Click()
'Open photo from a temp file
On Error Resume Next
Kill "tmp.jpg"
SavePicture Photo1.Picture, "tmp.jpg"
ShellEx "tmp.jpg"
End Sub
Private Sub cmdReset_Click()
txtCode.Text = ""
txtName.Text = ""
txtC.Text = ""
txtM.Text = ""
txtRoll.Text = ""
cmbP.ListIndex = 0
cmbSection.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -