Public Class frmProject Inherits PMFormClass.frmPM Dim oProj As ProjectManager.Project Dim oItemForm As frmItem Dim oProd As ProjectManager.Product #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 oProduct As ProjectManager.Product) MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call oProd = oProduct Me.lblProduct.Text = oProd.ID Me.dtpStart.Value = Today Me.dtpEstEnd.Value = Today Me.dtpEnd.Value = Today 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 btnItem As System.Windows.Forms.Button Friend WithEvents txtMgrID As System.Windows.Forms.TextBox Friend WithEvents lblMgrID As System.Windows.Forms.Label Friend WithEvents txtDescription As System.Windows.Forms.TextBox Friend WithEvents lblDescription As System.Windows.Forms.Label Friend WithEvents dtpStart As System.Windows.Forms.DateTimePicker Friend WithEvents dtpEstEnd As System.Windows.Forms.DateTimePicker Friend WithEvents dtpEnd As System.Windows.Forms.DateTimePicker Friend WithEvents lblStart As System.Windows.Forms.Label Friend WithEvents lblEstEnd As System.Windows.Forms.Label Friend WithEvents lblEnd As System.Windows.Forms.Label Friend WithEvents lblProduct As System.Windows.Forms.Label Friend WithEvents lblProdID As System.Windows.Forms.Label '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.btnItem = New System.Windows.Forms.Button() Me.txtMgrID = New System.Windows.Forms.TextBox() Me.lblMgrID = New System.Windows.Forms.Label() Me.txtDescription = New System.Windows.Forms.TextBox() Me.lblDescription = New System.Windows.Forms.Label() Me.dtpStart = New System.Windows.Forms.DateTimePicker() Me.dtpEstEnd = New System.Windows.Forms.DateTimePicker() Me.dtpEnd = New System.Windows.Forms.DateTimePicker() Me.lblStart = New System.Windows.Forms.Label() Me.lblEstEnd = New System.Windows.Forms.Label() Me.lblEnd = New System.Windows.Forms.Label() Me.lblProduct = New System.Windows.Forms.Label() Me.lblProdID = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnCreate ' Me.btnCreate.Location = New System.Drawing.Point(8, 216) Me.btnCreate.TabIndex = 16 ' 'btnSave ' Me.btnSave.Location = New System.Drawing.Point(184, 216) Me.btnSave.TabIndex = 18 ' 'btnRead ' Me.btnRead.Location = New System.Drawing.Point(96, 216) Me.btnRead.TabIndex = 17 ' 'btnDelete ' Me.btnDelete.Location = New System.Drawing.Point(272, 216) Me.btnDelete.TabIndex = 19 ' 'btnItem ' Me.btnItem.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right) Me.btnItem.Location = New System.Drawing.Point(264, 184) Me.btnItem.Name = "btnItem" Me.btnItem.Size = New System.Drawing.Size(80, 23) Me.btnItem.TabIndex = 20 Me.btnItem.Text = "Project Items" ' 'txtMgrID ' Me.txtMgrID.Location = New System.Drawing.Point(96, 112) Me.txtMgrID.Name = "txtMgrID" Me.txtMgrID.Size = New System.Drawing.Size(64, 20) Me.txtMgrID.TabIndex = 9 Me.txtMgrID.Text = "" ' 'lblMgrID ' Me.lblMgrID.Location = New System.Drawing.Point(16, 104) Me.lblMgrID.Name = "lblMgrID" Me.lblMgrID.Size = New System.Drawing.Size(80, 23) Me.lblMgrID.TabIndex = 8 Me.lblMgrID.Text = "Project Manager ID:" Me.lblMgrID.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'txtDescription ' Me.txtDescription.Location = New System.Drawing.Point(96, 56) Me.txtDescription.Multiline = True Me.txtDescription.Name = "txtDescription" Me.txtDescription.Size = New System.Drawing.Size(168, 48) Me.txtDescription.TabIndex = 7 Me.txtDescription.Text = "" ' 'lblDescription ' Me.lblDescription.AutoSize = True Me.lblDescription.Location = New System.Drawing.Point(32, 56) Me.lblDescription.Name = "lblDescription" Me.lblDescription.Size = New System.Drawing.Size(64, 13) Me.lblDescription.TabIndex = 6 Me.lblDescription.Text = "Description:" ' 'dtpStart ' Me.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Short Me.dtpStart.Location = New System.Drawing.Point(96, 136) Me.dtpStart.Name = "dtpStart" Me.dtpStart.Size = New System.Drawing.Size(88, 20) Me.dtpStart.TabIndex = 11 Me.dtpStart.Value = New Date(2002, 1, 1, 0, 0, 0, 0) ' 'dtpEstEnd ' Me.dtpEstEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short Me.dtpEstEnd.Location = New System.Drawing.Point(96, 160) Me.dtpEstEnd.Name = "dtpEstEnd" Me.dtpEstEnd.Size = New System.Drawing.Size(88, 20) Me.dtpEstEnd.TabIndex = 13 Me.dtpEstEnd.Value = New Date(2002, 1, 1, 0, 0, 0, 0) ' 'dtpEnd ' Me.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short Me.dtpEnd.Location = New System.Drawing.Point(96, 184) Me.dtpEnd.Name = "dtpEnd" Me.dtpEnd.Size = New System.Drawing.Size(88, 20) Me.dtpEnd.TabIndex = 15 Me.dtpEnd.Value = New Date(2002, 1, 1, 0, 0, 0, 0) ' 'lblStart ' Me.lblStart.AutoSize = True Me.lblStart.Location = New System.Drawing.Point(38, 140) Me.lblStart.Name = "lblStart" Me.lblStart.Size = New System.Drawing.Size(58, 13) Me.lblStart.TabIndex = 10 Me.lblStart.Text = "Start Date:" Me.lblStart.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblEstEnd ' Me.lblEstEnd.AutoSize = True Me.lblEstEnd.Location = New System.Drawing.Point(19, 164) Me.lblEstEnd.Name = "lblEstEnd" Me.lblEstEnd.Size = New System.Drawing.Size(77, 13) Me.lblEstEnd.TabIndex = 12 Me.lblEstEnd.Text = "Est. End Date:" Me.lblEstEnd.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblEnd ' Me.lblEnd.AutoSize = True Me.lblEnd.Location = New System.Drawing.Point(42, 188) Me.lblEnd.Name = "lblEnd" Me.lblEnd.Size = New System.Drawing.Size(54, 13) Me.lblEnd.TabIndex = 14 Me.lblEnd.Text = "End Date:" Me.lblEnd.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblProduct ' Me.lblProduct.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblProduct.Location = New System.Drawing.Point(280, 8) Me.lblProduct.Name = "lblProduct" Me.lblProduct.Size = New System.Drawing.Size(56, 24) Me.lblProduct.TabIndex = 3 ' 'lblProdID ' Me.lblProdID.AutoSize = True Me.lblProdID.Location = New System.Drawing.Point(216, 8) Me.lblProdID.Name = "lblProdID" Me.lblProdID.Size = New System.Drawing.Size(61, 13) Me.lblProdID.TabIndex = 2 Me.lblProdID.Text = "Product ID:" ' 'frmProject ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(360, 253) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtName, Me.txtID, Me.lblName, Me.lblID, Me.lblProdID, Me.btnCreate, Me.btnDelete, Me.btnSave, Me.btnRead, Me.lblEnd, Me.lblEstEnd, Me.lblStart, Me.lblDescription, Me.lblProduct, Me.dtpEnd, Me.dtpEstEnd, Me.dtpStart, Me.btnItem, Me.txtMgrID, Me.lblMgrID, Me.txtDescription}) Me.Name = "frmProject" Me.Text = "Project Manager - Project" 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 Dim strProject As String intIdent = CInt(Me.txtID.Text) strProject = Trim(Me.txtName.Text) If intIdent <= 0 Then oProj = oProd.AddProject() ElseIf strProject.Length = 0 Then oProj = oProd.AddProject(intIdent) Else oProj = oProd.AddProject(intIdent, strProject) 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 oProj Is Nothing Then oProj.Read() Me.txtName.Text = oProj.Name Me.txtDescription.Text = oProj.Description Me.txtMgrID.Text = oProj.ManagerID Me.dtpStart.Value = oProj.StartDate Me.dtpEstEnd.Value = oProj.EstEndDate Me.dtpEnd.Value = oProj.EndDate End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click If Not oProj Is Nothing Then oProj.Name = Me.txtName.Text oProj.Description = Me.txtDescription.Text oProj.ManagerID = CInt(Val(Me.txtMgrID.Text)) oProj.StartDate = Me.dtpStart.Value oProj.EstEndDate = Me.dtpEstEnd.Value oProj.EndDate = Me.dtpEnd.Value oProj.Save() Me.txtID.Text = "" Me.txtName.Text = "" Me.txtDescription.Text = "" Me.txtMgrID.Text = "" Me.dtpStart.Value = Today Me.dtpEstEnd.Value = Today Me.dtpEnd.Value = Today 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 oProj Is Nothing Then oProj.Delete() oProj = Nothing Me.txtID.Text = "" Me.txtName.Text = "" Me.txtDescription.Text = "" Me.txtMgrID.Text = "" Me.dtpStart.Value = Today Me.dtpEstEnd.Value = Today Me.dtpEnd.Value = Today Me.btnCreate.Enabled = True Me.btnRead.Enabled = False Me.btnSave.Enabled = False Me.btnDelete.Enabled = False End If End Sub Private Sub btnItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItem.Click If Not oProj Is Nothing Then If oProj.ID > 0 Then oItemForm = New frmItem(oProj) oItemForm.Show() End If End If End Sub End Class