📄 teachereduchecktaskform.vb
字号:
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Core
Public Class TeacherEduCheckTaskForm
'初始化为0
Private umode As Integer = UserMode.NobodyMode
Public Sub SetUserMode(ByVal value As Integer)
umode = value
End Sub
Private Sub TeacherEduCheckTaskForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListStudentName.Items.Clear()
Dim strSQL As String
If umode = UserMode.TeacherMode Then
'查询语句中,学生表和指导老师表作关联
Dim strUser As String = LoginForm.TextUser.Text
strSQL = "select * from student s, teacher t where s.tid=t.tid and t.tuser='" + strUser + "'"
Else
ButtonExcel.Visible = True
ButtonEmail.Visible = True
strSQL = "select * from student"
End If
Dim UserTable As DataTable = DBOperation.Search(strSQL)
Dim UserRow As DataRow
For Each UserRow In UserTable.Rows
ListStudentName.Items.Add(UserRow("sname"))
Next
'指导老师没有指导任何学生
If ListStudentName.Items.Count = 0 Then
MsgBox("没有合适的学生信息!", MsgBoxStyle.Exclamation, "信息框")
Me.Close()
Exit Sub
End If
ListStudentName.SelectedIndex = 0
TextTask.Text = UserTable.Rows(0)("stask")
End Sub
Private Sub ListStudentName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListStudentName.SelectedIndexChanged
Dim strListName As String = ListStudentName.SelectedItem().ToString
Dim strSQL As String = "select * from student where sname='" + strListName + "'"
TextTask.Text = DBOperation.Search(strSQL).Rows(0)("stask")
End Sub
Private Sub ButtonExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonExcel.Click
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim filePath As String = FolderBrowserDialog1.SelectedPath
My.Computer.FileSystem.CreateDirectory(filePath)
If ExcelOperation.ExcelSave(DocumentMode.ChooseMode, filePath) Then
MsgBox("保存成功!", MsgBoxStyle.Exclamation, "情况汇总")
Else
MsgBox("保存失败!", MsgBoxStyle.Exclamation, "情况汇总")
End If
End If
End Sub
Private Sub ButtonEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEmail.Click
Dim strSQL As String = "select s.sname, s.sschedule, s.semail, t.temail from student s, teacher t where s.tid=t.tid"
Dim UserTable As DataTable = DBOperation.Search(strSQL)
Dim UserRow As DataRow
Dim strSchedule As String
Dim strSubSchedule As String
Dim response As Integer = MsgBox("是否需要提醒未完成学生和其指导老师?", vbOKCancel + vbQuestion, "确认")
If response = 2 Then
Exit Sub
End If
Dim strTitle As String
Dim strSBody As String
Dim strTBody As String
Dim isSendOK As Boolean = True
For Each UserRow In UserTable.Rows
strSchedule = UserRow("sschedule")
strSubSchedule = strSchedule.Substring(0, 1)
If strSubSchedule = "0" Then
strTitle = "选题完成情况"
strSBody = "您的选题尚未完成,请加快进度!"
strTBody = "您的学生:" + UserRow("sname") + "选题尚未完成,请加以督促,谢谢!"
If EmailOperation.SendEmail("001010806@163.com", UserRow("semail"), strTitle, strSBody, "") = False Then
isSendOK = False
End If
If EmailOperation.SendEmail("001010806@163.com", UserRow("temail"), strTitle, strTBody, "") = False Then
isSendOK = False
End If
End If
Next
If isSendOK Then
MsgBox("邮件发送成功!", MsgBoxStyle.Exclamation, "发送邮件")
Else
MsgBox("邮件发送失败!", MsgBoxStyle.Exclamation, "发送邮件")
End If
End Sub
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -