📄 frmgrademan.vb
字号:
stugdbset = Nothing
stugdbset = MyGrade.GetStuGrade(CurMar.MarjoyID, Trim(CombTestYear.Text) & Trim(CombTesttime.Text))
If Not stugdbset Is Nothing Then
DGStudent.DataSource = stugdbset.Tables(0).DefaultView
Else
DGStudent.DataSource = Nothing
End If
End If
DGStudent.CaptionText = "学生信息"
DGStuGradeDetials.CaptionText = "学生成绩明细"
dsstugraddeta = Nothing
DGStuGradeDetials.DataSource = Nothing
clearfrom()
End Sub
Private Sub RDBDetails_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RDBDetails.CheckedChanged
If RDBModify.Checked = True Then
GetDataSet()
BindGradesGrid()
Else
stugdbset = Nothing
stugdbset = MyGrade.GetStuGrade(CurMar.MarjoyID, Trim(CombTestYear.Text) & Trim(CombTesttime.Text))
DGStudent.ReadOnly = True
If Not stugdbset Is Nothing Then
DGStudent.DataSource = stugdbset.Tables(0).DefaultView
Else
DGStudent.DataSource = Nothing
End If
DGStudent.CaptionText = "学生信息"
End If
DGStuGradeDetials.CaptionText = "学生成绩明细"
dsstugraddeta = Nothing
DGStuGradeDetials.DataSource = Nothing
clearfrom()
End Sub
Private Sub DGStudent_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGStudent.CurrentCellChanged
If DGStudent.CurrentRowIndex < 0 Then
Exit Sub
End If
If DGStudent.Item(DGStudent.CurrentRowIndex, 0) Is Nothing Then
Exit Sub
End If
If RDBDetails.Checked Then
txtStuName.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 1)
txtStuID.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 2)
CombSexy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 3)
txtDepartment.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 4)
txtMarjoy.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 5)
txtGrade.Text = DGStudent.Item(DGStudent.CurrentRowIndex, 6)
MyStu.GetStuInfo(txtStuID.Text)
CurStu.Equal(MyStu)
CurGrade.GetInfo(DGStudent.Item(DGStudent.CurrentRowIndex, 8))
dsstugraddeta = Nothing
dsstugraddeta = MyGrade.GetInfoByStuID(CurGrade.StudentID)
If Not dsstugraddeta Is Nothing Then
DGStuGradeDetials.CaptionText = "学生[" & CurStu.StudentName & "]共参加:" & _
dsstugraddeta.Tables(0).Rows.Count.ToString & "次考试"
DGStuGradeDetials.ReadOnly = True
DGStuGradeDetials.DataSource = dsstugraddeta.Tables(0).DefaultView
Else
DGStuGradeDetials.CaptionText = "学生[" & CurStu.StudentName & "]共参加:0次考试"
DGStuGradeDetials.DataSource = Nothing
DGStuGradeDetials.ReadOnly = True
End If
Else
Dim tmpds As DataSet
tmpds = MyGrade.GetStuInfo(DGStudent.Item(DGStudent.CurrentRowIndex, 1), DGStudent.Item(DGStudent.CurrentRowIndex, 3))
If Not tmpds Is Nothing Then
txtStuName.Text = tmpds.Tables(0).Rows(0).Item(1)
txtStuID.Text = tmpds.Tables(0).Rows(0).Item(2)
CombSexy.Text = tmpds.Tables(0).Rows(0).Item(3)
txtDepartment.Text = tmpds.Tables(0).Rows(0).Item(4)
txtMarjoy.Text = tmpds.Tables(0).Rows(0).Item(5)
txtGrade.Text = tmpds.Tables(0).Rows(0).Item(6)
DGStudent.CaptionText = "学生信息--当前编辑学生[" & txtStuName.Text & "(" & txtStuID.Text & ")]"
End If
End If
End Sub
Public Function CreateDataSet() As DataSet
Dim dsgrades As DataSet
' Attempt to connect to the local SQL server instance, and a local
' MSDE installation (with Northwind).
Dim IsConnecting As Boolean = True
While IsConnecting
Try
' The SqlConnection class allows you to communicate with SQL Server.
' The constructor accepts a connection string as an argument. This
' connection string uses Integrated Security, which means that you
' must have a login in SQL Server, or be part of the Administrators
' group for this to work.
Dim scnnNW As New OleDbConnection(ConnectStr)
Dim strSQL As String = _
"SELECT * FROM Grades"
' A SqlCommand object is used to execute the SQL commands.
Dim scmd As New OleDbCommand(strSQL, scnnNW)
' A SqlDataAdapter uses the SqlCommand object to fill a DataSet.
sdastugrades = New OleDbDataAdapter(scmd)
' A SqlCommandBuilder automatically generates the SQL commands needed
' to update the database later.
Dim scb As New OleDbCommandBuilder(sdastugrades)
' Create a new DataSet and fill its first DataTable.
dsgrades = New DataSet
sdastugrades.Fill(dsgrades, "Grades")
IsConnecting = False
Catch exp As Exception
MsgBox("连接数据库失败,请重新操作!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
Exit Function
End Try
End While
Return dsgrades
End Function
Public Sub UpdateDataSet(ByVal inDS As DataSet)
' If the DataSet that was passed in is Nothing, exit this subrouting.
If inDS Is Nothing Then
Exit Sub
End If
Try
' First verify that the data adapters have been created, and call
' the CreateDataSet to build them if necessary.
If sdastugrades Is Nothing Then
CreateDataSet()
End If
' Try to Update the DataSet. It is critical that everything is done
' in the proper sequence, unless you turn off the EnforceConstraints property.
' So there are two ways of updating the data.
' The first is shutting off EnforceConstraints
'inDS.EnforceConstraints = False
sdastugrades.Update(inDS, "Grades")
'' Changes can be made in any order
If Not inDS.GetChanges(DataRowState.Modified) Is Nothing Then
sdastugrades.Update(inDS.GetChanges(DataRowState.Modified), "Grades")
End If
If Not inDS.GetChanges(DataRowState.Deleted) Is Nothing Then
sdastugrades.Update(inDS.GetChanges(DataRowState.Modified), "Grades")
End If
sdastugrades = Nothing
Catch exc As Exception
sdastugrades = Nothing
' Alert the front end that an error occurred.
MsgBox("连接数据库失败,请重新操作!", MsgBoxStyle.Exclamation, "大学语文考试系统V2.0")
Exit Sub
End Try
End Sub
Private Sub cmdFlash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFlash.Click
MyDep.Initials()
CurDep.Initials()
MyMar.Initials()
CurMar.Initials()
MyStu.Initials()
CurStu.Initials()
MyGrade.Initials()
CurGrade.Initials()
MyDep.LoadDepNodesToTV(TvDep)
clearfrom()
RDBDetails.Checked = True
stugdbset = Nothing
sdastugrades = Nothing
With DGStudent
.CaptionText = "学生成绩"
.DataSource = Nothing
End With
LbMarjoy.Items.Clear()
DGStuGradeDetials.CaptionText = "学生成绩明细"
dsstugraddeta = Nothing
DGStuGradeDetials.DataSource = Nothing
End Sub
Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
If Trim(txtQuery.Text) = "" Then
Exit Sub
End If
Dim tmpdbset As DataSet = MyGrade.QueryStuGrades(txtQuery.Text)
RDBDetails.Checked = True
If Not tmpdbset Is Nothing Then
With DGStudent
.CaptionText = "学生信息"
.ReadOnly = True
.DataSource = tmpdbset.Tables(0).DefaultView
End With
Else
With DGStudent
.CaptionText = "学生信息"
.ReadOnly = True
.DataSource = Nothing
End With
End If
clearfrom()
DGStuGradeDetials.CaptionText = "学生成绩明细"
dsstugraddeta = Nothing
DGStuGradeDetials.DataSource = Nothing
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RDBModify.Checked = True Then
Dim i As Integer
If DGStudent.CurrentRowIndex >= 0 Then
i = DGStudent.CurrentRowIndex
If MsgBox("您是否真的要删除该学生的本次考试?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "大学语文考试系统V2.0") = MsgBoxResult.Yes Then
dvstugrades.Delete(i)
UpdateDataSet(dsstugrades.GetChanges())
GetDataSet()
BindGradesGrid()
End If
End If
End If
End Sub
Private Sub frmGradeMan_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
MyDep.Initials()
CurDep.Initials()
MyMar.Initials()
CurMar.Initials()
MyStu.Initials()
CurStu.Initials()
MyGrade.Initials()
CurGrade.Initials()
stugdbset = Nothing
End Sub
Private Sub frmGradeMan_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
MyDep.Initials()
CurDep.Initials()
MyMar.Initials()
CurMar.Initials()
MyStu.Initials()
CurStu.Initials()
MyGrade.Initials()
CurGrade.Initials()
GbMarjoy.Text = "专业信息--当前专业[]"
GbDepartment.Text = "院系信息--当前院系:[]"
With DGStudent
.CaptionText = "学生成绩"
.DataSource = Nothing
End With
clearfrom()
DGStuGradeDetials.CaptionText = "学生成绩明细"
dsstugraddeta = Nothing
DGStuGradeDetials.DataSource = Nothing
RDBDetails.Checked = True
stugdbset = Nothing
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -