?? frmselect.vb
字號:
Me.Label8.Size = New System.Drawing.Size(56, 15)
Me.Label8.TabIndex = 10
Me.Label8.Text = " 課序號"
'
'txbCNumber
'
Me.txbCNumber.Location = New System.Drawing.Point(208, 48)
Me.txbCNumber.Name = "txbCNumber"
Me.txbCNumber.Size = New System.Drawing.Size(56, 21)
Me.txbCNumber.TabIndex = 9
Me.txbCNumber.Text = ""
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(24, 52)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(56, 15)
Me.Label7.TabIndex = 8
Me.Label7.Text = "課程編號"
'
'txbCId
'
Me.txbCId.Location = New System.Drawing.Point(80, 48)
Me.txbCId.Name = "txbCId"
Me.txbCId.Size = New System.Drawing.Size(56, 21)
Me.txbCId.TabIndex = 7
Me.txbCId.Text = ""
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(152, 21)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(56, 15)
Me.Label6.TabIndex = 6
Me.Label6.Text = "課程名稱"
'
'txbCName
'
Me.txbCName.Location = New System.Drawing.Point(208, 16)
Me.txbCName.Name = "txbCName"
Me.txbCName.Size = New System.Drawing.Size(56, 21)
Me.txbCName.TabIndex = 5
Me.txbCName.Text = ""
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(24, 21)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(56, 15)
Me.Label5.TabIndex = 4
Me.Label5.Text = "課程拼音"
'
'txbPY
'
Me.txbPY.Location = New System.Drawing.Point(80, 16)
Me.txbPY.Name = "txbPY"
Me.txbPY.Size = New System.Drawing.Size(56, 21)
Me.txbPY.TabIndex = 3
Me.txbPY.Text = ""
'
'frmSelect
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(640, 325)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.grbTop)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmSelect"
Me.Text = "學生選課"
Me.grbTop.ResumeLayout(False)
Me.GroupBox1.ResumeLayout(False)
CType(Me.dgdList, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
CType(Me.dgdSubject, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSearch.Click
SetDGDSubject()
End Sub
Private Sub btnSelect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSelect.Click
If dgdList.CurrentCell.RowNumber = -1 Or _
dgdSubject.CurrentCell.RowNumber = -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(dgdSubject.CurrentCell.RowNumber)(1).ToString.Trim()
strSQL = "select * from 選課表 where 學號='" + txbId.Text.Trim
strSQL += "' and 課序號 in(select 課序號 from 課程表 where 課程編號='"
strSQL += strTmp + "')"
dv = db.RunSelectSQL(strSQL)
If dv.Count <> 0 Then
MessageBox.Show("該課程已經(jīng)選擇!")
db.Dispose()
Exit Sub
End If
Dim strCId As String = dtSubject. _
Rows(dgdSubject.CurrentCell.RowNumber)(0).ToString.Trim()
strSQL = "select * from 選課表 as a, 課程表 as b "
strSQL += "where a.課序號=b.課序號 and a.學號='"
strSQL += txbId.Text.Trim + "' and 100*b.上課時間天+"
strSQL += "b.上課時間節(jié) in (select 100*上課時間天+上課時間節(jié)"
strSQL += " from 課程表 where 課序號='" + strCId + "')"
dv = db.RunSelectSQL(strSQL)
If dv.Count <> 0 Then
MessageBox.Show("該課序號時間和已經(jīng)選擇的課程沖突!")
Exit Sub
Else
strSQL = "insert into 選課表(學號,課序號) values('"
strSQL += txbId.Text.Trim + "','" + strCId + " ')"
db.RunDelOrInsSQL(strSQL)
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL += "a.上課時間天,a.上課時間節(jié),a.上課地點 from 選課表 "
strSQL += "as c, 課程表 as a, 課程信息 as b where "
strSQL += "a.課程編號=b.課程編號 and c.課序號=a.課序號 and 學號='"
strSQL += txbId.Text.Trim + "' order by a.課序號"
dv = db.RunSelectSQL(strSQL)
dv.AllowDelete = False
dv.AllowEdit = False
dv.AllowNew = False
dtData = dv.Table
Me.dgdList.DataSource = dtData
End If
db.Dispose()
End Sub
Private Sub btnDel_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDel.Click
If Me.dgdList.CurrentCell.RowNumber = -1 Then
Exit Sub
End If
Dim dlgResult As DialogResult = MessageBox. _
Show("確定刪除指定的已選課程嗎?", "提示", _
MessageBoxButtons.YesNo)
If dlgResult = DialogResult.Yes Then
Dim strCId As String = dtData. _
Rows(dgdList.CurrentCell.RowNumber)(1).ToString.Trim()
Dim strSQL As String = "delete from 選課表 where 學號='"
strSQL += Me.txbId.Text.Trim
strSQL += "' and 課序號 = '" + strCId + "'"
Dim db As DataBase = New DataBase
db.RunDelOrInsSQL(strSQL)
Dim dv As DataView
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL += "a.上課時間天,a.上課時間節(jié),a.上課地點 from 選課表 "
strSQL += "as c, 課程表 as a, 課程信息 as b where "
strSQL += "a.課程編號=b.課程編號 and c.課序號=a.課序號 "
strSQL += "and 學號='" + txbId.Text.Trim + "' order by a.課序號"
dv = db.RunSelectSQL(strSQL)
dv.AllowDelete = False
dv.AllowEdit = False
dv.AllowNew = False
dtData = dv.Table
Me.dgdList.DataSource = dtData
db.Dispose()
End If
End Sub
Private Sub btnDisplay_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim dlgChild As frmCourse = New frmCourse
dlgChild.Show()
End Sub
Private Sub txbId_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbId.KeyDown
If e.KeyCode = Keys.Enter And txbId.Text.Trim.Length <> 0 Then
Dim db As DataBase = New DataBase
Dim strSQL As String = ""
strSQL = "select 姓名, 班級名稱, 學籍編號 from 學生信息 as a,"
strSQL += " 班級信息 as b where a.班級編號=b.班級編號 "
strSQL += "and 學號='" + Me.txbId.Text.Trim + "'"
Dim dv As DataView = db.RunSelectSQL(strSQL)
If dv.Count = 0 Then
MessageBox.Show("不是在籍的學生")
Me.txbId.Text = ""
Else
Me.txbName.Text = dv(0)(0).ToString.Trim
Me.txbGrade.Text = dv(0)(1).ToString.Trim
End If
strSQL = "select c.學號,a.課序號,b.課程名稱,b.教師,b.開課系別,"
strSQL += "a.上課時間天,a.上課時間節(jié),a.上課地點 from 選課表 "
strSQL += "as c, 課程表 as a, 課程信息 as b where a.課程編號 "
strSQL += "=b.課程編號 and c.課序號=a.課序號 and 學號='"
strSQL += txbId.Text.Trim
strSQL += "' order by a.課序號"
dv = db.RunSelectSQL(strSQL)
If dv.Count = 0 Then
MessageBox.Show("不是在籍的學生")
Me.txbId.Text = ""
Else
dv.AllowDelete = False
dv.AllowEdit = False
dv.AllowNew = False
dtData = dv.Table
Me.dgdList.DataSource = dtData
End If
db.Dispose()
End If
End Sub
Private Sub txbPY_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbPY.KeyDown
If e.KeyCode = Keys.Enter Then
SetDGDSubject()
End If
End Sub
Private Sub SetDGDSubject()
'根據(jù)查詢條件組合SQL語句
Dim strSQL As String = "select a.課序號,b.課程編號,b.課程名稱,b.教師,"
strSQL += "b.開課系別,a.上課時間天,a.上課時間節(jié),a.上課地點 from 課程表"
strSQL += " as a, 課程信息 as b where a.課程編號=b.課程編號"
Dim strFilter As String = ""
If Me.txbPY.Text.Trim.Length <> 0 Then
strFilter += " and 拼音碼 like '" + Me.txbPY.Text.Trim + "%'"
End If
If Me.txbCName.Text.Trim.Length <> 0 Then
strFilter += " and 課程名稱 like '" + Me.txbCName.Text.Trim + "%'"
End If
If Me.txbCId.Text.Trim.Length <> 0 Then
strFilter += " and b.課程編號 like '" + Me.txbCId.Text.Trim + "%'"
End If
If Me.txbCNumber.Text.Trim.Length <> 0 Then
strFilter += " and 課序號 like '" + Me.txbCNumber.Text.Trim + "%'"
End If
If strFilter.Trim.Length = 0 Then
Exit Sub
End If
strFilter += " order by 課序號"
'執(zhí)行SQL語句
Dim db As DataBase = New DataBase
Dim dv As DataView = db.RunSelectSQL(strSQL + strFilter)
dv.AllowDelete = False
dv.AllowEdit = False
dv.AllowNew = False
Me.dgdSubject.AllowSorting = False
dtSubject = dv.Table
'設(shè)置數(shù)據(jù)源
Me.dgdSubject.DataSource = dtSubject
db.Dispose()
End Sub
Private Sub txbCName_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbCName.KeyDown
If e.KeyCode = Keys.Enter Then
SetDGDSubject()
End If
End Sub
Private Sub txbCNumber_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbCNumber.KeyDown
If e.KeyCode = Keys.Enter Then
SetDGDSubject()
End If
End Sub
Private Sub txbCId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbCId.KeyDown
If e.KeyCode = Keys.Enter Then
SetDGDSubject()
End If
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -