Public Class frmItem Inherits PMFormClass.frmPM Dim oItem As ProjectManager.ProjectItems Dim oProj As ProjectManager.Project #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 Public Sub New(ByVal oProject As ProjectManager.Project) MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call oProj = oProject Me.lblProject.Text = oProj.ID Me.dtpStart.Value = Today Me.txtHours.Text = 0 End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents lblResID As System.Windows.Forms.Label Friend WithEvents txtDescription As System.Windows.Forms.TextBox Friend WithEvents lblDescription As System.Windows.Forms.Label Friend WithEvents lblProjID As System.Windows.Forms.Label Friend WithEvents lblProject As System.Windows.Forms.Label Friend WithEvents dtpStart As System.Windows.Forms.DateTimePicker Friend WithEvents lblStart As System.Windows.Forms.Label Friend WithEvents lblHours As System.Windows.Forms.Label Friend WithEvents txtHours As System.Windows.Forms.TextBox Friend WithEvents txtResID As System.Windows.Forms.TextBox 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer '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. Private Sub InitializeComponent() Me.txtResID = New System.Windows.Forms.TextBox() Me.lblResID = New System.Windows.Forms.Label() Me.txtDescription = New System.Windows.Forms.TextBox() Me.lblDescription = New System.Windows.Forms.Label() Me.lblProjID = New System.Windows.Forms.Label() Me.lblProject = New System.Windows.Forms.Label() Me.dtpStart = New System.Windows.Forms.DateTimePicker() Me.lblStart = New System.Windows.Forms.Label() Me.lblHours = New System.Windows.Forms.Label() Me.txtHours = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'btnSave ' Me.btnSave.Location = New System.Drawing.Point(184, 168) ' 'btnRead ' Me.btnRead.Location = New System.Drawing.Point(96, 168) ' 'btnDelete ' Me.btnDelete.Location = New System.Drawing.Point(272, 168) ' 'btnCreate ' Me.btnCreate.Location = New System.Drawing.Point(8, 168) ' 'txtResID ' Me.txtResID.Location = New System.Drawing.Point(96, 88) Me.txtResID.Name = "txtResID" Me.txtResID.Size = New System.Drawing.Size(64, 20) Me.txtResID.TabIndex = 5 Me.txtResID.Text = "" ' 'lblResID ' Me.lblResID.AutoSize = True Me.lblResID.Location = New System.Drawing.Point(24, 88) Me.lblResID.Name = "lblResID" Me.lblResID.Size = New System.Drawing.Size(70, 13) Me.lblResID.TabIndex = 4 Me.lblResID.Text = "Resource ID:" Me.lblResID.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'txtDescription ' Me.txtDescription.Location = New System.Drawing.Point(96, 32) Me.txtDescription.Multiline = True Me.txtDescription.Name = "txtDescription" Me.txtDescription.Size = New System.Drawing.Size(168, 48) Me.txtDescription.TabIndex = 3 Me.txtDescription.Text = "" ' 'lblDescription ' Me.lblDescription.AutoSize = True Me.lblDescription.Location = New System.Drawing.Point(32, 32) Me.lblDescription.Name = "lblDescription" Me.lblDescription.Size = New System.Drawing.Size(64, 13) Me.lblDescription.TabIndex = 2 Me.lblDescription.Text = "Description:" ' 'lblProjID ' Me.lblProjID.AutoSize = True Me.lblProjID.Location = New System.Drawing.Point(240, 8) Me.lblProjID.Name = "lblProjID" Me.lblProjID.Size = New System.Drawing.Size(57, 13) Me.lblProjID.TabIndex = 14 Me.lblProjID.Text = "Project ID:" ' 'lblProject ' Me.lblProject.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblProject.Location = New System.Drawing.Point(296, 8) Me.lblProject.Name = "lblProject" Me.lblProject.Size = New System.Drawing.Size(56, 24) Me.lblProject.TabIndex = 15 ' 'dtpStart ' Me.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Short Me.dtpStart.Location = New System.Drawing.Point(96, 112) Me.dtpStart.Name = "dtpStart" Me.dtpStart.Size = New System.Drawing.Size(88, 20) Me.dtpStart.TabIndex = 7 Me.dtpStart.Value = New Date(2002, 1, 1, 0, 0, 0, 0) ' 'lblStart ' Me.lblStart.AutoSize = True Me.lblStart.Location = New System.Drawing.Point(32, 112) Me.lblStart.Name = "lblStart" Me.lblStart.Size = New System.Drawing.Size(58, 13) Me.lblStart.TabIndex = 6 Me.lblStart.Text = "Start Date:" ' 'lblHours ' Me.lblHours.AutoSize = True Me.lblHours.Location = New System.Drawing.Point(56, 136) Me.lblHours.Name = "lblHours" Me.lblHours.Size = New System.Drawing.Size(38, 13) Me.lblHours.TabIndex = 8 Me.lblHours.Text = "Hours:" ' 'txtHours ' Me.txtHours.Location = New System.Drawing.Point(96, 136) Me.txtHours.Name = "txtHours" Me.txtHours.TabIndex = 9 Me.txtHours.Text = "" ' 'frmItem ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(360, 205) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtName, Me.txtID, Me.lblName, Me.lblID, Me.btnCreate, Me.btnDelete, Me.btnSave, Me.btnRead, Me.txtHours, Me.lblHours, Me.lblStart, Me.dtpStart, Me.lblProject, Me.lblProjID, Me.txtResID, Me.lblResID, Me.txtDescription, Me.lblDescription}) Me.Name = "frmItem" Me.Text = "Project Manager - Project Item" Me.ResumeLayout(False) End Sub #End Region Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click Dim intIdent As Integer If intIdent <= 0 Then oItem = oProj.AddItem() Else oItem = oProj.AddItem(intIdent) End If Me.btnCreate.Enabled = False Me.btnRead.Enabled = True Me.btnSave.Enabled = True Me.btnDelete.Enabled = True End Sub Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click If Not oItem Is Nothing Then oItem.Read() Me.txtDescription.Text = oItem.Description Me.txtResID.Text = oItem.ResID Me.dtpStart.Value = oItem.StartDate Me.txtHours.Text = oItem.Hours End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click If Not oItem Is Nothing Then oItem.Description = Me.txtDescription.Text oItem.ResID = CInt(Me.txtResID.Text) oItem.StartDate = Me.dtpStart.Value oItem.Hours = CInt(Me.txtHours.Text) oItem.Save() Me.txtID.Text = "" Me.txtDescription.Text = "" Me.txtResID.Text = "" Me.dtpStart.Value = Today Me.txtHours.Text = "" Me.btnCreate.Enabled = True Me.btnRead.Enabled = False Me.btnSave.Enabled = False Me.btnDelete.Enabled = False End If End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click If Not oItem Is Nothing Then oItem.Delete() oItem = Nothing Me.txtID.Text = "" Me.txtDescription.Text = "" Me.txtResID.Text = "" Me.dtpStart.Value = Today Me.txtHours.Text = "" Me.btnCreate.Enabled = True Me.btnRead.Enabled = False Me.btnSave.Enabled = False Me.btnDelete.Enabled = False End If End Sub End Class