📄 frmxsxxgl.frm
字号:
DataNull
Display
'lstSt
End Sub
Private Sub CmdSave_Click()
On Error GoTo err
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
If ctl.Text = "" Then
MsgBox "记录输入不完整!"
Exit Sub
End If
End If
Next ctl
If Len(Trim(Text1.Text)) <> 7 Then
MsgBox "初考证号输入不正确!"
Exit Sub
End If
If Len(Trim(Text2.Text)) <> 8 Then
MsgBox "考试号输入不正确!"
Exit Sub
End If
If ComBj.ListIndex = -1 Then
MsgBox "班级输入不正确!"
Exit Sub
End If
If Combo1.ListIndex = -1 And (Combo1.Text <> "男" And Combo1.Text <> "女") Then
MsgBox "性别输入不完整!"
Exit Sub
End If
If Combo2.ListIndex = -1 And (Combo2.Text <> "否" And Combo2.Text <> "是") Then
MsgBox "计外情况输入不完整!"
Exit Sub
End If
If AddFlg = True Then
rs!初考证号 = Trim(Text1.Text)
rs!考试号 = Trim(Text2.Text)
rs!班级 = Trim(ComBj.Text)
rs!学号 = Trim(Text4.Text)
rs!姓名 = Trim(Text5.Text)
rs!家长姓名 = Trim(Text6.Text)
rs!联系电话 = Trim(Text7.Text)
rs!家庭住址 = Trim(Text8.Text)
rs!出生年月 = Trim(MaskEdBox1.Text)
rs!性别 = Trim(Combo1.Text)
rs!计外 = Trim(Combo2.Text)
If Image1.Picture <> 0 Then
rs!照片 = arr
End If
rs.Update
'Rs.MoveNext
'If Rs.EOF Then Rs.MoveLast
Display
MsgBox "记录成功添加!"
Else
rs!初考证号 = Trim(Text1.Text)
rs!考试号 = Trim(Text2.Text)
rs!班级 = Trim(ComBj.Text)
rs!学号 = Trim(Text4.Text)
rs!姓名 = Trim(Text5.Text)
rs!家长姓名 = Trim(Text6.Text)
rs!联系电话 = Trim(Text7.Text)
rs!家庭住址 = Trim(Text8.Text)
rs!出生年月 = Trim(MaskEdBox1.Text)
rs!性别 = Trim(Combo1.Text)
rs!计外 = Trim(Combo2.Text)
If Image1.Picture <> 0 Then
rs!照片 = arr
End If
rs.UpdateBatch adAffectAllChapters
' Rs.MoveNext
' If Rs.EOF Then Rs.MoveLast
Display
MsgBox "记录成功修改!"
End If
List1.Enabled = True
lstSt
Exit Sub
err:
Call ExecErr(Date, Me.Caption, err.Number, err.Source, err.Description)
End Sub
Private Sub cmdCancel_Click()
On Error GoTo CancleErr
If AddFlg = True Then
rs.CancelUpdate
' Rs.MoveNext
' If Rs.EOF Then Rs.MoveLast
Display
Else
rs.CancelBatch adAffectAllChapters
' Rs.MoveNext
' If Rs.EOF Then Rs.MoveLast
Display
End If
List1.Enabled = True
CancleErr:
DataNull
Display
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Command7_Click()
rs.MoveFirst
List1.ListIndex = 1
Display
End Sub
Private Sub Command8_Click()
With rs
.MovePrevious
If .BOF Then
.MoveFirst
List1.ListIndex = List1.ListIndex
Else
List1.ListIndex = List1.ListIndex - 1
End If
End With
Display
End Sub
Private Sub Command9_Click()
ItemIndex = rs.Index
With rs
.MoveNext
If .EOF Then
.MoveLast
List1.ListIndex = List1.ListIndex
Else
List1.ListIndex = List1.ListIndex + 1
End If
End With
Display
End Sub
Private Sub Form_Load()
On Error GoTo err
Dim Rsb As ADODB.Recordset
Set Rsb = New ADODB.Recordset
Rsb.Open "班级表", Con, adOpenStatic, adLockPessimistic, adCmdTable
ComBj.Clear
Do While Not Rsb.EOF
ComBj.AddItem Rsb!班级
Rsb.MoveNext
Loop
Set rs = New ADODB.Recordset
Set RsLst = New ADODB.Recordset
ComBj.Text = "请选择"
rs.Open "select * from 学籍表 order by 班级,学号", Con, adOpenStatic, adLockPessimistic, adCmdText
List1.Clear
List1.AddItem "班级 " & "学号" & "-" & "姓名"
If rs.BOF And rs.EOF Then
Else
rs.MoveFirst
Do While rs.EOF = False
If Len(rs!学号) = 1 Then
List1.AddItem rs!班级 & " 0" & rs!学号 & " - " & rs!姓名
Else
List1.AddItem rs!班级 & " " & rs!学号 & " - " & rs!姓名
End If
rs.MoveNext
Loop
rs.MoveFirst
List1.ListIndex = 1
End If
Display
Cdlg.DialogTitle = "打开照片文件:"
Cdlg.Filter = "GIF Images|*.gif|Bitmap Images|*.bmp|JPG Images|*.jpg|JPEG Images|*.jpeg|ICONS|*.ico|CURSORS|*.cur|所有文件|*.*"
Exit Sub
err:
Call ExecErr(Date, Me.Caption, err.Number, err.Source, err.Description)
End Sub
Private Sub Display()
On Error GoTo err
DataNull
Const TempFile As String = "tempfile.tmp"
If rs.BOF = True And rs.EOF = True Then
MsgBox "学籍表中没有任何数据!"
CmdAdd.Enabled = True
CmdMdi.Enabled = False
CmdDel.Enabled = False
CmdSave.Enabled = False
CmdCancel.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11_Click
Else
CmdAdd.Enabled = True
CmdMdi.Enabled = True
CmdDel.Enabled = True
CmdSave.Enabled = False
CmdCancel.Enabled = False
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Text1.Text = "" & rs!初考证号
Text2.Text = "" & rs!考试号
ComBj.Text = "" & rs!班级
Text4.Text = "" & rs!学号
Text5.Text = "" & rs!姓名
Text6.Text = "" & rs!家长姓名
Text7.Text = "" & rs!联系电话
Text8.Text = "" & rs!家庭住址
If rs!出生年月 <> "" Then
MaskEdBox1.Text = "" & rs!出生年月
End If
If rs!照片.ActualSize > 0 Then
arr = rs![照片]
Open TempFile For Binary Access Write As #1
Put #1, , arr
Close #1
Image1.Picture = LoadPicture(TempFile)
Kill (TempFile)
End If
Combo1.Text = "" & rs!性别
Combo2.Text = "" & rs!计外
End If
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
ctl.Enabled = False
End If
Next ctl
MaskEdBox1.Enabled = False
Frame1.Enabled = False
Exit Sub
err:
Call ExecErr(Date, Me.Caption, err.Number, err.Source, err.Description)
End Sub
Private Sub DataNull()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
ctl.Enabled = True
End If
Next ctl
MaskEdBox1.Enabled = True
Frame1.Enabled = True
Text1.Text = ""
Text2.Text = ""
ComBj.Text = "请选择"
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
MaskEdBox1.Text = "1990.01"
Image1.Picture = Nothing
Combo1.Text = Combo1.List(0)
Combo2.Text = Combo2.List(0)
End Sub
Private Sub Image1_Click()
On Error GoTo err
Cdlg.ShowOpen
If Cdlg.FileName = "" Then Exit Sub
Image1.Picture = LoadPicture(Cdlg.FileName)
Open Cdlg.FileName For Binary As 1
ReDim arr(LOF(1))
Do While Not EOF(1)
Get #1, , arr
i = i + 1
Loop
Close #1
Exit Sub
err:
Call ExecErr(Date, Me.Caption, err.Number, err.Source, err.Description)
End Sub
Private Sub List1_Click()
If List1.ListIndex < 1 Then
Else
rs.Move List1.ListIndex - 1, adBookmarkFirst
End If
Display
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
Private Sub lstSt()
On Error GoTo err
RsLst.Open "select * from 学籍表 order by 班级,学号 ", Con, adOpenStatic, adLockPessimistic, adCmdText
List1.Clear
List1.AddItem "班级 " & "学号" & "-" & "姓名"
If RsLst.BOF And RsLst.EOF Then
RsLst.Close
Exit Sub
Else
RsLst.MoveFirst
Do While RsLst.EOF = False
If Len(RsLst!学号) = 1 Then
List1.AddItem RsLst!班级 & " 0" & RsLst!学号 & " - " & RsLst!姓名
Else
List1.AddItem RsLst!班级 & " " & RsLst!学号 & " - " & RsLst!姓名
End If
RsLst.MoveNext
Loop
RsLst.MoveFirst
End If
RsLst.Close
List1.ListIndex = List1.ListIndex
Exit Sub
err:
Call ExecErr(Date, Me.Caption, err.Number, err.Source, err.Description)
End Sub
Private Sub Text9_Change()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -