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

📄 mainform.vb

📁 使用Access数据库演示的任务分配管理程序 一个使用ADO.NET基于Microsoft Access数据库演示的任务分配管理的程序
💻 VB
📖 第 1 页 / 共 4 页
字号:

        MessageBox.Show(sb.ToString, "Function Disabled", MessageBoxButtons.OK, MessageBoxIcon.Information)
        'Dim xlExport As New ExcelExport()
        'xlExport.ExportTasks(dsTasks, dsTasks.Tables(0).DefaultView, DataGridViewTasks1)
    End Sub

    Private Sub ChangePasswordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangePasswordToolStripMenuItem.Click
        Dim cForm As New ChangePasswordForm(m_DataLayer)
        cForm.ShowDialog()
    End Sub

    Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
        Try
            m_DataGridPrinter = New DataGridPrinter(DataGridViewTasks1, PrintDocument1, dsTasks.Tables(0))

            PrintPreviewDialog1.ShowDialog()
        Catch iex As System.Drawing.Printing.InvalidPrinterException
            MessageBox.Show(m_ResourceManager.GetString("no_printer"), "Printer Error")
        End Try
    End Sub

    Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
        Try
            m_DataGridPrinter = New DataGridPrinter(DataGridViewTasks1, PrintDocument1, dsTasks.Tables(0))

            Dim pDialogResult As System.Windows.Forms.DialogResult = PrintDialog1.ShowDialog()
            Me.Refresh()
            If pDialogResult = System.Windows.Forms.DialogResult.OK Then PrintDocument1.Print()
        Catch iex As System.Drawing.Printing.InvalidPrinterException
            MessageBox.Show(m_ResourceManager.GetString("no_printer"), "Printer Error")
        End Try
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub PreviewPaneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviewPaneToolStripMenuItem.Click

        Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
        If myItem.Checked Then
            myItem.Checked = False
            SplitContainer2.Panel2Collapsed = True
        Else
            myItem.Checked = True
            SplitContainer2.Panel2Collapsed = False
        End If
    End Sub

    Private Sub CustomizeColumnsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomizeColumnsToolStripMenuItem.Click
        If Not DataGridViewTasks1.DataSource Is Nothing Then
            'atleast one column was found
            Dim cForm As New CustomizeColumnsForm(DataGridViewTasks1.Columns)
            cForm.ShowDialog()
        End If
    End Sub

    Private Sub SearchProjectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchProjectToolStripMenuItem.Click
        Dim sForm As New SearchForm(m_DataLayer, Me)
        tmrGetTasks.Stop()
        sForm.ShowDialog()

        'since you can edit a task from the search, update any edits
        UpdateTasks()
        tmrGetTasks.Start()
    End Sub

    Private Sub UsersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsersToolStripMenuItem.Click
        Dim mForm As New ManageUsersForm(m_DataLayer)
        mForm.ShowDialog()

        If Not m_DataLayer.CurrentUser.IsAdministrator Then
            ManageToolStripMenuItem.Visible = False
        End If
    End Sub

    Private Sub AddProjectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddProjectToolStripMenuItem.Click
        Dim aForm As New AddProjectForm(m_DataLayer)
        aForm.ShowDialog()
    End Sub

    Private Sub ForceBackgroundUpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForceBackgroundUpdateToolStripMenuItem.Click
        If (ApplicationDeployment.IsNetworkDeployed) Then
            Dim updater As ApplicationDeployment = ApplicationDeployment.CurrentDeployment
            If updater.CheckForUpdate() Then 'Update available
                Dim res As System.Windows.Forms.DialogResult = MessageBox.Show("A newer version of the TeamVision application is available. Do you wish to update the application now?", "TimecardManager Updater", MessageBoxButtons.YesNo)
                If (res = System.Windows.Forms.DialogResult.Yes) Then
                    updater.Update()
                    MessageBox.Show("Please shutdown and restart the application to start using the new version.")
                End If
            Else
                MessageBox.Show("No updates available.")

            End If
        Else
            MessageBox.Show("No updates available because TeamVision was not network deployed.")
        End If
    End Sub

    Private Sub EnglishToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnglishToolStripMenuItem.Click
        If Not EnglishToolStripMenuItem.Checked Then
            GermanToolStripMenuItem.Checked = False
            EnglishToolStripMenuItem.Checked = True
            SetLanguage(c_DefaultCultureName)
        End If
    End Sub

    Private Sub GermanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GermanToolStripMenuItem.Click
        If Not GermanToolStripMenuItem.Checked Then
            EnglishToolStripMenuItem.Checked = False
            GermanToolStripMenuItem.Checked = True
            SetLanguage(c_GermanCultureName)
        End If
    End Sub

    Private Sub AboutTeamVisionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutTeamVisionToolStripMenuItem.Click
        Dim aForm As New AboutForm()
        aForm.ShowDialog()
    End Sub
#End Region

#Region " NotifyIcon Menu Items "
    Private Sub toolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripMenuItem1.Click
        'about from trayicon
        Dim aForm As New AboutForm()
        aForm.ShowDialog()
    End Sub

    Private Sub toolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripMenuItem2.Click
        'exit from trayicon
        Me.Close()
    End Sub

#End Region

#Region " Panel History "
    Private Sub panelHistory_HistoryLinkClicked(ByVal taskID As Integer, ByVal index As Integer) Handles hPanel.HistoryLinkClicked
        Dim row As DataRow = dsTasks.Tables(0).Rows.Find(taskID)
        If row Is Nothing Then Exit Sub

        Dim task As New Business.Task
        PrepareTask(row, task)

        Dim eForm As New EditTaskForm(m_DataLayer, New Common.TaskEventArgs(task), index)
        tmrGetTasks.Stop()
        Dim eFormResult As System.Windows.Forms.DialogResult = eForm.ShowDialog()

        If eFormResult <> System.Windows.Forms.DialogResult.Cancel Then UpdateTasks()
        tmrGetTasks.Start()
    End Sub
#End Region

#Region " Print Preview and Dialog "
    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        e.HasMorePages = m_DataGridPrinter.DrawDataGridView(e.Graphics)
        If e.HasMorePages Then
            m_DataGridPrinter.PageNumber += 1
        Else
            m_DataGridPrinter.PageNumber = 1
            m_DataGridPrinter.RowCount = 0
        End If
    End Sub

    Private Sub PrintPreviewDialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewDialog1.Load
        PrintPreviewDialog1.Bounds = ClientRectangle
    End Sub
#End Region

#Region " Helper Methods "
    Private Sub HideOverDueLabel()
        If lblOverDue.Visible Then
            lblOverDue.Visible = False
            txtDescriptionText.Location = New System.Drawing.Point(txtDescriptionText.Location.X, lblOverDue.Location.Y)
            txtDescriptionText.Height = (txtDescriptionText.Height + lblOverDue.Height + 4)
        End If
    End Sub

    Private Sub ShowOverDueLabel()
        If Not lblOverDue.Visible Then
            lblOverDue.Visible = True
            txtDescriptionText.Location = New System.Drawing.Point(txtDescriptionText.Location.X, (lblOverDue.Location.Y + lblOverDue.Height + 4))
            txtDescriptionText.Height = (txtDescriptionText.Height - lblOverDue.Height - 4)
        End If
    End Sub

    Private Sub SetLanguage(ByVal cultureName As String)
        Try
            'save the language choice to the user registry
            My.Settings.Language = cultureName
            My.Settings.Save()
            Dim mbResult As System.Windows.Forms.DialogResult = MessageBox.Show( _
                m_ResourceManager.GetString("The_application_must_be_restarted") & _
                    vbNewLine & vbNewLine & m_ResourceManager.GetString("restartApp2"), _
                        m_ResourceManager.GetString("restartApp3"), MessageBoxButtons.YesNo, _
                            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)

            If mbResult = System.Windows.Forms.DialogResult.Yes Then
                Me.Close()
                Application.Restart()
            End If
        Catch ex As Exception
            LogError.Write(ex.Message & vbNewLine & ex.StackTrace)
        End Try
    End Sub

    Private Sub ShowProgressBar(ByVal message As String)

        ToolStripStatusLabel1.Text = message
        ToolStripProgressBar1.Visible = True
        ToolStripProgressBar1.Value = 0

        'start a new thread to increment the progressbar
        BackgroundWorker1.RunWorkerAsync()

    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        'This method will run on a thread other than the UI thread.
        'Be sure not to manipulate any Windows Forms controls created
        'on the UI thread from this method.
        Dim progress As Integer = 0
        While (progress < 80)
            progress = progress + 8
            BackgroundWorker1.ReportProgress(progress)
        End While

    End Sub

    Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
        ToolStripProgressBar1.Value = e.ProgressPercentage
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        HideProgressBar()
    End Sub

    Private Sub HideProgressBar()
        'this sleep code is only eye candy but note that we must set m_ProgressBar.Value = 100
        'so that BackGroundIncrementProgressBar() can die
        Dim i As Integer
        For i = 0 To 16
            Thread.Sleep(30)
            Application.DoEvents()

            'show 100% for a glance
            If i = 15 Then ToolStripProgressBar1.Value = 100
        Next

        'clear the status bar
        ToolStripProgressBar1.Visible = False
        ToolStripStatusLabel1.Text = String.Empty
    End Sub

    Private Sub CreateNewTask(ByVal description As String)
        'create a new Task
        Dim task As New Business.Task(-1, -1, Now, Now.AddDays(30), Now, description, _
            False, 2, 0, m_ProjectID, 1, "", m_DataLayer.CurrentUser.UserID)


        Dim aForm As New AddTaskForm(m_DataLayer, New Common.TaskEventArgs(task))
        Dim aFormResult As System.Windows.Forms.DialogResult = aForm.ShowDialog()
        If aFormResult <> System.Windows.Forms.DialogResult.Cancel Then
            GetTasks(m_ProjectID, True)
        End If
    End Sub

    Private Function DisplayLoginForm() As System.Windows.Forms.DialogResult
        'now it's time for the user to login
        'note: that we are passing the web service wrapper instance
        'and the user information. you'll see a lot of this
        'because the wrapper very important.
        Dim lForm As New LoginForm(m_DataLayer)
        Dim lFormResult As System.Windows.Forms.DialogResult = lForm.ShowDialog()
        Me.Refresh()

        'the login form will not close unless the user
        'is authenticated or the user cancels
        'if the user canceled, close the app
        Return lFormResult
    End Function

    Private Sub ResetDataGrid(ByVal selectFirstRow As Boolean)
        Try
            ' Set the current row

⌨️ 快捷键说明

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