📄 addtaskform.vb
字号:
Me.lblHeader.TabIndex = CType(resources.GetObject("lblHeader.TabIndex"), Integer)
Me.lblHeader.Text = resources.GetString("lblHeader.Text")
Me.lblHeader.TextAlign = CType(resources.GetObject("lblHeader.TextAlign"), System.Drawing.ContentAlignment)
Me.lblHeader.Visible = CType(resources.GetObject("lblHeader.Visible"), Boolean)
'
'AddTaskForm
'
Me.AcceptButton = Me.btnOK
Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
Me.AccessibleName = resources.GetString("$this.AccessibleName")
Me.Anchor = CType(resources.GetObject("$this.Anchor"), System.Windows.Forms.AnchorStyles)
Me.AutoScaleBaseSize = CType(resources.GetObject("$this.AutoScaleBaseSize"), System.Drawing.Size)
Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
Me.BackColor = System.Drawing.Color.White
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.CancelButton = Me.btnCancel
Me.ClientSize = CType(resources.GetObject("$this.ClientSize"), System.Drawing.Size)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblHeader, Me.PictureBox1, Me.TabControl1})
Me.Dock = CType(resources.GetObject("$this.Dock"), System.Windows.Forms.DockStyle)
Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
Me.MaximizeBox = False
Me.MaximumSize = CType(resources.GetObject("$this.MaximumSize"), System.Drawing.Size)
Me.MinimizeBox = False
Me.MinimumSize = CType(resources.GetObject("$this.MinimumSize"), System.Drawing.Size)
Me.Name = "AddTaskForm"
Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.ShowInTaskbar = False
Me.StartPosition = CType(resources.GetObject("$this.StartPosition"), System.Windows.Forms.FormStartPosition)
Me.Text = resources.GetString("$this.Text")
Me.Visible = CType(resources.GetObject("$this.Visible"), Boolean)
Me.TabControl1.ResumeLayout(False)
Me.tabDetails.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private m_DataLayer As DataLayer
Private m_TaskRow As DataRow
Private m_ImageList As New ImageList()
Private m_TextList As New ArrayList()
Private m_ProgressList As ArrayList
Private Const c_PriorityImagesPath As String = "Images\"
Private m_ResourceManager As New Resources.ResourceManager("TaskVision.Localize", System.Reflection.Assembly.GetExecutingAssembly())
Private Sub TaskForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'bind the datatables to their respective dropdowns
With m_DataLayer.DsLookupTables.Statuses
cbStatus.DataSource = .DefaultView
cbStatus.DisplayMember = .StatusTextColumn.ColumnName
cbStatus.ValueMember = .StatusIDColumn.ColumnName
End With
With m_DataLayer.DsLookupTables.Priorities
cbPriority.DataSource = .DefaultView
cbPriority.DisplayMember = .PriorityTextColumn.ColumnName
cbPriority.ValueMember = .PriorityIDColumn.ColumnName
End With
With m_DataLayer.DsLookupTables.Users
cbAssignedTo.DataSource = .DefaultView
cbAssignedTo.DisplayMember = .UserFullNameColumn.ColumnName
cbAssignedTo.ValueMember = .UserIDColumn.ColumnName
End With
m_ProgressList = TaskProgress.GetValues()
cbProgress.DataSource = m_ProgressList
cbProgress.DisplayMember = "Text"
cbProgress.ValueMember = "Value"
'grab the priority images
Dim dr As DataRow
Dim columnName As String = m_DataLayer.DsLookupTables.Priorities.PriorityTextColumn.ColumnName
For Each dr In m_DataLayer.DsLookupTables.Priorities.Rows
Try
m_ImageList.Images.Add(Image.FromFile(c_PriorityImagesPath & CType(dr.Item(columnName), String) & ".gif"))
m_TextList.Add(dr.Item("PriorityText"))
Catch
MessageBox.Show(m_ResourceManager.GetString("The_image_file") & " " & Application.StartupPath & "\" & c_PriorityImagesPath & CType(dr.Item(columnName), String) & m_ResourceManager.GetString("gif_was_not_found"), m_ResourceManager.GetString("File_Not_Found"))
LogError.Write(m_ResourceManager.GetString("The_image_file") & " " & Application.StartupPath & "\" & c_PriorityImagesPath & CType(dr.Item(columnName), String) & m_ResourceManager.GetString("gif_was_not_found"))
Exit For
Me.Close()
Return
End Try
Next
'add the value from a drag and drop task
If m_TaskRow.Item("TaskDescription") Is DBNull.Value Then
txtDescription.Text = String.Empty
Else
txtDescription.Text = CType(m_TaskRow.Item("TaskDescription"), String)
End If
'enable the update button if data is changed by the user
AddHandler txtSummary.TextChanged, AddressOf EnableUpdate
AddHandler txtDescription.TextChanged, AddressOf EnableUpdate
AddHandler cbPriority.SelectedValueChanged, AddressOf EnableUpdate
AddHandler cbProgress.SelectedValueChanged, AddressOf EnableUpdate
AddHandler cbAssignedTo.SelectedValueChanged, AddressOf EnableUpdate
AddHandler cbStatus.SelectedValueChanged, AddressOf EnableUpdate
AddHandler dtDueDate.ValueChanged, AddressOf EnableUpdate
lblHeader.Text = m_ResourceManager.GetString("Add_new_task_to") & " " & CType(m_DataLayer.DsProjects.Projects.Rows.Find(m_TaskRow.Item("ProjectID")).Item("ProjectName"), String)
End Sub
Private Sub EnableUpdate(ByVal sender As Object, ByVal e As System.EventArgs)
btnOK.Enabled = True
End Sub
Private Function SaveTask() As Boolean
If txtSummary.Text.Trim().Length > 0 Then
'copy the information from the form fields back to the DataRow
With m_TaskRow
.Item("TaskSummary") = txtSummary.Text.Trim()
.Item("TaskDescription") = txtDescription.Text.Trim()
.Item("PriorityID") = cbPriority.SelectedValue
.Item("StatusID") = cbStatus.SelectedValue
.Item("AssignedTo") = cbAssignedTo.SelectedValue
.Item("ModifiedBy") = m_DataLayer.CurrentUserInformation.UserID
.Item("Progress") = cbProgress.SelectedValue
.Item("IsDeleted") = False
.Item("DateDue") = dtDueDate.Value
.Item("DateModified") = DateTime.Now
.Item("DateCreated") = DateTime.Now
.Item("StatusText") = m_DataLayer.DsLookupTables.Tables("Statuses").Rows.Find(cbStatus.SelectedValue).Item("StatusText")
.Item("AssignedToText") = m_DataLayer.DsLookupTables.Tables("Users").Rows.Find(cbAssignedTo.SelectedValue).Item("UserFullName")
.Item("ModifiedByText") = m_DataLayer.CurrentUserInformation.UserFullName
.Item("PriorityText") = m_DataLayer.DsLookupTables.Tables("Priorities").Rows.Find(cbPriority.SelectedValue).Item("PriorityText")
End With
Return True
Else
MessageBox.Show(m_ResourceManager.GetString("Please_enter_a_Summary"))
txtSummary.Focus()
Return False
End If
End Function
Private Sub cbPriority_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cbPriority.DrawItem
e.DrawBackground()
e.DrawFocusRectangle()
e.Graphics.DrawImage(m_ImageList.Images(e.Index), New Point(e.Bounds.X, e.Bounds.Y))
e.Graphics.DrawString(CType(m_TextList(e.Index), String), e.Font, New SolidBrush(Color.Black), _
m_ImageList.Images(e.Index).Width + 4, e.Bounds.Top + 1)
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If SaveTask() Then
Me.Close()
Else
Me.DialogResult = DialogResult.None
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub txtDescription_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDescription.Enter
Me.AcceptButton = Nothing
End Sub
Private Sub txtDescription_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDescription.Leave
Me.AcceptButton = Me.btnOK
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -