📄 frmaddxj.frm
字号:
TabIndex = 13
Top = 720
Width = 780
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "考 试 号:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000D&
Height = 240
Index = 1
Left = 375
TabIndex = 12
Top = 650
Width = 1305
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "初考证号:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000D&
Height = 240
Index = 0
Left = 375
TabIndex = 11
Top = 200
Width = 1290
End
End
Attribute VB_Name = "FrmAddXj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim RsLst As ADODB.Recordset
Dim AddFlg As Boolean
Dim arr() As Byte
Dim i As Long
Private Sub Command1_Click()
DataNull
rs.AddNew
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
Command5.Enabled = True
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
List1.Enabled = False
AddFlg = True
End Sub
Private Sub Command10_Click()
rs.MoveLast
Display
End Sub
Private Sub Command2_Click()
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
Command4.Enabled = True
Command5.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
List1.Enabled = False
AddFlg = False
End Sub
Private Sub Command3_Click()
On Error GoTo delErr
If vbYes = MsgBox("确认索要删除此记录么?", vbYesNo, "删除对话框") Then
rs.Delete
rs.MoveNext
If rs.EOF Then rs.MoveLast
Display
End If
delErr:
DataNull
Display
lstSt
End Sub
Private Sub Command4_Click()
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 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(Text3.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(Text3.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
End Sub
Private Sub Command5_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
Display
End Sub
Private Sub Command8_Click()
With rs
.MovePrevious
If .BOF Then .MoveFirst
End With
Display
End Sub
Private Sub Command9_Click()
ItemIndex = rs.Index
With rs
.MoveNext
If .EOF Then .MoveLast
End With
List1.Enabled = False
Display
End Sub
Private Sub Form_Load()
On Error GoTo err
Set rs = New ADODB.Recordset
Set RsLst = New ADODB.Recordset
Text3.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
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 "学籍表中没有任何数据!"
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Else
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command5.Enabled = False
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Text1.Text = "" & rs!初考证号
Text2.Text = "" & rs!考试号
Text3.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 = ""
Text3.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()
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
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 Text3_Change()
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
Else
RsLst.MoveFirst
Do While RsLst.EOF = False
If Len(rs!学号) = 1 Then
List1.AddItem rs!班级 & " 0" & RsLst!学号 & "--" & RsLst!姓名
Else
List1.AddItem rs!班级 & " " & RsLst!学号 & "--" & RsLst!姓名
End If
RsLst.MoveNext
Loop
RsLst.MoveFirst
End If
RsLst.Close
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 + -