?? frmselect.frm
字號:
_ExtentY = 3201
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin VB.Frame Frame1
Caption = "學生信息"
Height = 975
Left = 0
TabIndex = 0
Top = 0
Width = 9735
Begin VB.TextBox txbGrade
Height = 375
Left = 4680
TabIndex = 6
Top = 360
Width = 975
End
Begin VB.TextBox txbName
Height = 375
Left = 2880
TabIndex = 4
Top = 360
Width = 975
End
Begin VB.TextBox txbId
Height = 375
Left = 600
TabIndex = 2
Top = 360
Width = 1575
End
Begin VB.Label Label4
Caption = "這里輸入學號后回車,正常操作是學生用自己的學號登陸到系統,只能選擇自己的課程。因為系統沒有制作登陸功能,所以這么處理。"
Height = 615
Left = 5880
TabIndex = 7
Top = 240
Width = 3735
End
Begin VB.Label Label3
Caption = "班級"
Height = 255
Left = 4200
TabIndex = 5
Top = 480
Width = 495
End
Begin VB.Label Label2
Caption = "姓名"
Height = 255
Left = 2520
TabIndex = 3
Top = 480
Width = 615
End
Begin VB.Label Label1
Caption = "學號"
Height = 255
Left = 120
TabIndex = 1
Top = 480
Width = 615
End
End
End
Attribute VB_Name = "frmSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub SetGrdSubject()
'根據查詢條件組合SQL語句
Dim strSQL As String
strSQL = "select a.課序號,b.課程編號,b.課程名稱,b.教師,"
strSQL = strSQL + "b.開課系別,a.上課時間天,a.上課時間節,a.上課地點 from 課程表"
strSQL = strSQL + " as a, 課程信息 as b where a.課程編號=b.課程編號"
Dim strFilter As String
strFilter = ""
If Len(Trim(Me.txbPY.Text)) <> 0 Then
strFilter = strFilter + " and 拼音碼 like '" + Trim(Me.txbPY.Text) + "%'"
End If
If Len(Trim(Me.txbCName.Text)) <> 0 Then
strFilter = strFilter + " and 課程名稱 like '" + Trim(txbCName.Text) + "%'"
End If
If Len(Trim(Me.txbCId.Text)) <> 0 Then
strFilter = strFilter + " and b.課程編號 like '" + Trim(Me.txbCId.Text) + "%'"
End If
If Len(Trim(Me.txbCNumber.Text)) <> 0 Then
strFilter = strFilter + " and 課序號 like '" + Trim(Me.txbCNumber.Text) + "%'"
End If
If Len(Trim(strFilter)) = 0 Then
Exit Sub
End If
strFilter = strFilter + " order by 課序號"
'執行SQL語句
Dim db As New DataBases
Dim rs As Recordset
Set rs = db.RunSelectSQL(strSQL + strFilter)
'設置數據源
Set Adodc2.Recordset = rs
End Sub
Private Sub btnDelete_Click()
If Adodc1.Recordset.EOF Or Adodc1.Recordset.BOF Then
Exit Sub
End If
If MsgBox("你確定要刪除嗎?", vbYesNo) = vbYes Then
Dim strCId As String
strCId = Trim(Adodc1.Recordset(1))
Dim strSQL As String
strSQL = "delete from 選課表 where 學號='"
strSQL = strSQL + Trim(Me.txbId.Text)
strSQL = strSQL + "' and 課序號 = '" + strCId + "'"
Dim db As New DataBases
db.RunSelectSQL (strSQL)
Dim rs As Recordset
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL = strSQL + "a.上課時間天,a.上課時間節,a.上課地點 from 選課表 "
strSQL = strSQL + "as c, 課程表 as a, 課程信息 as b where "
strSQL = strSQL + "a.課程編號=b.課程編號 and c.課序號=a.課序號 "
strSQL = strSQL + "and 學號='" + Trim(txbId.Text) + "' order by a.課序號"
Set rs = db.RunSelectSQL(strSQL)
Set Adodc1.Recordset = rs
End If
End Sub
Private Sub btnDisplay_Click()
Dim frm As New frmCourse
frm.txbOne.Text = Me.txbId.Text
frm.LoadData
frm.Show
End Sub
Private Sub btnSearch_Click()
SetGrdSubject
End Sub
Private Sub btnSelect_Click()
If Adodc2.Recordset.EOF Or Adodc2.Recordset.BOF Then
Exit Sub
End If
Dim db As New DataBases
Dim rs As Recordset
Dim strSQL As String
Dim strTmp As String
strTmp = Trim(Adodc2.Recordset(1))
strSQL = "select * from 選課表 where 學號='" + Trim(txbId.Text)
strSQL = strSQL + "' and 課序號 in(select 課序號 from 課程表 where 課程編號='"
strSQL = strSQL + strTmp + "')"
Set rs = db.RunSelectSQL(strSQL)
If rs.RecordCount <> 0 Then
MsgBox ("該課程已經選擇!")
db.CloseConn
Exit Sub
End If
Dim strCId As String
strCId = Trim(Adodc2.Recordset(0))
strSQL = "select * from 選課表 as a, 課程表 as b "
strSQL = strSQL + "where a.課序號=b.課序號 and a.學號='"
strSQL = strSQL + Trim(txbId.Text) + "' and 100*b.上課時間天+"
strSQL = strSQL + "b.上課時間節 in (select 100*上課時間天+上課時間節"
strSQL = strSQL + " from 課程表 where 課序號='" + strCId + "')"
Set rs = db.RunSelectSQL(strSQL)
If rs.RecordCount <> 0 Then
MsgBox ("該課序號時間和已經選擇的課程沖突!")
Exit Sub
Else
strSQL = "insert into 選課表(學號,課序號) values('"
strSQL = strSQL + Trim(txbId.Text) + "','" + strCId + " ')"
db.RunSelectSQL (strSQL)
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL = strSQL + "a.上課時間天,a.上課時間節,a.上課地點 from 選課表 "
strSQL = strSQL + "as c, 課程表 as a, 課程信息 as b where "
strSQL = strSQL + "a.課程編號=b.課程編號 and c.課序號=a.課序號 and 學號='"
strSQL = strSQL + Trim(txbId.Text) + "' order by a.課序號"
Set rs = db.RunSelectSQL(strSQL)
Set Adodc1.Recordset = rs
End If
End Sub
Private Sub Form_Load()
Dim db As New DataBases
Adodc1.ConnectionString = db.sConn
Adodc2.ConnectionString = db.sConn
SetGrdSubject
End Sub
Private Sub txbPY_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SetGrdSubject
End If
End Sub
Private Sub txbCName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SetGrdSubject
End If
End Sub
Private Sub txbCId_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SetGrdSubject
End If
End Sub
Private Sub txbCNumber_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SetGrdSubject
End If
End Sub
Private Sub txbId_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim db As New DataBases
Dim strSQL As String
strSQL = "select 姓名, 班級名稱, 學籍編號 from 學生信息 as a,"
strSQL = strSQL + " 班級信息 as b where a.班級編號=b.班級編號 "
strSQL = strSQL + "and 學號='" + Trim(Me.txbId.Text) + "'"
Dim rs As Recordset
Set rs = db.RunSelectSQL(strSQL)
If rs.RecordCount = 0 Then
MsgBox ("不是在籍的學生")
Me.txbId.Text = ""
Else
Me.txbName.Text = Trim(rs("姓名"))
Me.txbGrade.Text = Trim(rs("班級名稱"))
End If
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL = strSQL + "a.上課時間天,a.上課時間節,a.上課地點 from 選課表 "
strSQL = strSQL + "as c, 課程表 as a, 課程信息 as b where a.課程編號 "
strSQL = strSQL + "=b.課程編號 and c.課序號=a.課序號 and 學號='"
strSQL = strSQL + Trim(txbId.Text)
strSQL = strSQL + "' order by a.課序號"
Set rs = db.RunSelectSQL(strSQL)
Set Adodc1.Recordset = rs
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -