Professional Documents
Culture Documents
Watts A Loan (XML)
Watts A Loan (XML)
Watts A Loan (XML)
Data entry is probably the most important aspect of a database. Without data, there is
nothing to do with a database. In this application, we explore some of the details of
assisting a user with data entry. The various issues include unique values, data types, Page | 1
or default values, etc.
Watts A Loan is a fictitious company that lends money to individuals. The amounts
can be small to cover cash need or higher for car purchase. The money can be given
directly to a customer or through a store (furniture store or musical instrument store,
etc.).
ColumnName (Name)
DateAllocated colDateAllocated
LoanNumber colLoanNumber
PreparedBy colPreparedBy
PreparedFor colPreparedFor
Principal colPrincipal
InterestRate colInterestRate
Periods colPeriods
InterestEarned colInterestEarned
FutureValue colFutureValue
MonthlyPayment colMonthlyPayment
Page | 2
Practical Learning: Controlling the Uniqueness of a Column
Member DataType
DateAllocated System.DateTime
LoanNumber System.String
PreparedBy System.String
PreparedFor System.String
Principal System.Double
InterestRate System.Double
Periods System.Double
InterestEarned System.Double
FutureValue System.Double
MonthlyPayment System.Double
Member DefaultValue
Principal 0.00
InterestRate 8.75
Periods 36
Member Expression
InterestEarned Principal * (InterestRate / 100) * (Periods / 12)
FutureValue Principal + InterestEarned
MonthlyPayment FutureValue / Periods
Page | 5
End Class
Imports System.IO
If File.Exists(Filename) Then
dsEmployees.ReadXml(Filename)
End If
End Sub
End Class
21. In the Method Name combo box, select FormClosing and implement the event
as follows:
Private Sub EmployeesFormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs)
Handles Me.FormClosing
dsEmployees.WriteXml("employees.xml")
End Sub
(Name): dsCustomers
End Class
If File.Exists(Filename) Then
dsCustomers.ReadXml(Filename)
End If
End Sub
End Class
43. In the Method Name combo box, select FormClosing and implement the event
as follows:
Private Sub CustomersFormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs)
Handles Me.FormClosing
dsCustomers.WriteXml("customers.xml")
End Sub
45. 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 Page | 9
Close()
End Sub
DefaultCellStyle
DataPropertyName HeaderText Width
-> Format
Date Page | 10
DateAllocated Date Time
Allocated
LoanNumber Loan # 65
ColumnType:
DataGridViewComboBoxColumn
Prepared
PreparedBy 110 DataSource: dsEmployees
By
DisplayMember:
Employee.EmployeeNumber
ColumnType:
DataGridViewComboBoxColumn
Prepared
PreparedFor 110 DataSource: dsCustomers
For
DisplayMember:
Customer.AccountNumber
Principal 70 Currency
InterestRate Rate (%) 65 Numeric
Prd
Periods 65 Numeric
(Months)
Interest
InterestEarned Currency
Earned
Future
FutureValue Currency
Value
MonthlyPayment Pmt/Month Currency
Imports System.IO
End Class
If File.Exists(Filename) Then
dsEmployees.ReadXml(Filename) Page | 11
End If
Filename = "customers.xml"
If File.Exists(Filename) Then
dsCustomers.ReadXml(Filename)
End If
Filename = "loans.xml"
If File.Exists(Filename) Then
dsLoanAllocations.ReadXml(Filename)
End If
End Sub
55. In the Method Name combo box, select FormClosing and implement the event
as follows:
58. To create a new form, in the Solution Explorer, right-click WattsALoan1 ->
Add -> Windows Forms...
59. Set the Name to Payments and click Add
60. Display the Employees form
61. Right-click dsEmployees and click Copy
62. Display the Payments form
Page | 13
DefaultCellStyle
DataPropertyName HeaderText Width
-> Format
PaymentNumber Pmt # 55
PaymentDate Pmt Date 70 Date Time
ColumnType:
DataGridViewComboBoxColumn
Received
ReceivedBy DataSource: dsEmployees
By
DisplayMember:
Employee.EmployeeNumber
ColumnType:
DataGridViewComboBoxColumn
Payment
PaymentFor DataSource: dsLoanAllocations
For
DisplayMember:
Loan.LoanNumber
PaymentAmount Pmt Amt 70 Currency
Balance 80 Currency
Imports System.IO
Page | 14
Public Class Payments
End Class
If File.Exists(Filename) Then
dsEmployees.ReadXml(Filename)
End If
Filename = "loans.xml"
If File.Exists(Filename) Then
dsLoanAllocations.ReadXml(Filename)
End If
Filename = "payments.xml"
If File.Exists(Filename) Then
dsPayments.ReadXml(Filename)
End If
End Sub
81. In the Method Name combo box, select FormClosing and implement the event
as follows:
83. In the Method Name combo box, select Click and implement the event as
follows:
ByVal e As System.EventArgs)
Handles btnClose.Click
End
End Sub
End Class
Page | 17
91. Execute the application
92. Click the Employees label and create the following records:
93.
Page | 18
98.
Payment
Pmt # Pmt Date Received By Pmt Amt Balance
For
1001 10/25/06 2497-94 52-9739-5 268.58 9400.17
1002 11/30/06 2930-75 52-9739-5 268.58 9131.59
1003 12/24/2006 7973-45 20-5804-8 114.33 4001.42 Page | 19
1004 12/28/06 2497-94 52-9739-5 268.58 8863.01
1005 01/26/07 2497-94 20-5804-8 114.33 3887.09
1006 01/31/07 2930-75 52-9739-5 268.58 8594.43
1007 02/20/07 2497-94 20-5804-8 114.33 3772.76
1008 03/02/07 2930-75 52-9739-5 268.58 8325.85
1009 03/25/2007 2930-75 20-5804-8 114.33 3658.43
1010 04/25/07 7973-45 92-7495-4 416.25 19563.75
1011 04/28/07 2497-94 77-3907-2 693.47 40914.66
1012 04/28/07 7973-45 20-5804-8 114.33 3544.10
1013 05/01/07 7973-45 52-9739-5 268.58 8057.27
1014 05/26/07 2497-94 77-3907-2 693.47 40221.19