⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teachersettaskform.vb

📁 管理毕业设计的管理系统 VB+SQL2000....
💻 VB
字号:
Public Class TeacherSetTaskForm

    Private umode As Integer = UserMode.NobodyMode
    Private isListTaskSelected As Boolean = False

    Public Sub SetUserMode(ByVal value As Integer)
        umode = value
    End Sub

    Private Sub TeacherSetTaskForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListTask.Items.Clear()

        Dim strUser As String = LoginForm.TextUser.Text
        Dim strSQL As String

        If umode = UserMode.StudentMode Then
            Label1.Text = "自定义课题名:"
            ButtonInsert.Visible = False
            ButtonDelete.Visible = False
            ButtonOK.Enabled = False
            strSQL = "select t.ttask from teacher t, student s where t.tid=s.tid and s.suser='" + strUser + "'"
        Else
            strSQL = "select ttask from teacher where tuser='" + strUser + "'"
        End If

        Dim strAllTask As String = DBOperation.Search(strSQL).Rows(0)("ttask")
        Dim strTask As String

        Dim position As Integer = InStr(strAllTask, vbLf)
        While position > 0
            strTask = strAllTask.Substring(0, position - 1)
            ListTask.Items.Add(strTask)
            strAllTask = strAllTask.Substring(position)
            position = InStr(strAllTask, vbLf)
        End While
    End Sub

    Private Sub ListTask_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListTask.SelectedIndexChanged
        If umode = UserMode.StudentMode Then
            ButtonOK.Enabled = True
            isListTaskSelected = True
        End If
    End Sub

    Private Sub TextTask_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextTask.TextChanged
        If umode = UserMode.StudentMode Then
            If TextTask.Text.Trim <> "" Or isListTaskSelected = True Then
                ButtonOK.Enabled = True
            Else
                ButtonOK.Enabled = False
            End If
        End If
    End Sub

    Private Sub ButtonInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonInsert.Click
        Dim strTask As String = TextTask.Text.Trim
        If strTask = "" Then
            MsgBox("请正确输入要添加的课题名!", MsgBoxStyle.Exclamation, "错误")
            Exit Sub
        End If
        ListTask.Items.Add(strTask)
        TextTask.Text = ""
    End Sub

    Private Sub ButtonDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDelete.Click
        Dim index As Integer = ListTask.SelectedIndex
        If index >= 0 Then
            ListTask.Items.RemoveAt(index)
        End If
    End Sub

    Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
        If umode = UserMode.StudentMode Then
            Dim strTask As String
            If TextTask.Text.Trim <> "" Then
                strTask = TextTask.Text.Trim
            Else
                strTask = ListTask.SelectedItem.ToString
            End If

            Dim response As Integer = MsgBox("确定选择《" + strTask + "》作为毕业设计的课题?", vbOKCancel + vbQuestion, "确认")
            If response = 2 Then
                Exit Sub
            End If

            Dim strUser As String = LoginForm.TextUser.Text
            Dim strSQL As String = "update student set stask='" + strTask + "' where suser='" + strUser + "'"
            If DBOperation.Update(strSQL) Then
                MsgBox("选择成功!", MsgBoxStyle.OkOnly, "选择课题")
            Else
                MsgBox("选择失败!", MsgBoxStyle.Exclamation, "选择课题")
            End If
        Else
            Dim response As Integer = MsgBox("确定保存这些修改?", vbOKCancel + vbQuestion, "确认")
            If response = 2 Then
                Exit Sub
            End If

            Dim strAllTask As String = ""
            Dim i As Integer = ListTask.Items.Count
            For i = 0 To ListTask.Items.Count - 1
                strAllTask = strAllTask + ListTask.Items(i).ToString + vbLf
            Next

            Dim strUser As String = LoginForm.TextUser.Text
            Dim strSQL As String = "update teacher set ttask='" + strAllTask + "' where tuser='" + strUser + "'"
            If DBOperation.Update(strSQL) Then
                MsgBox("修改成功!", MsgBoxStyle.OkOnly, "修改课题")
            Else
                MsgBox("修改失败!", MsgBoxStyle.Exclamation, "修改课题")
            End If
        End If
    End Sub

    Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCancel.Click
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -