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

📄 frmtimetracker.vb

📁 Programming the .NET Compact Framework with vb 源代码
💻 VB
📖 第 1 页 / 共 2 页
字号:
' -----------------------------------------------------------------------------
' Code from _Programming the .NET Compact Framework with VB_
' and _Programming the .NET Compact Framework with C#_
' (c) Copyright 2002-2004 Paul Yao and David Durant. 
' All rights reserved.
' -----------------------------------------------------------------------------

Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel
Imports System.Collections

Public Class frmTimeTracker
   Inherits System.Windows.Forms.Form
   Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

#Region " Windows Form Designer generated code "

   Public Sub New()
      MyBase.New()

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

      'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      MyBase.Dispose(disposing)
   End Sub

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   Friend WithEvents lblProjName As System.Windows.Forms.Label
   Friend WithEvents txtTaskEnd As System.Windows.Forms.TextBox
   Friend WithEvents txtTaskStart As System.Windows.Forms.TextBox
   Friend WithEvents lblProjStart As System.Windows.Forms.Label
   Friend WithEvents lblProjEnd As System.Windows.Forms.Label
   Friend WithEvents cboxTasks As System.Windows.Forms.ComboBox
   Friend WithEvents txtTaskNo As System.Windows.Forms.TextBox
   Friend WithEvents txtTaskName As System.Windows.Forms.TextBox
   Friend WithEvents txtTaskEstimated As System.Windows.Forms.TextBox
   Friend WithEvents txtTaskActual As System.Windows.Forms.TextBox
   Friend WithEvents btnNewTask As System.Windows.Forms.Button
   Friend WithEvents btnAddTask As System.Windows.Forms.Button
   Friend WithEvents btnCancel As System.Windows.Forms.Button
   Friend WithEvents panelTaskFields As System.Windows.Forms.Panel
   Private Sub InitializeComponent()
      Me.MainMenu1 = New System.Windows.Forms.MainMenu
      Me.lblProjStart = New System.Windows.Forms.Label
      Me.btnNewTask = New System.Windows.Forms.Button
      Me.lblProjName = New System.Windows.Forms.Label
      Me.lblProjEnd = New System.Windows.Forms.Label
      Me.txtTaskNo = New System.Windows.Forms.TextBox
      Me.txtTaskEnd = New System.Windows.Forms.TextBox
      Me.txtTaskStart = New System.Windows.Forms.TextBox
      Me.txtTaskName = New System.Windows.Forms.TextBox
      Me.txtTaskEstimated = New System.Windows.Forms.TextBox
      Me.txtTaskActual = New System.Windows.Forms.TextBox
      Me.cboxTasks = New System.Windows.Forms.ComboBox
      Me.btnAddTask = New System.Windows.Forms.Button
      Me.btnCancel = New System.Windows.Forms.Button
      Me.panelTaskFields = New System.Windows.Forms.Panel
      '
      'lblProjStart
      '
      Me.lblProjStart.Location = New System.Drawing.Point(144, 16)
      Me.lblProjStart.Size = New System.Drawing.Size(40, 20)
      '
      'btnNewTask
      '
      Me.btnNewTask.Location = New System.Drawing.Point(80, 240)
      Me.btnNewTask.Text = "New &Task"
      '
      'lblProjName
      '
      Me.lblProjName.Location = New System.Drawing.Point(16, 16)
      Me.lblProjName.Size = New System.Drawing.Size(120, 20)
      '
      'lblProjEnd
      '
      Me.lblProjEnd.Location = New System.Drawing.Point(192, 16)
      Me.lblProjEnd.Size = New System.Drawing.Size(40, 20)
      '
      'txtTaskNo
      '
      Me.txtTaskNo.Location = New System.Drawing.Point(8, 8)
      Me.txtTaskNo.Size = New System.Drawing.Size(40, 22)
      Me.txtTaskNo.Text = ""
      '
      'txtTaskEnd
      '
      Me.txtTaskEnd.Location = New System.Drawing.Point(160, 8)
      Me.txtTaskEnd.Size = New System.Drawing.Size(72, 22)
      Me.txtTaskEnd.Text = ""
      '
      'txtTaskStart
      '
      Me.txtTaskStart.Location = New System.Drawing.Point(72, 8)
      Me.txtTaskStart.Size = New System.Drawing.Size(72, 22)
      Me.txtTaskStart.Text = ""
      '
      'txtTaskName
      '
      Me.txtTaskName.Location = New System.Drawing.Point(8, 40)
      Me.txtTaskName.Size = New System.Drawing.Size(144, 22)
      Me.txtTaskName.Text = ""
      '
      'txtTaskEstimated
      '
      Me.txtTaskEstimated.Location = New System.Drawing.Point(160, 40)
      Me.txtTaskEstimated.Size = New System.Drawing.Size(32, 22)
      Me.txtTaskEstimated.Text = ""
      '
      'txtTaskActual
      '
      Me.txtTaskActual.Location = New System.Drawing.Point(200, 40)
      Me.txtTaskActual.Size = New System.Drawing.Size(32, 22)
      Me.txtTaskActual.Text = ""
      '
      'cboxTasks
      '
      Me.cboxTasks.Location = New System.Drawing.Point(8, 200)
      Me.cboxTasks.Size = New System.Drawing.Size(224, 22)
      '
      'btnAddTask
      '
      Me.btnAddTask.Location = New System.Drawing.Point(0, 240)
      Me.btnAddTask.Text = "Add &Task"
      '
      'btnCancel
      '
      Me.btnCancel.Location = New System.Drawing.Point(160, 240)
      Me.btnCancel.Text = "&Cancel"
      '
      'panelTaskFields
      '
      Me.panelTaskFields.Controls.Add(Me.txtTaskActual)
      Me.panelTaskFields.Controls.Add(Me.txtTaskEstimated)
      Me.panelTaskFields.Controls.Add(Me.txtTaskName)
      Me.panelTaskFields.Controls.Add(Me.txtTaskStart)
      Me.panelTaskFields.Controls.Add(Me.txtTaskEnd)
      Me.panelTaskFields.Controls.Add(Me.txtTaskNo)
      Me.panelTaskFields.Location = New System.Drawing.Point(0, 128)
      Me.panelTaskFields.Size = New System.Drawing.Size(240, 64)
      '
      'frmTimeTracker
      '
      Me.Controls.Add(Me.panelTaskFields)
      Me.Controls.Add(Me.btnCancel)
      Me.Controls.Add(Me.btnAddTask)
      Me.Controls.Add(Me.cboxTasks)
      Me.Controls.Add(Me.lblProjEnd)
      Me.Controls.Add(Me.lblProjName)
      Me.Controls.Add(Me.btnNewTask)
      Me.Controls.Add(Me.lblProjStart)
      Me.Menu = Me.MainMenu1
      Me.Text = "Time Tracker"

   End Sub

#End Region

#Region " Database Structure Simulated "
   Private Structure Project
      Public strProjNo As String
      Public strProjName As String
      Public dateProjStart As Date
      Public dateProjEnd As Date
      Public ctProjTasks As Integer
      Public strProjComments As String
      Public Sub New(ByVal strNo As String, _
                     ByVal strName As String, _
                     ByVal dateStart As Date, _
                     ByVal dateEnd As Date, _
                     ByVal ctTasks As Integer, _
                     ByVal strComments As String)
         strProjNo = strNo
         strProjName = strName
         dateProjStart = dateStart
         dateProjEnd = dateEnd
         ctProjTasks = ctTasks
         strProjComments = strComments
      End Sub
   End Structure

   Private Structure Task
      Private m_strTaskIdent As String
      Private m_strTaskName As String
      Private m_dateTaskStart As Date
      Private m_dateTaskEnd As Date
      Private m_durTaskEstimated As Integer  '  In hours
      Private m_durTaskActual As Integer     '  In hours
      Private m_strTaskComments As String
      Public Property strTaskIdent() As String
         Get
            Return m_strTaskIdent
         End Get
         Set(ByVal Value As String)
            m_strTaskIdent = Value
         End Set
      End Property
      Public Property strTaskName() As String
         Get
            Return m_strTaskName
         End Get
         Set(ByVal Value As String)
            m_strTaskName = Value
         End Set
      End Property
      Public Property dateTaskStart() As DateTime
         Get
            Return m_dateTaskStart
         End Get
         Set(ByVal Value As DateTime)
            m_dateTaskStart = Value
         End Set
      End Property
      Public Property dateTaskEnd() As DateTime
         Get
            Return m_dateTaskEnd
         End Get
         Set(ByVal Value As DateTime)
            m_dateTaskEnd = Value
         End Set
      End Property
      Public Property durTaskEstimated() As Integer
         Get
            Return m_durTaskEstimated
         End Get
         Set(ByVal Value As Integer)
            m_durTaskEstimated = Value
         End Set
      End Property
      Public Property durTaskActual() As Integer
         Get
            Return m_durTaskActual
         End Get
         Set(ByVal Value As Integer)
            m_durTaskActual = Value
         End Set
      End Property
      Public Property strTaskComments() As String
         Get
            Return m_strTaskComments
         End Get
         Set(ByVal Value As String)
            m_strTaskComments = Value
         End Set
      End Property
      Public Sub New(ByVal strNo As String, _
                     ByVal strName As String, _
                     ByVal dateStart As Date, _
                     ByVal dateEnd As Date, _
                     ByVal durEstimated As Integer, _
                     ByVal durActual As Integer, _
                     ByVal strComments As String)
         strTaskIdent = strNo
         strTaskName = strName
         dateTaskStart = dateStart
         dateTaskEnd = dateEnd
         durTaskEstimated = durEstimated
         durTaskActual = durActual
         strTaskComments = strComments
      End Sub
   End Structure
#End Region

   '  The current project.
   Private theProject As Project
   '  The tasks of the current project.
   Private theTasks As New ArrayList

   '  A text box that we will create later in the program.
   Private txtTaskComments As Windows.Forms.TextBox

   '  The index number of the previous task.  We will
   '     need to know it in case the users cancels out 
   '     during task creation.
   Private ixTaskPrev As Integer

   Private Sub Form1_Load( _
                  ByVal sender As System.Object, _
                  ByVal e As System.EventArgs _
                  ) _
                  Handles MyBase.Load

      '  Set the initial state of the controls.
      InitControlState()

      '  Load and display a project.
      If LoadProject(42) Then
         DisplayProject()
      Else
         Me.Close()
      End If
   End Sub

   Private Sub lbldateProjEnd_TextChanged( _
                  ByVal sender As System.Object, _
                  ByVal e As System.EventArgs _
                  ) _
                  Handles lblProjEnd.TextChanged

      '  If this project is due or overdue,
      '      make the background light red.
      SetBkColor(lblProjEnd, Color.LightPink)

⌨️ 快捷键说明

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