?? frminput.frm
字號:
Adodc2.Recordset.Fields("父母姓名").Value = Text6.Text
Adodc2.Recordset.Fields("地址").Value = Text7.Text
Adodc2.Recordset.Fields("郵政編碼").Value = Text8.Text
Adodc2.Recordset.Fields("電話號碼").Value = Text9.Text
Adodc2.Recordset.Fields("院系").Value = Text10.Text
Adodc2.Recordset.Fields("專業").Value = DataCombo1.Text
Adodc2.Recordset.Fields("附注").Value = Text12.Text
Adodc2.Recordset.Update
'Adodc2.Recordset.Close
MsgBox "修改學籍信息成功!", vbOKOnly + vbExclamation, "修改學籍信息"
' Adodc2.Recordset.Bookmark = mybookmark
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command10.Enabled = True
mcclean = True
End If
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command10_Click()
On Error GoTo AddErr
If MsgBox("你確信嗎?", vbOKCancel, "警告") = vbOK Then
Adodc2.Recordset.Delete
Adodc2.Recordset.MoveNext
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
End If
GradeRefresh
End If
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
On Error GoTo AddErr
Adodc2.Recordset.MoveFirst
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command3_Click()
On Error GoTo AddErr
Adodc2.Recordset.MoveLast
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command4_Click()
On Error GoTo AddErr
If Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveFirst
Adodc2.Recordset.MoveNext
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command5_Click()
On Error GoTo AddErr
If Adodc2.Recordset.BOF Then Adodc2.Recordset.MoveLast
Adodc2.Recordset.MovePrevious
GradeRefresh
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub Command6_Click()
On Error GoTo AditErr
mcclean = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command10.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Combo1.Enabled = True
DataCombo1.Enabled = True
Text10.Enabled = True
Text12.Enabled = True
Exit Sub
'mybookmark = Adodc2.Recordset.Bookmark
AditErr:
MsgBox Err.Description
End Sub
Private Sub Command7_Click()
On Error GoTo errh
If Text1.Text <> "" Then
If Text13.Text <> "" Then
If Combo4.Text <> "" Then
If Combo2.Text <> "" Then
If Combo3.Text <> "" Then
If checkclass = False Then
If match Then
'Set rs = cn.Execute("select 成績 from 學生與課程 where 課程號='" & Trim(Combo1.Text) & "' and 課程名稱='" & Trim(Combo2.Text) & "' and 學號='" & Trim(Text2.Text) & "' ")
'If rs.EOF Then
'rs.Close
'Exit Sub
' End If
'rs.Close
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
rs.Open "select * from 學生與課程 where 課程號='" & Trim(Combo4.Text) & "' and 課程名稱='" & Trim(Combo2.Text) & "' and 學號='" & Trim(Text1.Text) & "' ", cn, , , adCmdText
'rs.Find ("UserName=" & "'" & Text1.Text & "'")
'If rs.Fields("Password").Value = Text2.Text Then
'rs.Fields(0).Value = Text3.Text
'rs.Fields(1).Value = Combo3.Text
'rs.Update
'rs.Update "成績", Text3.Text
rs.Fields("成績").Value = Text13.Text
rs.Fields("備注").Value = Combo3.Text
rs.Update
rs.Close
MsgBox "修改成功!"
Combo4.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Text13.Text = ""
Combo4.SetFocus
Else
MsgBox "成績和備注不匹配,請核對!"
End If
Else
MsgBox "沒有該課程成績,不能修改!"
End If
Else
MsgBox "該項不能為空,請輸入備注!"
End If
Else
MsgBox "該項不能為空,請輸入課程名稱!"
End If
Else
MsgBox "該項不能為空,請輸入課程號!"
End If
Else
MsgBox "該項不能為空,請輸入成績!"
End If
Else
MsgBox "該項不能為空,請輸入學號!"
End If
Exit Sub
errh:
MsgBox Err.Description
'rs.Close
End Sub
Private Sub Command8_Click()
On Error GoTo errh
If MsgBox("你的操作將會刪除當前的紀錄,你確信嗎?", vbOKCancel, "警告") = vbOK Then
If Combo4.Text <> "" Then
If Combo2.Text <> "" Then
Set rs1 = New ADODB.Recordset
rs1.CursorType = adOpenDynamic
rs1.LockType = adLockOptimistic
rs1.Open "SELECT * FROM 學生與課程 WHERE 課程名稱='" & Trim(Combo2.Text) & "'AND 課程號='" & Trim(Combo4.Text) & "' and 學號='" & Trim(Text1.Text) & "'", cn, adOpenDynamic, adLockOptimistic, adCmdText
If rs1.EOF Then
'Adodc2.Recordset.Close
rs1.Close
MsgBox "沒有這條記錄,無法刪除!"
Exit Sub
End If
rs1.Delete
rs1.Update
rs1.Close
MsgBox "刪除成功!"
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End If
End If
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub Command9_Click()
Unload Me
End Sub
Private Sub DataCombo1_Click(Area As Integer)
'datacombo1.
End Sub
Private Sub Form_Load()
MakeCenter FrmInput
If UserType = False Then
Command6.Enabled = False
'Command7.Enabled = False
'Command8.Enabled = False
CmdUpdata.Enabled = False
CmdBolish.Enabled = False
' CmdBolish.Enabled = False
'CmdUpdata.Enabled = False
Command10.Enabled = False
End If
mcclean = True
Set rs = cn.Execute("select distinct 課程名稱,課程號 from 課程")
rs.MoveFirst
Do
Combo4.AddItem rs.Fields(1).Value
Combo2.AddItem rs.Fields(0).Value
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo3.AddItem "優異"
Combo3.AddItem "良好"
Combo3.AddItem "中等"
Combo3.AddItem "及格"
Combo3.AddItem "不及格"
' Adodc1.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
' "DBQ=db5.MDB;" & _
' "DefaultDir=" & CheckPath(App.path) & ";" & _
' "UID=;PWD=;"
' Adodc1.RecordSource = "SELECT * FROM 學生與課程"
'txtSQL = "select * from 學生"
'Set mrc = cn.Execute(txtSQL)
'Data1.RecordSource = "SELECT 課程號,課程名稱,成績,備注 FROM 學生與課程 where 學號=text1.text"
Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=db5.MDB;" & _
"DefaultDir=" & CheckPath(App.path) & ";" & _
"UID=;PWD=;"
Adodc2.RecordSource = "SELECT * FROM 學生"
Text1.DataField = "學號"
Text2.DataField = "名字"
'Combo1.Text = Adodc2.Recordset.Fields("性別").Value
Text3.DataField = "班級"
Text4.DataField = "出生年月"
Text5.DataField = "民族"
Text6.DataField = "父母姓名"
Text7.DataField = "地址"
Text8.DataField = "郵政編碼"
Text9.DataField = "電話號碼"
Text10.DataField = "院系"
' Text11.DataField = "專業"
Text12.DataField = "附注"
' Label3.DataField = "學生ID"
GradeRefresh
End Sub
'Private Sub Form_Unload(Cancel As Integer)
'On Error Resume Next
' Adodc2.Recordset.Close
'End Sub
Private Function check1() As Boolean '檢測添加的課程是否重復
On Error GoTo errh
Set rs = cn.Execute("SELECT 學號 FROM 學生 WHERE 學號='" & Trim(Text1.Text) & "'")
' Adodc2.RecordSource = "select * from 課程 where 課程號='" & Trim(Text1.Text) & "' and 課程名稱='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
check1 = True
Exit Function
End If
check1 = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Sub GradeRefresh()
Adodc1.RecordSource = "Select * from 學生與課程 where 學號 = '" & Trim(Text1.Text) & "'"
Adodc1.Refresh
End Sub
Private Function checkcourse() As Boolean
On Error GoTo errh
Set rs = cn.Execute("select * from 課程 where 課程名稱='" & Trim(Combo2.Text) & "' and 課程號='" & Trim(Combo4.Text) & "'")
'If Adodc2.Recordset.EOF Then
'Adodc2.Recordset.Close
If rs.EOF Then
rs.Close
checkcourse = False
Exit Function
End If
checkcourse = True
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Function checkclass() As Boolean '檢測添加的課程是否重復
On Error GoTo errh
' Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=db5.MDB;" & _
"DefaultDir=" & CheckPath(App.path) & ";" & _
"UID=;PWD=;"
Set rs = cn.Execute("SELECT 課程名稱 FROM 學生與課程 WHERE 課程名稱='" & Trim(Combo2.Text) & "' and 學號='" & Trim(Text1.Text) & "' And 成績 Is Not Null ")
' Adodc2.RecordSource = "select * from 課程 where 課程號='" & Trim(Text1.Text) & "' and 課程名稱='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
checkclass = True
Exit Function
End If
checkclass = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Function match() As Boolean
On Error GoTo error
If Text13.Text < 60 Then
If Combo3.Text = "不及格" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 70 And Text13.Text >= 60 Then
If Combo3.Text = "及格" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 80 And Text13.Text >= 70 Then
If Combo3.Text = "中等" Then
match = True
Else
match = False
End If
End If
If Text13.Text < 90 And Text13.Text >= 80 Then
If Combo3.Text = "良好" Then
match = True
Else
match = False
End If
End If
If Text13.Text <= 100 And Text13.Text >= 90 Then
If Combo3.Text = "優異" Then
match = True
Else
match = False
End If
End If
Exit Function
error:
MsgBox Err.descirption
End Function
Private Sub Timer1_Timer()
If Combo4.Text <> "" Then
Set rs = cn.Execute("SELECT distinct 課程名稱 ,課程號 FROM 課程 where 課程號='" & Trim(Combo4.Text) & "'")
If Not rs.EOF Then
Combo2.Text = rs.Fields(0).Value
rs.Close
End If
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -