【正文】
e As ) Handles SetDGDSubject() End Sub Private Sub btnSelect_Click(ByVal sender As , _ ByVal e As ) Handles If = 1 Or _ = 1 Then Exit Sub End If Dim db As DataBase = New DataBase Dim dv As DataView Dim strSQL As String = Dim strTmp As String = dtSubject. _ Rows()(1).() strSQL = select * from 選課表where 學(xué)號=39。 + strSQL += 39。 and 課序號in(select 課序號from 課程表where 課程編號=39。 strSQL += strTmp + 39。) dv = (strSQL) If 0 Then (該課程已經(jīng)選擇!) () Exit Sub End If Dim strCId As String = dtSubject. _ Rows()(0).() strSQL = select * from 選課表as a, 課程表as b strSQL += where = =39。 strSQL += + 39。 and 100*+ strSQL += (select 100*上課時間天+上課時間節(jié) strSQL += from 課程表where 課序號=39。 + strCId + 39。) dv = (strSQL) If 0 Then (該課序號時間和已經(jīng)選擇的課程沖突!) Exit Sub Else strSQL = insert into 選課表(學(xué)號,課序號) values(39。 strSQL += + 39。,39。 + strCId + 39。) (strSQL) strSQL = select ,, strSQL += , 選課表 strSQL += as c, 課程表as a, 課程信息as b where strSQL += = = 學(xué)號=39。 strSQL += + 39。 order by dv = (strSQL) = False = False = False dtData = = dtData End If () End Sub Private Sub btnDel_Click(ByVal sender As , _ ByVal e As ) Handles If = 1 Then Exit Sub End If Dim dlgResult As DialogResult = MessageBox. _ Show(確定刪除指定的已選課程嗎?, 提示, _ ) If dlgResult = Then Dim strCId As String = dtData. _ Rows()(1).() Dim strSQL As String = delete from 選課表where 學(xué)號=39。 strSQL += strSQL += 39。 and 課序號= 39。 + strCId + 39。 Dim db As DataBase = New DataBase (strSQL) Dim dv As DataView strSQL = select ,, strSQL += , 選課表 strSQL += as c, 課程表as a, 課程信息as b where strSQL += = = strSQL += and 學(xué)號=39。 + + 39。 order by dv = (strSQL) = False = False = False dtData = = dtData () End If End Sub Private Sub btnDisplay_Click(ByVal sender As , _ ByVal e As ) Handles Dim dlgChild As frmCourse = New frmCourse () End Sub Private Sub txbId_KeyDown(ByVal sender As Object, _ ByVal e As ) Handles If = And 0 Then Dim db As DataBase = New DataBase Dim strSQL As String = strSQL = select 姓名, 班級名稱, 學(xué)籍編號from 學(xué)生信息as a, strSQL += 班級信息as b where = strSQL += and 學(xué)號=39。 + + 39。 Dim dv As DataView = (strSQL) If = 0 Then (不是在籍的學(xué)生) = Else = dv(0)(0). = dv(0)(1). End If strSQL = select ,, strSQL += , 選課表 strSQL += as c, 課程表as a, 課程信息as b where strSQL += = = 學(xué)號=39。 strSQL += strSQL += 39。 order by dv = (strSQL) If = 0 Then (不是在籍的學(xué)生) = Else = False = False = False dtData = = dtData End If () End If End Sub Private Sub txbPY_KeyDown(ByVal sender As Object, _ ByVal e As ) Handles If = Then SetDGDSubject() End If End Sub Private Sub SetDGDSubject() 39。根據(jù)查詢條件組合SQL語句 Dim strSQL As String = select , strSQL += , 課程表 strSQL += as a, 課程信息as b where = Dim strFilter As String = If 0 Then strFilter += and 拼音碼like 39。 + + %39。 End If If 0 Then strFilter += and 課程名稱like 39。 + + %39。 End If If 0 Then strFilter += and 39。 + + %39。 End If If 0 Then strFilter += and 課序號like 39。 + + %39。 End If If = 0 Then Exit Sub End If strFilter += order by 課序號 39。執(zhí)行SQL語句 Dim db As DataBase = New DataBase Dim dv As DataView = (strSQL + strFilter) = False = False = False = False dtSubject = 39。設(shè)置數(shù)據(jù)源 = dtSubject () End Sub Private Sub txbCName_KeyDown(ByVal sender As Object, ByVal e As ) Handles If = Then SetDGDSubject() End If End Sub Private Sub txbCNumber_KeyDown(ByVal sender As Object, ByVal e As ) Handles If = Then SetDGDSubject() End If End Sub Private Sub txbCId_KeyDown(ByVal sender As Object, ByVal e As ) Handles If = Then SetDGDSubject() End If End Sub Private Sub frmSelect_Load(ByVal sender As , ByVal e As ) Handles End SubEnd Class6. 教學(xué)管理可實(shí)現(xiàn)的功能:課程的查詢,選課,刪除,顯示課表等查詢功能實(shí)現(xiàn)如下所示:Public Class frmSelect Inherits Private dtData As DataTable Private dtSubject As DataTable Private Sub btnSearch_Click(ByVal sender As , _ ByVal e As ) Handles SetDGDSubject() End Sub Private Sub btnSelect_Click(ByVal sender As , _ ByVal e As ) Handles If = 1 Or _ = 1 Then Exit Sub End If Dim db As DataBase = New DataBase