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

📄 searchform.vb

📁 使用Access数据库演示的任务分配管理程序 一个使用ADO.NET基于Microsoft Access数据库演示的任务分配管理的程序
💻 VB
字号:
'---------------------------------------------------------------------
'  This file is part of the Microsoft .NET Framework SDK Code Samples.
' 
'  Copyright (C) Microsoft Corporation.  All rights reserved.
' 
' This source code is intended only as a supplement to Microsoft
' Development Tools and/or on-line documentation.  See these other
' materials for detailed information regarding Microsoft code samples.
' 
' THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'---------------------------------------------------------------------

Public Class SearchForm
    Inherits System.Windows.Forms.Form

    Public Sub New(ByVal dl As DataLayer, ByVal mForm As MainForm)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        m_DataLayer = dl
    End Sub

    Private m_DataLayer As DataLayer
    Private facade As New Database.TaskFacade
    Private m_ResourceManager As New Resources.ResourceManager("TeamVision.Localize", System.Reflection.Assembly.GetExecutingAssembly())

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If txtQuery.Text.Trim() = String.Empty Then
            Return
        End If

        'clear last results
        lvResults.Items.Clear()

        Try
            'loop through tasks and do a simple indexof search
            'on the summary, description, assignedtotext fields
            Dim TaskList As ArrayList = facade.GetAllTasks

            For Each task As Business.Task In TaskList
                Dim AssignedUser As Business.User = m_DataLayer.GetAssignment(task.AssignedID).User
                If task.Summary.ToLower().IndexOf(txtQuery.Text.ToLower()) <> -1 Or task.Description.ToLower().IndexOf(txtQuery.Text.ToLower()) <> -1 Or AssignedUser.Name.ToLower().IndexOf(txtQuery.Text.ToLower()) <> -1 Then

                    'add found task to listview
                    Dim lvItem As New ListViewItem(New String() {task.TaskID.ToString, task.Summary, AssignedUser.Name})
                    lvResults.Items.Add(lvItem)
                End If
            Next
            If lvResults.Items.Count = 0 Then
                'add found task to listview
                Dim lvItem As New ListViewItem(New String() {String.Empty, m_ResourceManager.GetString("Search_0items"), String.Empty})
                lvResults.Items.Add(lvItem)
            End If
        Catch ex As Exception
            LogError.Write(ex.Message & vbCrLf & ex.StackTrace)
        End Try
    End Sub

    Private Sub lvResults_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvResults.DoubleClick
        'user double-clicked a task, try to open a task form
        If lvResults.SelectedItems.Count > 0 Then
            Try
                If lvResults.SelectedItems(0).SubItems(0).Text = String.Empty Then Return

                Dim taskID As Integer = Integer.Parse(lvResults.SelectedItems(0).SubItems(0).Text)
                Dim task As Business.Task = facade.GetTask(taskID)

                Dim eForm As New EditTaskForm(m_DataLayer, New Common.TaskEventArgs(task))
                eForm.ShowDialog()
            Catch ex As Exception
                LogError.Write(ex.Message & vbCrLf & ex.StackTrace)
            End Try
        End If
    End Sub

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

⌨️ 快捷键说明

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