Public Class frmProduct Inherits PMFormClass.frmPM Dim oProd As ProjectManager.Product Dim oProjForm As frmProject #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) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents lblDescription As System.Windows.Forms.Label Friend WithEvents txtDescription As System.Windows.Forms.TextBox Friend WithEvents lblMgrID As System.Windows.Forms.Label Friend WithEvents txtMgrID As System.Windows.Forms.TextBox Friend WithEvents btnProject As System.Windows.Forms.Button '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.lblDescription = New System.Windows.Forms.Label() Me.txtDescription = New System.Windows.Forms.TextBox() Me.lblMgrID = New System.Windows.Forms.Label() Me.txtMgrID = New System.Windows.Forms.TextBox() Me.btnProject = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnCreate ' Me.btnCreate.Location = New System.Drawing.Point(8, 168) Me.btnCreate.TabIndex = 8 ' 'txtID ' Me.txtID.TabIndex = 1 ' 'btnSave ' Me.btnSave.Location = New System.Drawing.Point(184, 168) Me.btnSave.TabIndex = 10 ' 'lblName ' Me.lblName.TabIndex = 2 ' 'btnRead ' Me.btnRead.Location = New System.Drawing.Point(96, 168) Me.btnRead.TabIndex = 9 ' 'btnDelete ' Me.btnDelete.Location = New System.Drawing.Point(272, 168) Me.btnDelete.TabIndex = 11 ' '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 = 4 Me.lblDescription.Text = "Description:" ' '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 = 5 Me.txtDescription.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 = 6 Me.lblMgrID.Text = "Product Manager ID:" Me.lblMgrID.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' '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 = 7 Me.txtMgrID.Text = "" ' 'btnProject ' Me.btnProject.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right) Me.btnProject.Location = New System.Drawing.Point(272, 128) Me.btnProject.Name = "btnProject" Me.btnProject.TabIndex = 12 Me.btnProject.Text = "Projects" ' 'frmProduct ' 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.lblDescription, Me.btnProject, Me.txtMgrID, Me.lblMgrID, Me.txtDescription}) Me.Name = "frmProduct" Me.Text = "Project Manager - Product" 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 strProduct As String intIdent = CInt(Val(Me.txtID.Text)) strProduct = Trim(Me.txtName.Text) If intIdent <= 0 Then oProd = New ProjectManager.Product() ElseIf strProduct.Length = 0 Then oProd = New ProjectManager.Product(intIdent) Else oProd = New ProjectManager.Product(intIdent, strProduct) 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 oProd Is Nothing Then oProd.Read() Me.txtName.Text = oProd.Name Me.txtDescription.Text = oProd.Description Me.txtMgrID.Text = oProd.ManagerID End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click If Not oProd Is Nothing Then oProd.Name = Me.txtName.Text oProd.Description = Me.txtDescription.Text oProd.ManagerID = CInt(Val(Me.txtMgrID.Text)) oProd.Save() Me.txtID.Text = "" Me.txtName.Text = "" Me.txtDescription.Text = "" Me.txtMgrID.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 oProd Is Nothing Then oProd.Delete() oProd = Nothing Me.txtID.Text = "" Me.txtName.Text = "" Me.txtDescription.Text = "" Me.txtMgrID.Text = "" Me.btnCreate.Enabled = True Me.btnRead.Enabled = False Me.btnSave.Enabled = False Me.btnDelete.Enabled = False End If End Sub Private Sub btnProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProject.Click If Not oProd Is Nothing Then If oProd.ID > 0 Then oProjForm = New frmProject(oProd) oProjForm.Show() End If End If End Sub End Class