- Start Microsoft Visual Basic and create a new Windows Forms
Application named SolasPropertyRental1
- To add a new form to the application, in the Solution Explorer, right-click
SolasPropertyRental1 -> Add -> Windows Form...
- Set the Name to Tenants and click Add
- From the Toolbox, add a ListView to the form
- While the new list view is still selected, in the Properties window, click
the ellipsis button of the Columns field and create the columns as follows:
(Name) |
Text |
TextAlign |
Width |
colAccountNumber |
Account # |
|
65 |
colFullName |
Full Name |
|
120 |
colMaritalStatus |
Marital Status |
|
85 |
colPhoneNumber |
Phone # |
Center |
85 |
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
ListView |
|
lvwTenants |
Anchor: Top, Bottom, Left, Right
FullRowSelect: True
GridLines: True
View: Details |
Button |
New Tenant... |
btnNewTenant |
Anchor: Bottom, Right |
Button |
Close |
btnClose |
Anchor: Bottom, Right |
|
- Right-click the Tenants form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class Tenants
End Class
- Just above the End Class line, define a new procedure as follows:
Private Sub ShowTenants()
Dim Filename As String = "C:\Solas Property Rental\tenants.xml"
Dim docTenants As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
lvwTenants.Items.Clear()
docTenants.Load(Filename)
Dim TenantElement As XmlElement = docTenants.DocumentElement
Dim ListOfTenants As XmlNodeList = TenantElement.ChildNodes
For Each Node As XmlNode In ListOfTenants
Dim lviTenant As ListViewItem = New ListViewItem(Node.FirstChild.InnerText) ' Account Number
lviTenant.SubItems.Add(Node.FirstChild.NextSibling.InnerText) ' Full Name
lviTenant.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.InnerText) ' Phone Number
lviTenant.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.InnerText) ' Marital Status
lvwTenants.Items.Add(lviTenant)
Next
End If
End Sub
- In the Class Name combo box, select (Tenants Events)
- In the Method Name combo box, select Load and implement the event as follows:
Private Sub TenantsLoad(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles Me.Load
ShowTenants()
End Sub
- To add another form to the application, in the Solution Explorer, right-click
SolasPropertyRental1
-> Add ->
Windows Form...
- Set the Name to TenantEditor and click Add
- Design the form as follows:
|
Control |
Text |
Name |
Properties |
Label |
&Account #: |
|
|
MaskedTextBox |
|
txtAccountNumber |
Mask: 00-00-00
Modifiers: public |
Label |
&Full Name: |
|
|
TextBox |
|
txtFullName |
Modifiers: public |
Label |
Marital Status: |
|
|
ComboBox |
|
txtMaritalStatus |
Modifiers: public
Items:
Single
Widow
Married
Divorced
Separated |
Label |
&Phone #: |
|
|
MaskedTextBox |
|
txtPhoneNumber |
Mask: (999) 000-0000
Modifiers: public |
Button |
OK |
btnOK |
DialogResult: OK |
Button |
Cancel |
btnCancel |
DialogResult: Cancel |
Form |
|
|
AcceptButton: btnOK
CancelButton: btnCancel
FormBorderStyle: FixedDialog
MaximizeBox: False
MinimizeBox: False
ShowInTaskbar: False |
|
- To add a new form to the application, in the Solution Explorer, right- click
SolasPropertyRental4
-> Add ->
Windows Form...
- Set the Name to RentalProperties and press Enter
- From the Toolbox, add a ListView to the form
- While the new list view is still selected, in the Properties window, click
the ellipsis button of the Columns field and create the columns as follows:
(Name) |
Text |
TextAlign |
Width |
colPropertyCode |
Prop Code |
|
65 |
colPropertyType |
Property Type |
|
85 |
colBedrooms |
Bedrooms |
Right |
65 |
colBathrooms |
Bathrooms |
Right |
65 |
colMonthlyRent |
Monthly Rent |
Right |
75 |
colStatus |
Status |
|
65 |
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
ListView |
|
lvwProperties |
View: Details
GridLines: True
FullRowSelect: True
Anchor: Top, Bottom, Left, Right |
Button |
New Property... |
btnNewProperty |
Anchor: Bottom, Right |
Button |
Close |
btnClose |
Anchor: Bottom, Right |
|
- Right-click the Tenants form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class RentalProperties
End Class
- Just above the End Class line, define a new procedure as follows:
Private Sub ShowProperties()
Dim DOMProperties As XmlDocument = New XmlDocument
Dim Filename As String = "C:\Solas Property Rental\properties.xml"
If File.Exists(Filename) Then
lvwProperties.Items.Clear()
DOMProperties.Load(Filename)
Dim RootProperty As XmlElement = DOMProperties.DocumentElement
Dim ListOfProperties As XmlNodeList = RootProperty.ChildNodes
For Each Node As XmlNode In ListOfProperties
Dim lviProperty As ListViewItem = New ListViewItem(Node.FirstChild.InnerText) ' Property Code
lviProperty.SubItems.Add(Node.FirstChild.NextSibling.InnerText) ' Property Type
lviProperty.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.InnerText) ' Bedrooms
lviProperty.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.InnerText) ' Bathrooms
lviProperty.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Monthly Rent
lviProperty.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Status
lvwProperties.Items.Add(lviProperty)
Next
End If
End Sub
- In the Class Name combo box, select (RentalProperties Events)
- In the Method Name combo box, select Load and implement the event as follows:
Private Sub RentalPropertiesLoad(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles Me.Load
ShowProperties()
End Sub
- To add another form to the application, in the Solution Explorer, right-
click SolasPropertyRental1 -> Add -> Windows Form...
- Set the Name to PropertyEditor and click Add
- Design the form as follows:
|
Control |
Text |
Name |
Properties |
Label |
Property Code: |
|
|
MaskedTextBox |
|
txtPropertyCode |
Mask: 000-000
Modifiers: Public |
Button |
OK |
btnOK |
DialogResult: OK |
Label |
Property Type: |
|
|
ComboBox |
|
cbxPropertyTypes |
Modifiers: Public
Items: Unknown
Apartment
Townhouse
Single Family |
Button |
Cancel |
btnCancel |
DialogResult: Cancel |
Label |
Bedrooms: |
|
|
TextBox |
0 |
txtBedrooms |
TextAlign: Right
Modifiers: Public |
Label |
Bathrooms: |
|
|
TextBox |
0.00 |
txtBathrooms |
TextAlign: Right
Modifiers: Public |
Label |
Monthly Rent: |
|
|
TextBox |
0.00 |
txtMonthlyRent |
TextAlign: Right
Modifiers: Public |
Label |
Occupancy Status: |
|
|
ComboBox |
Unknown |
cbxStatus |
Modifiers: Public
Items:
Unknown
Available
Occupied
Needs Repair |
Form |
|
|
AcceptButton: btnOK
CancelButton: btnCancel
FormBorderStyle: FixedDialog
MaximizeBox: False
MinimizeBox: False
ShowInTaskbar: False |
|
- To add a new form to the application, in the Solution Explorer, right-click
SolasPropertyRental1 -> Add -> Windows Form...
- Set the Name to RentalAllocation and click Add
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
Label |
Rent Allocation |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
Label |
Allocation Code: |
|
|
MaskedTextBox |
|
txtAllocationCode |
Mask: 0000-9999
Modifiers: Public |
Label |
Date Allocated: |
|
|
DateTimePicker |
|
dtpDateAllocated |
Format: Short
Modifiers: Public |
Label |
Tenant |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
Label |
Property |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
|
|
|
|
Label |
Account #: |
|
|
MaskedTextBox |
|
txtTenantAcntNbr |
Mask: 00-00-00
Modifiers: Public |
Label |
Property #: |
|
|
MaskedTextBox |
|
txtPropertyCode |
Mask: 000-000
Modifiers: Public |
Label |
Tenant Name |
|
|
TextBox |
|
txtTenantName |
Modifiers: Public |
Label |
Property Type: |
|
|
TextBox |
|
txtPropertyType |
Modifiers: Public |
Label |
Marital Status: |
|
|
TextBox |
|
txtMaritalStatus |
Modifiers: Public |
Label |
Monthly Rent: |
|
|
TextBox |
|
txtMonthlyRent |
|
Label |
Allocation Evaluation |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
Label |
Contract Length: |
|
|
ComboBox |
|
cbxContractLength |
Items:
Monthly
3 Months
6 Months
12 Months
Modifiers: Public |
Label |
Rent Start Date: |
|
|
DateTimePicker |
|
dtpRentStartDate |
Modifiers: Public |
Button |
OK |
btnOK |
DialogResult: OK |
Button |
Close |
btnClose |
DialogResult: Cancel |
Form |
|
|
AcceptButton: btnOK
CancelButton: btnClose
FormBorderStyle: FixedDialog
MaximizeBox: False
MinimizeBox: False
ShowInTaskbar: False |
|
- Right-click the RentalAllocation form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class RentalAllocation
End Class
- In the Class Name combo box, select txtTenantAcntNbr
- In the Method Name combo box, select Leave and implement the event as follows:
Private Sub txtTenantAcntNbrLeave(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles txtTenantAcntNbr.Leave
Dim Filename As String = "C:\Solas Property Rental\tenants.xml"
Dim docTenants As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
docTenants.Load(Filename)
Dim TenantElement As XmlElement = docTenants.DocumentElement
Dim ListOfTenants As XmlNodeList = TenantElement.ChildNodes
Dim TenantFound As Boolean = False
For i = 0 To ListOfTenants.Count - 1
Dim Node As XmlNode = ListOfTenants(i)
If Node.FirstChild.InnerText = txtTenantAcntNbr.Text Then
TenantFound = True
txtTenantName.Text = Node.FirstChild.NextSibling.InnerText
txtMaritalStatus.Text = Node.FirstChild.NextSibling.NextSibling.InnerText
End If
Next
If TenantFound = False Then
MsgBox("There is no tenant with that account number")
txtTenantAcntNbr.Text = ""
End If
Else
MsgBox("There is no list of tenants to check.")
End If
End Sub
- In the Class Name combo box, select txtPropertyCode
- In the Method Name combo box, select Leave and implement the event as follows:
Private Sub txtPropertyCodeLeave(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles txtPropertyCode.Leave
Dim Filename As String = "C:\Solas Property Rental\properties.xml"
Dim DOMProperties As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
DOMProperties.Load(Filename)
Dim PropertyElement As XmlElement = DOMProperties.DocumentElement
Dim ListOfProperties As XmlNodeList = PropertyElement.ChildNodes
Dim PropertyFound As Boolean = False
For i = 0 To ListOfProperties.Count - 1
Dim Node As XmlNode = ListOfProperties(i)
If Node.FirstChild.InnerText = txtPropertyCode.Text Then
PropertyFound = True
txtPropertyType.Text = Node.FirstChild.NextSibling.InnerText
txtMonthlyRent.Text = Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
End If
Next
If PropertyFound = False Then
MsgBox("There is no Property with that code")
txtPropertyType.Text = ""
End If
Else
MsgBox("There is no list of properties to check.")
End If
End Sub
- To add a new form to the application, in the Solution Explorer, right-click
SolasPropertyRental1
-> Add ->
Windows Form...
- Set the Name to RentalAllocations and press Enter
- From the Toolbox, add a ListView to the form
- While the new list view is still selected, in the Properties window, click
the ellipsis button of the Columns field and create the columns as follows:
(Name) |
Text |
TextAlign |
Width |
colAllocationCode |
Alloc Code |
|
65 |
colDateAllocated |
Date Allocated |
Center |
85 |
colTenantAccount |
Tenant # |
Center |
65 |
colTenantName |
Tenant Name |
|
100 |
colPropertyCode |
Prop Code |
Center |
65 |
colPropertyType |
Prop Type |
|
75 |
colContractLength |
Contract Length |
|
88 |
colRentStartDate |
Rent Start Date |
Center |
88 |
colMonthlyRent |
Monthly Rent |
Right |
76 |
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
ListView |
|
lvwAllocations |
View: Details
GridLines: True
FullRowSelect: True
Anchor: Top, Bottom, Left, Right |
Button |
New Rental Allocation... |
btnNewAllocation |
Anchor: Bottom, Right |
Button |
Close |
btnClose |
|
|
- Right-click the Rental Allocations form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class RentalAllocations
End Class
- In the Class Name combo box, select txtTenantAcntNbr
- In the Method Name combo box, select Leave and implement the event as follows:
Private Sub ShowRentalAllocations()
Dim Filename As String = "C:\Solas Property Rental\contracts.xml"
Dim docAllocations As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
lvwAllocations.Items.Clear()
docAllocations.Load(Filename)
Dim AllocationElement As XmlElement = docAllocations.DocumentElement
Dim ListOfAllocations As XmlNodeList = AllocationElement.ChildNodes
For Each Node As XmlNode In ListOfAllocations
Dim lviAllocation As ListViewItem = New ListViewItem(Node.FirstChild.InnerText) ' Allocation Code
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.InnerText) ' Date Allocated
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.InnerText) ' Tenant Account Number
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.InnerText) ' Tenant Name
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Property Code
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Property Type
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Contract Length
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Rent Start Date
lviAllocation.SubItems.Add(Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Monthly Rent
lvwAllocations.Items.Add(lviAllocation)
Next
End If
End Sub
- In the Class Name combo box, select (RentalAllocations Events)
- In the Method Name combo box, select Load and implement the event as follows:
Private Sub RentalAllocationsLoad(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles Me.Load
ShowRentalAllocations()
End Sub
- To add a new form to the application, in the Solution Explorer, right-click
SolasPropertyRental4 -> Add -> Windows Form...
- Set the Name to RentPayment and click Add
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
Label |
Rent Allocation |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
Label |
Date Received: |
|
|
DateTimePicker |
|
dtpDateReceived |
Format: Short
Modifiers: Public |
Label |
Allocation Code: |
|
|
MaskedTextBox |
|
txtAllocationCode |
Mask: 0000-9999
Modifiers: Public |
Label |
Receipt #: |
|
|
TextBox |
|
txtReceiptNumber |
Modifiers: Public |
Label |
Tenant Account #: |
|
|
TextBox |
|
txtTenantAcntNber |
Modifiers: Public |
Label |
Property Code: |
|
|
TextBox |
|
txtPropertyCode |
Modifiers: Public |
Label |
Tenant Name: |
|
|
TextBox |
|
txtTenantName |
Modifiers: Public |
Label |
Property Type: |
|
|
TextBox |
|
txtPropertyType |
Modifiers: Public |
Label |
Payment Summary |
|
AutoSize: False
BackColor: Gray
BorderStyle: FixedSingle
ForeColor: White
TextAlign: MiddleLeft |
Label |
Month: |
|
|
Label |
Year: |
|
|
Label |
Payment For: |
|
|
ComboBox |
|
cbxMonths |
Modifiers: Public
Items:
January
February
March
April
May
June
July
August
September
October
November
December |
TextBox |
|
txtYear |
Modifiers: Public |
Label |
Amount Received: |
|
|
TextBox |
0.00 |
txtAmountReceived |
TextAlign: Right
Modifiers: Public |
Button |
OK |
btnOK |
DialogResult: OK |
Button |
Close |
btnClose |
DialogResult: Cancel |
Form |
|
|
AcceptButton: btnOK
CancelButton: btnClose
FormBorderStyle: FixedDialog
MaximizeBox: False
MinimizeBox: False
ShowInTaskbar: False |
|
- Right-click the Rent Payment form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class RentPayment
End Class
- In the Class Name combo box, select txtAllocationCode
- In the Method Name combo box, select Leave and implement the event as
follows:
Private Sub txtAllocationCodeLeave(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles txtAllocationCode.Leave
Dim Filename As String = "C:\Solas Property Rental\contracts.xml"
Dim docAllocations As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
docAllocations.Load(Filename)
Dim AllocationElement As XmlElement = docAllocations.DocumentElement
Dim ListOfAllocations As XmlNodeList = AllocationElement.ChildNodes
Dim ContractFound As Boolean = False
For i = 0 To ListOfAllocations.Count - 1
Dim Node As XmlNode = ListOfAllocations(i)
If Node.FirstChild.InnerText = txtAllocationCode.Text Then
ContractFound = True
txtTenantAcntNber.Text = Node.FirstChild.NextSibling.NextSibling.InnerText
txtTenantName.Text = Node.FirstChild.NextSibling.NextSibling.NextSibling.InnerText
txtPropertyCode.Text = Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtPropertyType.Text = Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtAmountReceived.Text = Node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
End If
Next
If ContractFound = False Then
MsgBox("There is no rental contract with that number")
txtTenantAcntNber.Text = ""
End If
Else
MsgBox("There is no list of rental contracts to check.")
End If
End Sub
- To add a new form to the application, in the Solution Explorer, right- click
SolasPropertyRental4
-> Add ->
Windows Form...
- Set the Name to RentPayments and press Enter
- From the Toolbox, add a ListView to the form
- While the new list view is still selected, in the Properties window, click
the ellipsis button of the Columns field and create the columns as follows:
(Name) |
Text |
TextAlign |
Width |
colReceiptNumber |
Receipt # |
Right |
|
colDateReceived |
Date Received |
Center |
85 |
colAllocationCode |
Alloc Code |
Center |
65 |
colTenantAccount |
Tenant # |
Center |
65 |
colTenantName |
Tenant Name |
|
100 |
colPropertyCode |
Prop Code |
Center |
65 |
colPropertyType |
Prop Type |
|
75 |
colPaymentFor |
Payment For |
|
88 |
colAmountReceived |
Amount |
Right |
50 |
- Design the form as follows:
|
Control |
Text |
Name |
Other Properties |
ListView |
|
lvwRentPayments |
View: Details
GridLines: True
FullRowSelect: True
Anchor: Top, Bottom, Left, Right |
Button |
New Rent Payment... |
btnNewPayment |
Anchor: Bottom, Right |
Button |
Close |
btnClose |
Anchor: Bottom, Right |
|
- Right-click the Rent Payments form and click View Code
- Import the System.IO and the System.Xml namespaces:
Imports System.IO
Imports System.Xml
Public Class RentPayments
End Class
- In the Class Name combo box, select txtTenantAcntNbr
- In the Method Name combo box, select Leave and implement the event as follows:
Private Sub ShowRentPayments()
Dim Filename As String = "C:\Solas Property Rental\payments.xml"
Dim DocumentPayments As XmlDocument = New XmlDocument
If File.Exists(Filename) Then
lvwRentPayments.Items.Clear()
DocumentPayments.Load(Filename)
Dim AllocationElement As XmlElement = DocumentPayments.DocumentElement
Dim ListOfAllocations As XmlNodeList = AllocationElement.ChildNodes
For Each Node As XmlNode In ListOfAllocations
Dim lviPayment As ListViewItem = New ListViewItem(node.FirstChild.InnerText) ' Receipt Number
lviPayment.SubItems.Add(node.FirstChild.NextSibling.InnerText) ' Date Received
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.InnerText) ' Allocation Code
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.InnerText) ' Tenant Account Number
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Tenant Name
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Property Code
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Property Type
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Payment For
lviPayment.SubItems.Add(node.FirstChild.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Amount
lvwRentPayments.Items.Add(lviPayment)
Next
End If
End Sub
- In the Class Name combo box, select (RentPayments.Events)
- In the Method Name combo box, select Load and implement the event as
follows:
Private Sub RentPaymentsLoad(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles Me.Load
ShowRentPayments()
End Sub
- In the Solution Explorer, right-click Form1.vb and click Rename
- Set the name to Central.vb and press Enter twice to display the
form
- Design the form as follows:
|
Control |
Text |
Name |
Button |
Tenants |
btnTenants |
Button |
Rental Properties |
btnRentalProperties |
Button |
Rental Allocations |
btnRentalAllocations |
Button |
C&lose |
btnClose |
|
- Right-click the form and click View Code
- In the Class Name combo box, select btnRentPayment
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnRentPaymentsClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnRentPayments.Click
Dim frmPayment As RentPayments = New RentPayments
frmPayment.Show()
nd Sub
- In the Class Name combo box, select btnRentalAllocations
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnRentalAllocationsClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnRentalAllocations.Click
Dim frmAllocations As RentalAllocations = New RentalAllocations
frmAllocations.ShowDialog()
End Sub
- In the Class Name combo box, select btnTenants
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnTenantsClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnTenants.Click
Dim frmTenants As Tenants = New Tenants
frmTenants.ShowDialog()
End Sub
- In the Class Name combo box, select btnRentalProperties
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnRentalPropertiesClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnRentalProperties.Click
Dim frmProperties As RentalProperties = New RentalProperties
frmProperties.ShowDialog()
End Sub
- In the Class Name combo box, select btnClose
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnClose.Click
End
End Sub
- Save all
- In the Solution Explorer, right-click Tenants.vb and click View Code
- In the Class Name combo box, select btnNewTenant
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnNewTenantClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnNewTenant.Click
Dim AccountNumber As String
Dim FullName As String
Dim MaritalStatus As String
Dim PhoneNumber As String
' If this directory doesn't exist, create it
Directory.CreateDirectory("C:\Solas Property Rental")
' This is the XML file that holds the list of tenants
Dim Filename As String = "C:\Solas Property Rental\tenants.xml"
' This is the dialog box from where a tenant is created
Dim editor As TenantEditor = New TenantEditor
' Display the Tenant Editor Dialog and find out if the
' user clicked OK after filling its controls
If editor.ShowDialog() = DialogResult.OK Then
' We will need a reference to the XML document
Dim DOMTenants As XmlDocument = New XmlDocument
' Find out if the file exists already
' If it doesn't, then create it
If Not File.Exists(Filename) Then
DOMTenants.LoadXml(
"<?xml version=""1.0"" encoding=""utf-8""?>" &
"<Tenants></Tenants>")
DOMTenants.Save(Filename)
End If
' At this time, we have a Tenants.xml file. Open it
DOMTenants.Load(Filename)
' Get a reference to the root node
Dim nodRoot As XmlElement = DOMTenants.DocumentElement
' Prepare the values of the XML element
AccountNumber = editor.txtAccountNumber.Text
FullName = editor.txtFullName.Text
MaritalStatus = editor.cbxMaritalStatus.Text
PhoneNumber = editor.txtPhoneNumber.Text
' Create an element named Tenant
Dim TenantElement As XmlElement =
DOMTenants.CreateElement("Tenant")
' Create the XML code of the child element of Tenant
Dim strTenant As String = "<AccountNumber>" & AccountNumber &
"</AccountNumber>" &
"<FullName>" + FullName &
"</FullName>" &
"<MaritalStatus>" & MaritalStatus &
"</MaritalStatus>" &
"<PhoneNumber>" & PhoneNumber &
"</PhoneNumber>"
TenantElement.InnerXml = strTenant
' Append the new element as a child of Tenant
DOMTenants.DocumentElement.AppendChild(TenantElement)
' Save the XML file
DOMTenants.Save("C:\Solas Property Rental\tenants.xml")
' Since the content of the XML file has just been changed,
' re-display the list of tenants
ShowTenants()
End If
End Sub
- In the Class Name combo box, select btnClose
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnClose.Click
Close()
End Sub
- In the Solution Explorer, right-click RentalProperties.vb and click View
Code
- In the Class Name combo box, select btnNewProperty
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnNewPropertyClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnNewProperty.Click
' If this directory doesn't exist, create it
Directory.CreateDirectory("C:\Solas Property Rental")
' This is the XML file that holds the list of proeprties
Dim Filename As String = "C:\Solas Property Rental\properties.xml"
Dim Editor As PropertyEditor = New PropertyEditor
Dim RandomNumber As Random = New Random
Editor.txtPropertyCode.Text = RandomNumber.Next(100000, 999999)
If Editor.ShowDialog() = DialogResult.OK Then
Dim PropertyCode As String
Dim PropertyType As String
Dim Status As String
Dim Bedrooms As Integer
Dim Bathrooms As Single
Dim MonthlyRent As Double
' We will need a reference to the XML document
Dim docProperty As XmlDocument = New XmlDocument
' Find out if the file exists already
' If it doesn't, then create it
If Not File.Exists(Filename) Then
docProperty.LoadXml(
"<?xml version=""1.0"" encoding=""utf-8""?>" &
"<Properties></Properties>")
docProperty.Save(Filename)
End If
' Open the XML file
docProperty.Load(Filename)
' Get a reference to the root node
Dim nodRoot As XmlElement = docProperty.DocumentElement
PropertyCode = Editor.txtPropertyCode.Text
PropertyType = Editor.cbxPropertyTypes.Text
Bedrooms = CInt(Editor.txtBedrooms.Text)
Bathrooms = CSng(Editor.txtBathrooms.Text)
MonthlyRent = Double.Parse(Editor.txtMonthlyRent.Text)
Status = Editor.cbxStatus.Text
Dim PropertyElement As XmlElement =
docProperty.CreateElement("Property")
Dim strNewCustomer As String = "<PropertyCode>" & PropertyCode &
"</PropertyCode>" & "<PropertyType>" &
PropertyType & "</PropertyType>" &
"<Bedrooms>" & Bedrooms + "</Bedrooms>" &
"<Bathrooms>" & FormatNumber(Bathrooms) &
"</Bathrooms>" & "<MonthlyRent>" &
FormatNumber(MonthlyRent) &
"</MonthlyRent>" &
"<Status>" & Status & "</Status>"
PropertyElement.InnerXml = strNewCustomer
docProperty.DocumentElement.AppendChild(PropertyElement)
docProperty.Save("C:\Solas Property Rental\properties.xml")
ShowProperties()
End If
End Sub
- In the Class Name combo box, select btnClose
- In the Method Name combo box, select Click and implement the event as follows:
Private Sub btnCloseClick(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles btnClose.Click
Close()
End Sub
- Execute the application
- Use the Tenants button and its New Tenant button to create the following Tenants:
Account # |
Full Name |
Marital Status |
Phone # |
20-48-46 |
Lenny Crandon |
Single |
(240) 975-9093 |
57-97-15 |
Joan Ramey |
Married |
(301) 304-5845 |
19-38-84 |
Peter Sellars |
Married |
(240) 801-7974 |
24-68-84 |
Alberta Sanson |
Separated |
(202) 917-0095 |
47-80-95 |
Urlus Flack |
Single |
(703) 203-7947 |
|
- Use the Rental Properties button and its New Property button to create the following properties:
Prop Code |
Property Types |
Bedrooms |
Bathrooms |
Monthly Rent |
Status |
527-992 |
Apartment |
1 |
1 |
925 |
Available |
726-454 |
Apartment |
2 |
1 |
1150.5 |
Available |
476-473 |
Single Family |
5 |
3.5 |
2250.85 |
Occupied |
625-936 |
Townhouse |
3 |
2.5 |
1750 |
Available |
179-738 |
Townhouse |
4 |
2.5 |
1920.5 |
Available |
727-768 |
Single Family |
4 |
2.5 |
2140.5 |
Needs Repair |
371-801 |
Apartment |
3 |
2 |
1250.25 |
Available |
241-536 |
Townhouse |
3 |
1.5 |
1650.5 |
Occupied |
|
|
- Close the forms and return to your programming environment