📄 teacher_entry.frm
字号:
Name = "Palatino Linotype"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 5280
TabIndex = 15
Top = 4200
Width = 1215
End
Begin VB.Label pwd_label
BackStyle = 0 'Transparent
Caption = "Password:=>"
BeginProperty Font
Name = "Palatino Linotype"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
TabIndex = 10
Top = 3480
Width = 1455
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Teacher Name :"
BeginProperty Font
Name = "Palatino Linotype"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 5280
TabIndex = 2
Top = 4920
Width = 2295
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Teacher ID :"
BeginProperty Font
Name = "Palatino Linotype"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 5280
TabIndex = 0
Top = 2760
Width = 1785
End
End
Attribute VB_Name = "teacher_entry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset
Dim db As New ADODB.Connection
Dim SQL1 As String
Option Explicit
Dim division As Integer
Dim flag1, flag2 As Boolean
Dim flag, addflag As Boolean
Dim records, msgflag As Integer
Private Sub cmd_add_Click()
On Error GoTo msg
addflag = True
If flag = True Then
t_id.Locked = False
cmd_update.Enabled = False
cmd_del.Enabled = False
CMD_NXT.Enabled = False
cmd_prev.Enabled = False
t_id.Text = ""
t_pwd.Text = ""
t_name.Text = ""
flag = False
cmdcancel.Enabled = True
cmdcancel.Visible = True
Else
If (Not t_id.Text = "" And Not t_name.Text = "" And Not t_pwd.Text = "") Then
t_name.Text = UCase(t_name.Text)
Set rs = Nothing
rs.Open "SELECT * FROM ARS_TEACHENTRY", db, adOpenKeyset, adLockPessimistic
While Not rs.EOF
If t_id.Text = rs.Fields(0) Then
MsgBox "Teacher ID Must Be Unique", vbCritical, "Error Message"
t_id.Text = ""
GoTo msg
End If
rs.MoveNext
Wend
rs.AddNew
rs(0) = CInt(t_id.Text)
rs(1) = Trim((t_pwd.Text))
rs(2) = cmb_branch.Text
rs(3) = Trim(t_name)
rs.Update
rs.Fields.Refresh
MsgBox "Current Record Added Successfully!", vbOKOnly, "Record Added"
t_id.Locked = True
cmd_update.Enabled = True
cmd_del.Enabled = True
CMD_NXT.Enabled = True
cmd_prev.Enabled = True
cmdcancel.Visible = False
flag = True
addflag = False
Else
MsgBox "Please Fill All Record!", vbOKOnly, "Error Message"
End If
End If
msg:
End Sub
Private Sub cmd_del_Click()
On Error GoTo msg
If (Not t_id.Text = "" And Not t_pwd.Text = "" And Not t_name.Text = "") Then
msgflag = MsgBox("Are You sure To Delete Record!", vbYesNo, "Confirm Record Delete")
If msgflag = 6 Then
rs.Delete
rs.Fields.Refresh
t_name.Text = ""
t_id.Text = ""
t_pwd.Text = ""
End If
Else
MsgBox "No Record To Delete", vbCritical, "Error Message"
End If
msg:
End Sub
Private Sub cmd_exit_Click()
db.Close
Set rs = Nothing
Set db = Nothing
ARS_MDI.Enabled = True
Unload Me
End Sub
Private Sub cmd_nxt_Click()
If (Not t_id.Text = "" And Not t_pwd.Text = "" And Not t_name.Text = "") Then
'If flag1 = False Then
rs.MoveNext
If Not (rs.EOF) Then
t_id.Text = rs.Fields(0)
t_pwd.Text = rs.Fields(1)
t_name.Text = rs.Fields(3)
'flag2 = False
Else
rs.MoveLast
t_id.Text = rs.Fields(0)
t_pwd.Text = rs.Fields(1)
t_name.Text = rs.Fields(3)
'flag1 = True
MsgBox "At Last Record!", vbOKOnly
'flag2 = False
End If
Else
MsgBox "Please Fill All Record Or Select Record!", vbOKOnly, "Error Message"
End If
End Sub
Private Sub cmd_prev_Click()
On Error GoTo msg
If (Not t_name.Text = "" And Not t_id.Text = "" And Not t_pwd.Text = "") Then
rs.MovePrevious
'If flag2 = False Then
If Not (rs.BOF = True) Then
t_id.Text = rs.Fields(0)
t_pwd.Text = rs.Fields(1)
t_name.Text = rs.Fields(3)
'flag1 = False
Else
'flag2 = True
rs.MoveFirst
MsgBox "At First Record!", vbOKOnly
'flag1 = False
End If
Else
MsgBox "Please Fill All Record Or Select Record!", vbOKOnly, "Error Message"
End If
msg:
' MsgBox err.Description
End Sub
Private Sub cmd_update_Click()
On Error GoTo msg
If (t_id.Text <> "" And t_pwd.Text <> "" And cmb_branch.Text <> "" And t_name.Text <> "") Then
t_name.Text = UCase(t_name.Text)
rs.Update 0, CInt(t_id.Text)
rs.Update 1, Trim(t_pwd.Text)
rs.Update 2, cmb_branch.Text
rs.Update 3, Trim(t_name.Text)
rs.Fields.Refresh
MsgBox "Current Record Updated Successfully!", vbOKOnly, "Record Updated"
Else
MsgBox "Please Fill All Record Or Select Record!", vbOKOnly, "Error Message"
End If
msg:
End Sub
Private Sub CMDCANCEL_Click()
t_id.Locked = True
cmd_update.Enabled = True
cmd_del.Enabled = True
CMD_NXT.Enabled = True
cmd_prev.Enabled = True
cmdcancel.Enabled = False
cmdcancel.Visible = False
addflag = False
flag = True
t_id.Text = ""
t_name.Text = ""
t_pwd.Text = ""
'If (Not t_name.Text = "" And Not t_id.Text = "" And Not t_pwd.Text = "") Then
db.Close
Form_Load
'End If
End Sub
Private Sub Form_Load()
addflag = False
flag1 = False
flag2 = False
flag = True
''cmd_nxt.Enabled = False
'cmd_prev.Enabled = False
'cmd_del.Enabled = False
cmdcancel.Visible = False
'cmd_update.Enabled = False
On Error GoTo err
GoTo ok
err:
MsgBox "Exception:Connection To Database Failed!!", vbOKOnly, "Error Message!"
ok:
db.Open "Provider=OraOLEDB.Oracle.1;Password=TIGER;Persist Security Info=True;User ID=SCOTT"
rs.Open "SELECT * FROM ARS_TEACHENTRY", db, adOpenKeyset, adLockPessimistic
t_id.Text = rs.Fields(0)
t_pwd.Text = rs.Fields(1)
t_name.Text = rs.Fields(3)
End Sub
Private Sub t_id_KeyPress(KeyAscii As Integer)
If (KeyAscii <> 8) Then
If Not (KeyAscii >= 48 And KeyAscii <= 57) Then
KeyAscii = 0
MsgBox "Only Numeric Data!", vbOKOnly, "Error Message"
End If
End If
End Sub
Private Sub t_name_KeyPress(KeyAscii As Integer)
If t_id.Text = "" Or cmb_branch.Text = "" Or t_pwd.Text = "" Then
KeyAscii = 0
MsgBox "Please Fill Above Field!", vbInformation, "Message"
End If
End Sub
Private Sub t_pwd_KeyPress(KeyAscii As Integer)
If t_id.Text = "" And t_name.Text = "" Or cmb_branch.Text = "" Then
KeyAscii = 0
MsgBox "Please Fill Above Field!", vbInformation, "Message"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -