|
XML Example Application: FunDS (Fun Department Store) |
|
|
XML provide effective and wonderful means to create a
database repository. XML by itself doesn't create or save records. It only
defines how datashould be stored. On the other hand, another language, a
library, or a programming environment can be used to create, save, or maintain
data (for example, editing or deleting records).
|
We are going to create an example database application for a
department store. We will name the business as FunDS, which stands for Fun
Department Store.
Naturally, we need people who can run the business.
Practical
Learning: Introducing the Application
|
|
- Start a text editor such as Notepad and type the following:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class EmployeeNew
Inherits Form
Private lblEmployeeNumber As Label
Public txtEmployeeNumber As TextBox
Private lblFirstName As Label
Public txtFirstName As TextBox
Private lblLastName As Label
Public txtLastName As TextBox
Private lblAddress As Label
Public txtAddress As TextBox
Private lblCity As Label
Public txtCity As TextBox
Private lblCounty As Label
Public txtCounty As TextBox
Private lblState As Label
Public txtState As TextBox
Private lblZIPCode As Label
Public txtZIPCode As TextBox
Private lblMaritalStatus As Label
Public cbxMaritalsStatus As ComboBox
Private lblExemptions As Label
Public txtExemptions As TextBox
Private lblHourlySalary As Label
Public txtHourlySalary As TextBox
Private WithEvents btnOK As Button
Private WithEvents btnCancel As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Employee Number
lblEmployeeNumber = New Label()
lblEmployeeNumber.AutoSize = True
lblEmployeeNumber.Location = New System.Drawing.Point(13, 18)
lblEmployeeNumber.TabIndex = 0
lblEmployeeNumber.Text = "Employee #:"
Controls.Add(lblEmployeeNumber)
' Text Box: Employee Number
txtEmployeeNumber = New TextBox()
txtEmployeeNumber.Location = New System.Drawing.Point(94, 16)
txtEmployeeNumber.Size = New System.Drawing.Size(88, 20)
txtEmployeeNumber.TabIndex = 1
Controls.Add(txtEmployeeNumber)
' Label: First Name
lblFirstName = New Label()
lblFirstName.AutoSize = True
lblFirstName.Location = New System.Drawing.Point(13, 49)
lblFirstName.TabIndex = 2
lblFirstName.Text = "First Name:"
Controls.Add(lblFirstName)
' Text Box: First Name
txtFirstName = New TextBox()
txtFirstName.Location = New System.Drawing.Point(94, 46)
txtFirstName.Size = New System.Drawing.Size(88, 20)
txtFirstName.TabIndex = 3
Controls.Add(txtFirstName)
' Label: Last Name
lblLastName = New Label()
lblLastName.AutoSize = True
lblLastName.Location = New System.Drawing.Point(195, 49)
lblLastName.TabIndex = 4
lblLastName.Text = "Last Name:"
Controls.Add(lblLastName)
' Text Box: Last Name
txtLastName = New TextBox()
txtLastName.Location = New System.Drawing.Point(276, 46)
txtLastName.Size = New System.Drawing.Size(88, 20)
txtLastName.TabIndex = 5
Controls.Add(txtLastName)
' Label: Address
lblAddress = New Label()
lblAddress.AutoSize = True
lblAddress.Location = New System.Drawing.Point(13, 75)
lblAddress.TabIndex = 6
lblAddress.Text = "Address:"
Controls.Add(lblAddress)
' Text Box: Address
txtAddress = New TextBox()
txtAddress.Location = New System.Drawing.Point(94, 72)
txtAddress.Size = New System.Drawing.Size(270, 20)
txtAddress.TabIndex = 7
Controls.Add(txtAddress)
' Label: City
lblCity = New Label()
lblCity.AutoSize = True
lblCity.Location = New System.Drawing.Point(13, 101)
lblCity.TabIndex = 8
lblCity.Text = "City:"
Controls.Add(lblCity)
' Text Box: City
txtCity = New TextBox()
txtCity.Location = New System.Drawing.Point(94, 98)
txtCity.Size = New System.Drawing.Size(270, 20)
txtCity.TabIndex = 9
Controls.Add(txtCity)
' Label: County
lblCounty = New Label()
lblCounty.AutoSize = True
lblCounty.Location = New System.Drawing.Point(13, 127)
lblCounty.TabIndex = 10
lblCounty.Text = "County:"
Controls.Add(lblCounty)
' Text Box: County
txtCounty = New TextBox()
txtCounty.Location = New System.Drawing.Point(94, 124)
txtCounty.Size = New System.Drawing.Size(88, 20)
txtCounty.TabIndex = 11
Controls.Add(txtCounty)
' Label: State
lblState = New Label()
lblState.AutoSize = True
lblState.Location = New System.Drawing.Point(195, 127)
lblState.TabIndex = 12
lblState.Text = "State:"
Controls.Add(lblState)
' Text Box: State
txtState = New TextBox()
txtState.Location = New System.Drawing.Point(276, 124)
txtState.Size = New System.Drawing.Size(88, 20)
txtState.TabIndex = 13
Controls.Add(txtState)
' Label: ZIP Code
lblZIPCode = New Label()
lblZIPCode.AutoSize = True
lblZIPCode.Location = New System.Drawing.Point(13, 153)
lblZIPCode.TabIndex = 14
lblZIPCode.Text = "ZIP Code:"
Controls.Add(lblZIPCode)
' Text Box: ZIP Code
txtZIPCode = New TextBox()
txtZIPCode.Location = New System.Drawing.Point(94, 150)
txtZIPCode.Size = New System.Drawing.Size(88, 20)
txtZIPCode.TabIndex = 15
Controls.Add(txtZIPCode)
' Label: Marital Status
lblMaritalStatus = New Label()
lblMaritalStatus.AutoSize = True
lblMaritalStatus.Location = New System.Drawing.Point(195, 153)
lblMaritalStatus.TabIndex = 16
lblMaritalStatus.Text = "Marital Status:"
Controls.Add(lblMaritalStatus)
' Combo Box: Maritals Status
cbxMaritalsStatus = New ComboBox()
cbxMaritalsStatus.Items.AddRange(New Object() {"Single", "Married"})
cbxMaritalsStatus.Location = New System.Drawing.Point(276, 150)
cbxMaritalsStatus.Size = New System.Drawing.Size(88, 21)
cbxMaritalsStatus.TabIndex = 17
Controls.Add(cbxMaritalsStatus)
' Label: Exemptions
lblExemptions = New Label()
lblExemptions.AutoSize = True
lblExemptions.Location = New System.Drawing.Point(13, 179)
lblExemptions.TabIndex = 18
lblExemptions.Text = "Exemptions:"
Controls.Add(lblExemptions)
' Text Box: Exemptions
txtExemptions = New TextBox()
txtExemptions.Location = New System.Drawing.Point(94, 176)
txtExemptions.Size = New System.Drawing.Size(88, 20)
txtExemptions.TabIndex = 19
txtExemptions.Text = "0"
txtExemptions.TextAlign = HorizontalAlignment.Right
Controls.Add(txtExemptions)
' Label: Hourly Salary
lblHourlySalary = New Label()
lblHourlySalary.AutoSize = True
lblHourlySalary.Location = New System.Drawing.Point(195, 180)
lblHourlySalary.TabIndex = 20
lblHourlySalary.Text = "Hourly Salary:"
Controls.Add(lblHourlySalary)
' Text Box: Hourly Salary
txtHourlySalary = New TextBox()
txtHourlySalary.Location = New System.Drawing.Point(276, 177)
txtHourlySalary.Size = New System.Drawing.Size(88, 20)
txtHourlySalary.TabIndex = 21
Controls.Add(txtHourlySalary)
' Button: OK
btnOK = New Button()
btnOK.DialogResult = DialogResult.OK
btnOK.Location = New System.Drawing.Point(202, 220)
btnOK.Size = New System.Drawing.Size(75, 23)
btnOK.TabIndex = 22
btnOK.Text = "OK"
Controls.Add(btnOK)
' Button: Cancel
btnCancel = New Button()
btnCancel.DialogResult = DialogResult.Cancel
btnCancel.Location = New System.Drawing.Point(288, 220)
btnCancel.Size = New System.Drawing.Size(75, 23)
btnCancel.TabIndex = 23
btnCancel.Text = "Cancel"
Controls.Add(btnCancel)
' Form: New Employee
AcceptButton = btnOK
CancelButton = btnCancel
ClientSize = New System.Drawing.Size(388, 260)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
StartPosition = FormStartPosition.CenterScreen
Text = "Fun Department Store - New Employee"
End Sub
End Class
- To save and start a new file, on the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top combo box, select and display the C: drive
- Click the New Folder button
- Type FunDS1 and press Enter twice to display it in the top combo
box
- Change the Save As Type combo box to All Files
- Set the File Name to EmployeeNew.vb
- Click Save
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class EmployeeEditor
Inherits Form
Private lblEmployeeNumber As Label
Public txtEmployeeNumber As TextBox
Private WithEvents btnFind As Button
Private lblFirstName As Label
Public txtFirstName As TextBox
Private lblLastName As Label
Public txtLastName As TextBox
Private lblAddress As Label
Public txtAddress As TextBox
Private lblCity As Label
Public txtCity As TextBox
Private lblCounty As Label
Public txtCounty As TextBox
Private lblState As Label
Public txtState As TextBox
Private lblZIPCode As Label
Public txtZIPCode As TextBox
Private lblMaritalStatus As Label
Public cbxMaritalsStatus As ComboBox
Private lblExemptions As Label
Public txtExemptions As TextBox
Private lblHourlySalary As Label
Public txtHourlySalary As TextBox
Private WithEvents btnSubmit As Button
Private WithEvents btnClose As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Employee Number
lblEmployeeNumber = New Label()
lblEmployeeNumber.AutoSize = True
lblEmployeeNumber.Location = New System.Drawing.Point(13, 18)
lblEmployeeNumber.TabIndex = 0
lblEmployeeNumber.Text = "Employee #:"
Controls.Add(lblEmployeeNumber)
' Text Box: Employee Number
txtEmployeeNumber = New TextBox()
txtEmployeeNumber.Location = New System.Drawing.Point(94, 16)
txtEmployeeNumber.Size = New System.Drawing.Size(88, 20)
txtEmployeeNumber.TabIndex = 1
Controls.Add(txtEmployeeNumber)
' Button: Find
btnFind = New Button()
btnFind.Location = New System.Drawing.Point(201, 18)
btnFind.Size = New System.Drawing.Size(75, 23)
btnFind.TabIndex = 2
btnFind.Text = "Find"
Controls.Add(btnFind)
' Label: First Name
lblFirstName = New Label()
lblFirstName.AutoSize = True
lblFirstName.Location = New System.Drawing.Point(13, 49)
lblFirstName.TabIndex = 5
lblFirstName.Text = "First Name:"
Controls.Add(lblFirstName)
' Text Box: First Name
txtFirstName = New TextBox()
txtFirstName.Location = New System.Drawing.Point(94, 46)
txtFirstName.Size = New System.Drawing.Size(88, 20)
txtFirstName.TabIndex = 6
Controls.Add(txtFirstName)
' Label: Last Name
lblLastName = New Label()
lblLastName.AutoSize = True
lblLastName.Location = New System.Drawing.Point(195, 49)
lblLastName.TabIndex = 7
lblLastName.Text = "Last Name:"
Controls.Add(lblLastName)
' Text Box: Last Name
txtLastName = New TextBox()
txtLastName.Location = New System.Drawing.Point(276, 46)
txtLastName.Size = New System.Drawing.Size(88, 20)
txtLastName.TabIndex = 8
Controls.Add(txtLastName)
' Label: Address
lblAddress = New Label()
lblAddress.AutoSize = True
lblAddress.Location = New System.Drawing.Point(13, 75)
lblAddress.TabIndex = 9
lblAddress.Text = "Address:"
Controls.Add(lblAddress)
' Text Box: Address
txtAddress = New TextBox()
txtAddress.Location = New System.Drawing.Point(94, 72)
txtAddress.Size = New System.Drawing.Size(270, 20)
txtAddress.TabIndex = 10
Controls.Add(txtAddress)
' Label: City
lblCity = New Label()
lblCity.AutoSize = True
lblCity.Location = New System.Drawing.Point(13, 101)
lblCity.TabIndex = 11
lblCity.Text = "City:"
Controls.Add(lblCity)
' Text Box: City
txtCity = New TextBox()
txtCity.Location = New System.Drawing.Point(94, 98)
txtCity.Size = New System.Drawing.Size(270, 20)
txtCity.TabIndex = 12
Controls.Add(txtCity)
' Label: County
lblCounty = New Label()
lblCounty.AutoSize = True
lblCounty.Location = New System.Drawing.Point(13, 127)
lblCounty.TabIndex = 13
lblCounty.Text = "County:"
Controls.Add(lblCounty)
' Text Box: County
txtCounty = New TextBox()
txtCounty.Location = New System.Drawing.Point(94, 124)
txtCounty.Size = New System.Drawing.Size(88, 20)
txtCounty.TabIndex = 14
Controls.Add(txtCounty)
' Label: State
lblState = New Label()
lblState.AutoSize = True
lblState.Location = New System.Drawing.Point(195, 127)
lblState.TabIndex = 15
lblState.Text = "State:"
Controls.Add(lblState)
' Text Box: State
txtState = New TextBox()
txtState.Location = New System.Drawing.Point(276, 124)
txtState.Size = New System.Drawing.Size(88, 20)
txtState.TabIndex = 16
Controls.Add(txtState)
' Label: ZIP Code
lblZIPCode = New Label()
lblZIPCode.AutoSize = True
lblZIPCode.Location = New System.Drawing.Point(13, 153)
lblZIPCode.TabIndex = 17
lblZIPCode.Text = "ZIP Code:"
Controls.Add(lblZIPCode)
' Text Box: ZIP Code
txtZIPCode = New TextBox()
txtZIPCode.Location = New System.Drawing.Point(94, 150)
txtZIPCode.Size = New System.Drawing.Size(88, 20)
txtZIPCode.TabIndex = 18
Controls.Add(txtZIPCode)
' Label: Marital Status
lblMaritalStatus = New Label()
lblMaritalStatus.AutoSize = True
lblMaritalStatus.Location = New System.Drawing.Point(195, 153)
lblMaritalStatus.TabIndex = 19
lblMaritalStatus.Text = "Marital Status:"
Controls.Add(lblMaritalStatus)
' Combo Box: MaritalsStatus
cbxMaritalsStatus = New ComboBox()
cbxMaritalsStatus.Items.AddRange(New Object() {"Single", "Married"})
cbxMaritalsStatus.Location = New System.Drawing.Point(276, 150)
cbxMaritalsStatus.Size = New System.Drawing.Size(88, 21)
cbxMaritalsStatus.TabIndex = 20
Controls.Add(cbxMaritalsStatus)
' Label: Exemptions
lblExemptions = New Label()
lblExemptions.AutoSize = True
lblExemptions.Location = New System.Drawing.Point(13, 179)
lblExemptions.TabIndex = 21
lblExemptions.Text = "Exemptions:"
Controls.Add(lblExemptions)
' Text Box: Exemptions
txtExemptions = New TextBox()
txtExemptions.Location = New System.Drawing.Point(94, 176)
txtExemptions.Size = New System.Drawing.Size(88, 20)
txtExemptions.TabIndex = 22
txtExemptions.Text = "0"
txtExemptions.TextAlign = HorizontalAlignment.Right
Controls.Add(txtExemptions)
' Label: Hourly Salary
lblHourlySalary = New Label()
lblHourlySalary.AutoSize = True
lblHourlySalary.Location = New System.Drawing.Point(195, 180)
lblHourlySalary.TabIndex = 23
lblHourlySalary.Text = "Hourly Salary:"
Controls.Add(lblHourlySalary)
' Text Box: Hourly Salary
txtHourlySalary = New TextBox()
txtHourlySalary.Location = New System.Drawing.Point(276, 177)
txtHourlySalary.Size = New System.Drawing.Size(88, 20)
txtHourlySalary.TabIndex = 24
Controls.Add(txtHourlySalary)
' Button: Submit
btnSubmit = New Button()
btnSubmit.Location = New System.Drawing.Point(207, 218)
btnSubmit.Size = New System.Drawing.Size(84, 23)
btnSubmit.TabIndex = 3
btnSubmit.Text = "Submit"
Controls.Add(btnSubmit)
' Button: Close
btnClose = New Button()
btnClose.Location = New System.Drawing.Point(297, 218)
btnClose.Size = New System.Drawing.Size(75, 23)
btnClose.TabIndex = 4
btnClose.Text = "Close"
Controls.Add(btnClose)
' Form: Employee Editor
ClientSize = New System.Drawing.Size(394, 259)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
StartPosition = FormStartPosition.CenterScreen
Text = "Fun Department Store: Employee Editor"
End Sub
Private Sub btnFindClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnFind.Click
Dim employeeFound As Boolean = False
Dim xdEmployees As XmlDocument = New XmlDocument()
Dim strEmployeesFile As String = "C:\Fun Department Store1\Employees.xml"
If String.IsNullOrEmpty(txtEmployeeNumber.Text) Then
MsgBox("You must enter an employee number.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strEmployeesFile) Then
Using fsEmployees As FileStream = New FileStream(strEmployeesFile, FileMode.Open, FileAccess.Read)
xdEmployees.Load(fsEmployees)
Dim xnlEmployees As XmlNodeList = xdEmployees.GetElementsByTagName("EmployeeNumber")
For Each xnEmployee As XmlNode In xnlEmployees
If xnEmployee.InnerText = txtEmployeeNumber.Text Then
txtFirstName.Text = xnEmployee.NextSibling.InnerText ' First Name
txtLastName.Text = xnEmployee.NextSibling.NextSibling.InnerText ' Last Name
txtAddress.Text = xnEmployee.NextSibling.NextSibling.NextSibling.InnerText ' Address
txtCity.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' City
txtCounty.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' County
txtState.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' State
txtZIPCode.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' ZIP Code
cbxMaritalsStatus.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Marital Status
txtExemptions.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Exemptions
txtHourlySalary.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Hourly Salary
employeeFound = True
End If
Next
If employeeFound = False Then
MsgBox("There is no staff member with that employee number.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
End If
End Using
End If
End Sub
Private Sub btnSubmitClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Dim xdEmployees As XmlDocument = New XmlDocument()
Dim strEmployeesFile As String = "C:\Fun Department Store1\Employees.xml"
If String.IsNullOrEmpty(txtEmployeeNumber.Text) Then
MsgBox("You must enter an employee number.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strEmployeesFile) Then
Using fsEmployees As FileStream = New FileStream(strEmployeesFile, FileMode.Open, FileAccess.Read)
xdEmployees.Load(fsEmployees)
Dim xnlEmployees As XmlNodeList = xdEmployees.GetElementsByTagName("EmployeeNumber")
For Each xnEmployee As XmlNode In xnlEmployees
If xnEmployee.InnerText = txtEmployeeNumber.Text Then
xnEmployee.ParentNode.InnerXml = "<EmployeeNumber>" & txtEmployeeNumber.Text & "</EmployeeNumber>" &
"<FirstName>" & txtFirstName.Text & "</FirstName>" &
"<LastName>" & txtLastName.Text & "</LastName>" &
"<Address>" & txtAddress.Text & "</Address>" &
"<City>" & txtCity.Text & "</City>" &
"<County>" & txtCounty.Text & "</County>" &
"<State>" & txtState.Text & "</State>" &
"<ZIPCode>" & txtZIPCode.Text & "</ZIPCode>" &
"<MaritalStatus>" & cbxMaritalsStatus.Text & "</MaritalStatus>" &
"<Exemptions>" & txtExemptions.Text & "</Exemptions>" &
"<HourlySalary>" & txtHourlySalary.Text & "</HourlySalary>"
Exit For
End If
Next
End Using
Using fsEmployees As FileStream = New FileStream(strEmployeesFile, FileMode.Create, FileAccess.Write)
xdEmployees.Save(fsEmployees)
MsgBox("The employee's record has been updated.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
End Using
End If
Close()
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
End Class
- To save and start a new filew, on the main menu, click File -> New
- When asked whether you want to save, click Save
- Make sure the FunDS1 folder is displaying in the top combo box. Set the Save
As Type combo box to All Files
- Set the File Name to EmployeeEditor.vb
- Click Save
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class Employees
Inherits Form
Private colEmployeeNumber As ColumnHeader
Private colFirstName As ColumnHeader
Private colLastName As ColumnHeader
Private colAddress As ColumnHeader
Private colCity As ColumnHeader
Private colCounty As ColumnHeader
Private colState As ColumnHeader
Private colZIPCode As ColumnHeader
Private colMaritalStatus As ColumnHeader
Private colExemptions As ColumnHeader
Private colHourlySalary As ColumnHeader
Private WithEvents lvwEmployees As ListView
Private lblNumberOfEmployees As Label
Private txtNumberOfEmployees As TextBox
Private WithEvents btnNewEmployee As Button
Private WithEvents btnClose As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Column: Employee Number
colEmployeeNumber = New ColumnHeader()
colEmployeeNumber.Text = "Employee #"
colEmployeeNumber.Width = 70
' Column: First Name
colFirstName = New ColumnHeader()
colFirstName.Text = "First Name"
colFirstName.Width = 65
' Column: Last Name
colLastName = New ColumnHeader()
colLastName.Text = "Last Name"
colLastName.Width = 70
' Column: Address
colAddress = New ColumnHeader()
colAddress.Text = "Address"
colAddress.Width = 125
' Column: City
colCity = New ColumnHeader()
colCity.Text = "City"
colCity.Width = 75
' Column: Username
colCounty = New ColumnHeader()
colCounty.Text = "County"
' Column: State
colState = New ColumnHeader()
colState.Text = "State"
colState.Width = 40
' Column: ZIP Code
colZIPCode = New ColumnHeader()
colZIPCode.Text = "ZIP Code"
' Column: Marital Status
colMaritalStatus = New ColumnHeader()
colMaritalStatus.Text = "Marital Status"
colMaritalStatus.Width = 80
' Column: Exemptions
colExemptions = New ColumnHeader()
colExemptions.Text = "Exemptions"
colExemptions.TextAlign = HorizontalAlignment.Right
colExemptions.Width = 70
' Column: Hourly Salary
colHourlySalary = New ColumnHeader()
colHourlySalary.Text = "Salary"
colHourlySalary.TextAlign = HorizontalAlignment.Right
colHourlySalary.Width = 45
' List View: Employees
lvwEmployees = New ListView()
lvwEmployees.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
lvwEmployees.Columns.AddRange(new ColumnHeader() {
colEmployeeNumber, colFirstName, colLastName,
colAddress, colCity, colCounty, colState, colZIPCode,
colMaritalStatus, colExemptions, colHourlySalary })
lvwEmployees.FullRowSelect = True
lvwEmployees.GridLines = True
lvwEmployees.Location = New System.Drawing.Point(16, 12)
lvwEmployees.Size = New System.Drawing.Size(785, 125)
lvwEmployees.View = View.Details
' Label: NumberOfEmployees
lblNumberOfEmployees = New Label()
lblNumberOfEmployees.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
lblNumberOfEmployees.AutoSize = True
lblNumberOfEmployees.Location = New Point(12, 158)
lblNumberOfEmployees.Size = New System.Drawing.Size(113, 13)
lblNumberOfEmployees.Text = "Number of Employees:"
' Text Box: NumberOfEmployees
txtNumberOfEmployees = New TextBox()
txtNumberOfEmployees.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
txtNumberOfEmployees.Location = New Point(131, 155)
txtNumberOfEmployees.Size = New System.Drawing.Size(60, 20)
txtNumberOfEmployees.TextAlign = HorizontalAlignment.Right
' Button: NewEmployee
btnNewEmployee = New Button()
btnNewEmployee.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
btnNewEmployee.Location = New Point(564, 153)
btnNewEmployee.Size = New System.Drawing.Size(109, 23)
btnNewEmployee.Text = "New Employee ..."
' Button: Close
btnClose = New Button()
btnClose.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
btnClose.Location = New Point(679, 153)
btnClose.Size = New System.Drawing.Size(75, 23)
btnClose.Text = "Close"
' Form: Employees
ClientSize = New System.Drawing.Size(820, 185)
Controls.Add(lvwEmployees)
Controls.Add(txtNumberOfEmployees)
Controls.Add(lblNumberOfEmployees)
Controls.Add(btnNewEmployee)
Controls.Add(btnClose)
MaximizeBox = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - Employees"
End Sub
Private Sub ShowEmployees()
Dim xdEmployees As XmlDocument = New XmlDocument()
Dim strEmployeesFile As String = "C:\Fun Department Store1\Employees.xml"
If File.Exists(strEmployeesFile) Then
lvwEmployees.Items.Clear()
Using fsEmployees As FileStream = New FileStream(strEmployeesFile, FileMode.Open, FileAccess.Read)
xdEmployees.Load(fsEmployees)
Dim xnlEmployees As XmlNodeList = xdEmployees.GetElementsByTagName("EmployeeNumber")
For Each xnEmployee As XmlNode In xnlEmployees
Dim lviEmployee As ListViewItem = New ListViewItem(xnEmployee.InnerText) ' Employee Number
lviEmployee.SubItems.Add(xnEmployee.NextSibling.InnerText) ' First Name
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.InnerText) ' Last Name
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.InnerText) ' Address
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' City
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' County
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' State
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' ZIP Code
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Marital Status
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Exemptions
lviEmployee.SubItems.Add(xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText) ' Hourly Salary
lvwEmployees.Items.Add(lviEmployee)
Next
txtNumberOfEmployees.Text = xnlEmployees.Count.ToString()
End Using
End If
End Sub
Private Sub EmployeesLoad(ByVal sender As Object, ByVal e As EventArgs) Handles me.Load
ShowEmployees()
End Sub
Private Sub btnNewEmployeeClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewEmployee.Click
Dim strEmployeeNumber As String
Dim strFirstName As String
Dim strLastName As String
Dim strCounty As String
Dim strAddress As String
Dim strCity As String
Dim strState As String
Dim strZIPCode As String
Dim strMaritalStatus As String
Dim iExemptions As Integer
Dim dblHourlySalary As Double
Dim en As EmployeeNew = New EmployeeNew()
Dim rndEmployeeNumber As Random = New Random()
Dim xdEmployees As XmlDocument = New XmlDocument()
Dim strEmployeesFile As String = "C:\Fun Department Store1\Employees.xml"
en.txtEmployeeNumber.Text = CStr(rndEmployeeNumber.Next(100000, 999999))
If en.ShowDialog() = DialogResult.OK Then
strEmployeeNumber = en.txtEmployeeNumber.Text
strFirstName = en.txtFirstName.Text
strLastName = en.txtLastName.Text
strMaritalStatus = en.cbxMaritalsStatus.Text
iExemptions = CInt(en.txtExemptions.Text)
strAddress = en.txtAddress.Text
strCity = en.txtCity.Text
strCounty = en.txtCounty.Text
strState = en.txtState.Text
strZIPCode = en.txtZIPCode.Text
dblHourlySalary = CDbl(en.txtHourlySalary.Text)
If Not File.Exists(strEmployeesFile) Then
xdEmployees.LoadXml("<?xml version=""1.0"" encoding=""utf-8""?>" &
"<Employees></Employees>")
xdEmployees.Save(strEmployeesFile)
End If
xdEmployees.Load(strEmployeesFile)
Dim elmXML As XmlElement = xdEmployees.CreateElement("Employee")
' Create the XML code of the child element of Employee
dim strNewEmployee as string= "<EmployeeNumber>" & strEmployeeNumber & "</EmployeeNumber>" &
"<FirstName>" & strFirstName & "</FirstName>" &
"<LastName>" & strLastName & "</LastName>" &
"<Address>" & strAddress & "</Address>" &
"<City>" & strCity & "</City>" &
"<County>" & strCounty & "</County>" &
"<State>" & strState & "</State>" &
"<ZIPCode>" & strZIPCode & "</ZIPCode>" &
"<MaritalStatus>" & strMaritalStatus & "</MaritalStatus>" &
"<Exemptions>" & iExemptions & "</Exemptions>" &
"<HourlySalary>" & dblHourlySalary & "</HourlySalary>"
elmXML.InnerXml = strNewEmployee
' Append the new element as a child of employees
xdEmployees.DocumentElement.AppendChild(elmXML)
' Save the XML file
xdEmployees.Save(strEmployeesFile)
ShowEmployees()
End If
End Sub
Private Sub lvwEmployeesDoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles lvwEmployees.DoubleClick
Dim ee As EmployeeEditor = New EmployeeEditor()
Dim xdEmployees As XmlDocument = New XmlDocument()
Dim strEmployeesFile As String = "C:\Fun Department Store1\Employees.xml"
If lvwEmployees.Items.Count <= 0 Then
Exit Sub
End If
Using fsEmployees As FileStream = New FileStream(strEmployeesFile, FileMode.Open, FileAccess.Read)
xdEmployees.Load(fsEmployees)
Dim xnlEmployees As XmlNodeList = xdEmployees.GetElementsByTagName("EmployeeNumber")
For Each xnEmployee As XmlNode In xnlEmployees
If xnEmployee.InnerText = lvwEmployees.SelectedItems(0).Text Then
ee.txtEmployeeNumber.Text = xnEmployee.InnerText '
ee.txtFirstName.Text = xnEmployee.NextSibling.InnerText ' First Name
ee.txtLastName.Text = xnEmployee.NextSibling.NextSibling.InnerText ' Last Name
ee.txtAddress.Text = xnEmployee.NextSibling.NextSibling.NextSibling.InnerText ' Address
ee.txtCity.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' City
ee.txtCounty.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' County
ee.txtState.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' State
ee.txtZIPCode.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' ZIP Code
ee.cbxMaritalsStatus.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Marital Status
ee.txtExemptions.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Exemptions
ee.txtHourlySalary.Text = xnEmployee.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText ' Hourly Salary
End If
Next
End Using
ee.ShowDialog()
ShowEmployees()
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
End Class
- To save, on the main menu, click File -> New
- When asked whether you want to save, click Save
- Make sure the FunDS1 folder is displaying in the top combo box and
change the Save As Type to All Files
- Set the File Name to Employees.vb
- Click Save
Items (such as clothing, jewelry, and accessories, etc) are
the basis of the business. For our database, the three most important pieces of
information about each item are the item number (which must be unique for each
item), a name or short description, and a price. Other pieces of information we
will consider for some items are the manufacturer, the category, and the
subcategory. We will also apply a discount rate to some items.
Practical
Learning: Creating Store Items
|
|
- In the empty document, type the following:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class Manufacturer
Inherits Form
Private lblManufacturer As Label
Public txtManufacturer As TextBox
Private WithEvents btnOK As Button
Private WithEvents btnCancel As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Manufacturer
lblManufacturer = New Label()
lblManufacturer.AutoSize = True
lblManufacturer.Location = New System.Drawing.Point(21, 20)
lblManufacturer.TabIndex = 0
lblManufacturer.Text = "Manufacturer:"
Controls.Add(lblManufacturer)
' Text Box: Manufacturer
txtManufacturer = New TextBox()
txtManufacturer.Location = New System.Drawing.Point(100, 17)
txtManufacturer.Size = New System.Drawing.Size(156, 20)
txtManufacturer.TabIndex = 1
Controls.Add(txtManufacturer)
' Button: OK
btnOK = New Button()
btnOK.DialogResult = DialogResult.OK
btnOK.Location = New System.Drawing.Point(100, 53)
btnOK.Size = New System.Drawing.Size(75, 23)
btnOK.TabIndex = 3
btnOK.Text = "OK"
Controls.Add(btnOK)
' Button: Cancel
btnCancel = New Button()
btnCancel.DialogResult = DialogResult.Cancel
btnCancel.Location = New System.Drawing.Point(181, 53)
btnCancel.Size = New System.Drawing.Size(75, 23)
btnCancel.TabIndex = 2
btnCancel.Text = "Cancel"
Controls.Add(btnCancel)
' Dialog Box: Manufacturer
AcceptButton = btnOK
CancelButton = btnCancel
ClientSize = New System.Drawing.Size(276, 92)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
Text = "FunDS - Manufacturer"
StartPosition = FormStartPosition.CenterScreen
End Sub
End Class
- To save and start a new file, on the main menu, click File -> New
- When asked whether you want save, click Yes (or Save)
- In the top combo box, make sure FunDS1 is selected. Set the name to Manufacturer.vb
-
Change the Save As Type to All Files
- Click
Save
- In the empty document, type the following:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class Category
Inherits Form
Private WithEvents btnOK As Button
Private WithEvents btnCancel As Button
Private lblCategory As Label
Public txtCategory As TextBox
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Category
lblCategory = New Label()
lblCategory.AutoSize = True
lblCategory.Location = New System.Drawing.Point(21, 20)
lblCategory.TabIndex = 4
lblCategory.Text = "Category:"
Controls.Add(lblCategory)
' Text Box: Category
txtCategory = New TextBox()
txtCategory.Location = New System.Drawing.Point(100, 17)
txtCategory.Size = New System.Drawing.Size(156, 20)
txtCategory.TabIndex = 5
Controls.Add(txtCategory)
' Button: OK
btnOK = New Button()
btnOK.DialogResult = DialogResult.OK
btnOK.Location = New System.Drawing.Point(100, 53)
btnOK.Size = New System.Drawing.Size(75, 23)
btnOK.TabIndex = 7
btnOK.Text = "OK"
btnOK.UseVisualStyleBackColor = True
Controls.Add(btnOK)
' Button: Cancel
btnCancel = New Button()
btnCancel.DialogResult = DialogResult.Cancel
btnCancel.Location = New System.Drawing.Point(181, 53)
btnCancel.Size = New System.Drawing.Size(75, 23)
btnCancel.TabIndex = 6
btnCancel.Text = "Cancel"
Controls.Add(btnCancel)
' Dialog Box: Category
AcceptButton = btnOK
CancelButton = btnCancel
ClientSize = New System.Drawing.Size(276, 93)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - Category"
End Sub
End Class
- To save and start a new file, on the main menu, click File -> New
- When asked whether you want to save, click Save
- Make sure FunDS1 is
selected in the top combo box and set the File Name to Category.vb
-
Set the Save As Type combo box to All Files
- Click Save
- In the empty document, type the following:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class SubCategory
Inherits Form
Private lblSubCategory As Label
Public txtSubCategory As TextBox
Private WithEvents btnOK As Button
Private WithEvents btnCancel As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
lblSubCategory = New Label()
lblSubCategory.AutoSize = True
lblSubCategory.Location = New System.Drawing.Point(21, 20)
lblSubCategory.TabIndex = 0
lblSubCategory.Text = "Sub-Category:"
Controls.Add(lblSubCategory)
txtSubCategory = New TextBox()
txtSubCategory.Location = New System.Drawing.Point(100, 17)
txtSubCategory.Size = New System.Drawing.Size(156, 20)
txtSubCategory.TabIndex = 1
Controls.Add(txtSubCategory)
btnOK = New Button()
btnOK.DialogResult = DialogResult.OK
btnOK.Location = New System.Drawing.Point(100, 53)
btnOK.Size = New System.Drawing.Size(75, 23)
btnOK.TabIndex = 2
btnOK.Text = "OK"
Controls.Add(btnOK)
btnCancel = New Button()
btnCancel.DialogResult = DialogResult.Cancel
btnCancel.Location = New System.Drawing.Point(181, 53)
btnCancel.Size = New System.Drawing.Size(75, 23)
btnCancel.TabIndex = 3
btnCancel.Text = "Cancel"
Controls.Add(btnCancel)
AcceptButton = btnOK
CancelButton = btnCancel
ClientSize = New System.Drawing.Size(276, 93)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - Sub-Category"
End Sub
End Class
- To save and start a new file, on the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top combo box, make sure the FunDS1 folder is selected. Set the Save
As Type combo box to All Files
- Set the File Name to SubCategory.vb
-
Click Save
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class StoreItemNew
Inherits Form
Private lblItemNumber As Label
Public txtItemNumber As TextBox
Private lblManufacturer As Label
Public cbxManufacturers As ComboBox
Private WithEvents btnNewManufacturer As Button
Private lblCategory As Label
Private lblSubCategory As Label
Private lblUnitPrice As Label
Private lblDiscountRate As Label
Private lblDiscountPercent As Label
Private WithEvents btnNewCategory As Button
Private WithEvents btnNewSubCategory As Button
Private WithEvents btnSubmit As Button
Private WithEvents btnClose As Button
Public cbxCategories As ComboBox
Public cbxSubCategories As ComboBox
Private lblItemName As Label
Public txtItemName As TextBox
Private lblItemSize As Label
Public txtItemSize As TextBox
Public txtUnitPrice As TextBox
Public txtDiscountRate As TextBox
Private WithEvents btnReset As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
lblItemNumber = New Label()
lblItemNumber.AutoSize = True
lblItemNumber.Location = New Point(17, 24)
lblItemNumber.TabIndex = 2
lblItemNumber.Text = "Item Number:"
Controls.Add(lblItemNumber)
' Label: Item Number
txtItemNumber = New TextBox()
txtItemNumber.Location = New Point(96, 21)
txtItemNumber.Size = New System.Drawing.Size(94, 20)
txtItemNumber.TabIndex = 3
Controls.Add(txtItemNumber)
' Label: Manufacturer
lblManufacturer = New Label()
lblManufacturer.AutoSize = True
lblManufacturer.Location = New Point(17, 54)
lblManufacturer.TabIndex = 6
lblManufacturer.Text = "Manufacturer:"
Controls.Add(lblManufacturer)
' Combo Box: Manufacturers
cbxManufacturers = New ComboBox()
cbxManufacturers.DropDownStyle = ComboBoxStyle.DropDownList
cbxManufacturers.FormattingEnabled = True
cbxManufacturers.Location = New Point(96, 50)
cbxManufacturers.Size = New System.Drawing.Size(200, 21)
cbxManufacturers.TabIndex = 7
Controls.Add(cbxManufacturers)
' Button: New Manufacturer
btnNewManufacturer = New Button()
btnNewManufacturer.Location = New Point(302, 50)
btnNewManufacturer.Size = New System.Drawing.Size(50, 23)
btnNewManufacturer.TabIndex = 21
btnNewManufacturer.Text = "New..."
Controls.Add(btnNewManufacturer)
' Label: Category
lblCategory = New Label()
lblCategory.AutoSize = True
lblCategory.Location = New Point(17, 82)
lblCategory.TabIndex = 8
lblCategory.Text = "Category:"
Controls.Add(lblCategory)
' Combo Box: Categories
cbxCategories = New ComboBox()
cbxCategories.DropDownStyle = ComboBoxStyle.DropDownList
cbxCategories.FormattingEnabled = True
cbxCategories.Location = New Point(96, 79)
cbxCategories.Size = New System.Drawing.Size(200, 21)
cbxCategories.TabIndex = 9
Controls.Add(cbxCategories)
' Button: New Category
btnNewCategory = New Button()
btnNewCategory.Location = New Point(302, 79)
btnNewCategory.Size = New System.Drawing.Size(50, 23)
btnNewCategory.TabIndex = 22
btnNewCategory.Text = "New..."
Controls.Add(btnNewCategory)
' Label: Sub-Category
lblSubCategory = New Label()
lblSubCategory.AutoSize = True
lblSubCategory.Location = New Point(17, 113)
lblSubCategory.TabIndex = 10
lblSubCategory.Text = "Sub-Category:"
Controls.Add(lblSubCategory)
' Combo Box: Sub-Categories
cbxSubCategories = New ComboBox()
cbxSubCategories.DropDownStyle = ComboBoxStyle.DropDownList
cbxSubCategories.FormattingEnabled = True
cbxSubCategories.Location = New Point(96, 109)
cbxSubCategories.Size = New System.Drawing.Size(200, 21)
cbxSubCategories.TabIndex = 11
Controls.Add(cbxSubCategories)
' Button: New Sub-Category
btnNewSubCategory = New Button()
btnNewSubCategory.Location = New Point(302, 109)
btnNewSubCategory.Size = New System.Drawing.Size(50, 23)
btnNewSubCategory.TabIndex = 23
btnNewSubCategory.Text = "New..."
Controls.Add(btnNewSubCategory)
' Label: Item Name
lblItemName = New Label()
lblItemName.AutoSize = True
lblItemName.Location = New Point(17, 142)
lblItemName.TabIndex = 12
lblItemName.Text = "Item Name:"
Controls.Add(lblItemName)
' Text Box: Item Name
txtItemName = New TextBox()
txtItemName.Location = New Point(96, 139)
txtItemName.Size = New System.Drawing.Size(256, 20)
txtItemName.TabIndex = 13
Controls.Add(txtItemName)
' Label: Item Size
lblItemSize = New Label()
lblItemSize.AutoSize = True
lblItemSize.Location = New Point(17, 172)
lblItemSize.TabIndex = 14
lblItemSize.Text = "Item Size:"
Controls.Add(lblItemSize)
' Text Box: Item Size
txtItemSize = New TextBox()
txtItemSize.Location = New Point(96, 169)
txtItemSize.Size = New System.Drawing.Size(256, 20)
txtItemSize.TabIndex = 15
Controls.Add(txtItemSize)
' Label: Unit Price
lblUnitPrice = New Label()
lblUnitPrice.AutoSize = True
lblUnitPrice.Location = New Point(17, 201)
lblUnitPrice.TabIndex = 16
lblUnitPrice.Text = "Unit Price:"
Controls.Add(lblUnitPrice)
' Text Box: Unit Price
txtUnitPrice = New TextBox()
txtUnitPrice.Location = New Point(96, 198)
txtUnitPrice.Size = New System.Drawing.Size(94, 20)
txtUnitPrice.TabIndex = 17
txtUnitPrice.Text = "0.00"
txtUnitPrice.TextAlign = HorizontalAlignment.Right
Controls.Add(txtUnitPrice)
' Label: Discount Rate
lblDiscountRate = New Label()
lblDiscountRate.AutoSize = True
lblDiscountRate.Location = New Point(200, 201)
lblDiscountRate.Size = New System.Drawing.Size(78, 13)
lblDiscountRate.TabIndex = 18
lblDiscountRate.Text = "Discount Rate:"
Controls.Add(lblDiscountRate)
' Text Box: Discount Rate
txtDiscountRate = New TextBox()
txtDiscountRate.Location = New Point(284, 198)
txtDiscountRate.Size = New System.Drawing.Size(47, 20)
txtDiscountRate.TabIndex = 19
txtDiscountRate.Text = "0.00"
txtDiscountRate.TextAlign = HorizontalAlignment.Right
Controls.Add(txtDiscountRate)
' Label: Discount Percent
lblDiscountPercent = New Label()
lblDiscountPercent.AutoSize = True
lblDiscountPercent.Location = New Point(334, 201)
lblDiscountPercent.TabIndex = 20
lblDiscountPercent.Text = "%"
Controls.Add(lblDiscountPercent)
' Button: Submit
btnSubmit = New Button()
btnSubmit.Location = New Point(113, 236)
btnSubmit.Size = New System.Drawing.Size(75, 23)
btnSubmit.TabIndex = 25
btnSubmit.Text = "Submit"
Controls.Add(btnSubmit)
' Button: Reset
btnReset = New Button()
btnReset.Location = New Point(194, 236)
btnReset.Size = New System.Drawing.Size(75, 23)
btnReset.TabIndex = 26
btnReset.Text = "Reset"
Controls.Add(btnReset)
' Button: Close
btnClose = New Button()
btnClose.Location = New Point(275, 236)
btnClose.Size = New System.Drawing.Size(75, 23)
btnClose.TabIndex = 24
btnClose.Text = "Close"
Controls.Add(btnClose)
' Dialog Box: New Store Item
ClientSize = New System.Drawing.Size(372, 280)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - New Store Item"
End Sub
Private Sub PopulateStoreItem()
Dim rndNumber As Random = New Random()
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
' Set some default values on the New Store Item dialog box before the user opens it
' Create a random item number. The user can change it if necessary
txtItemNumber.Text = CStr(rndNumber.Next(100000, 999999))
cbxManufacturers.Items.Clear()
cbxCategories.Items.Clear()
cbxSubCategories.Items.Clear()
If File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlCategories As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/Category")
Dim xnlSubCategories As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/SubCategory")
Dim xnlManufacturers As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/Manufacturer")
For Each xnManufacturer As XmlNode In xnlManufacturers
If Not cbxManufacturers.Items.Contains(xnManufacturer.InnerText) Then
cbxManufacturers.Items.Add(xnManufacturer.InnerText)
End If
Next
For Each xnCategory As XmlNode In xnlCategories
If Not cbxCategories.Items.Contains(xnCategory.InnerText) Then
cbxCategories.Items.Add(xnCategory.InnerText)
End If
next
For Each xnSubCategory As XmlNode In xnlSubCategories
If Not cbxSubCategories.Items.Contains(xnSubCategory.InnerText) Then
cbxSubCategories.Items.Add(xnSubCategory.InnerText)
End If
Next
cbxManufacturers.Sorted = True
cbxCategories.Sorted = True
cbxSubCategories.Sorted = True
cbxManufacturers.Text = "N/A"
cbxCategories.Text = "N/A"
cbxSubCategories.Text = "N/A"
txtItemName.Text = ""
txtItemSize.Text = ""
txtUnitPrice.Text = "0.00"
txtDiscountRate.Text = ""
End Using
End If
End Sub
Private Sub StoreItemLoad(ByVal sender As Object, ByVal e As EventArgs) Handles me.load
PopulateStoreItem()
End Sub
Private Sub btnNewManufacturerClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewManufacturer.Click
' bool ManufacturerFound = false
Dim man As Manufacturer = New Manufacturer()
' Show the New Manufacturer dialog box.
' Find out if the user clicked OK after using the dialog box
If man.ShowDialog() = DialogResult.OK Then
' If the user clicked OK...
' ... if the Manufacturer text box was empty, do nothing
If String.IsNullOrEmpty(man.txtManufacturer.Text) Then
MsgBox("You must enter a manufacturer's name.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
Else
If Not cbxManufacturers.Items.Contains(man.txtManufacturer.Text) Then
cbxManufacturers.Items.Add(man.txtManufacturer.Text)
cbxManufacturers.Text = man.txtManufacturer.Text
End If
End If
End If
End Sub
Private Sub btnNewCategoryClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewCategory.Click
Dim cat As Category = New Category()
If cat.ShowDialog() = DialogResult.OK Then
If String.IsNullOrEmpty(cat.txtCategory.Text) Then
MsgBox("You must enter a category's name.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
Else
If Not cbxCategories.Items.Contains(cat.txtCategory.Text) Then
cbxCategories.Items.Add(cat.txtCategory.Text)
cbxCategories.Text = cat.txtCategory.Text
End If
End If
End If
End Sub
Private Sub btnNewSubCategoryClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewSubCategory.Click
Dim sc As SubCategory = New SubCategory()
If sc.ShowDialog() = DialogResult.OK Then
If String.IsNullOrEmpty(sc.txtSubCategory.Text) Then
MsgBox("You must enter a sub-category's name.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
Else
If Not cbxSubCategories.Items.Contains(sc.txtSubCategory.Text) Then
cbxSubCategories.Items.Add(sc.txtSubCategory.Text)
cbxSubCategories.Text = sc.txtSubCategory.Text
End If
End If
End If
End Sub
Private Sub btnResetClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnReset.Click
PopulateStoreItem()
End Sub
Private Sub btnSubmitClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If String.IsNullOrEmpty(txtItemNumber.Text) Then
MsgBox("You must provide at least an item number.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
ElseIf (String.IsNullOrEmpty(txtItemName.Text)) Then
MsgBox("You must specify the name of the item or a (short) description.",
MsgBoxStyle.OKOnly Or MsgBoxStyle.Information,
"FunDS - Employees Records")
Exit Sub
End If
If Not File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Create, FileAccess.Write)
xdStoreItems.LoadXml("<?xml version=""1.0"" encoding=""utf-8""?>" &
"<StoreItems></StoreItems>")
xdStoreItems.Save(fsStoreItems)
End Using
End If
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
End Using
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Create, FileAccess.Write)
Dim xeStoreItem As XmlElement = xdStoreItems.CreateElement("StoreItem")
xeStoreItem.InnerXml = "<ItemNumber>" & txtItemNumber.Text & "</ItemNumber>" &
"<Manufacturer>" & cbxManufacturers.Text & "</Manufacturer>" &
"<Category>" & cbxCategories.Text & "</Category>" &
"<SubCategory>" & cbxSubCategories.Text & "</SubCategory>" &
"<ItemName>" & txtItemName.Text & "</ItemName>" &
"<ItemSize>" & txtItemSize.Text & "</ItemSize>" &
"<UnitPrice>" & txtUnitPrice.Text & "</UnitPrice>" &
"<DiscountRate>" & txtDiscountRate.Text & "</DiscountRate>"
xdStoreItems.DocumentElement.AppendChild(xeStoreItem)
xdStoreItems.Save(fsStoreItems)
End Using
PopulateStoreItem()
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
End Class
- On the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top combo box, make sure FunDS1 is selected Set the Save As Type
combo box to All Files
- Set the File Name to StoreItemNew.vb
-
Click Save
Editing an item consists of changing any of its aspects.
Since this is an XML-based application, you can simply open a file in a text
editor and change anything. As for us, we will provide a form that can be used
to enter an item number and click a button to find it. If the item is found, the
employee can make any changes, and save it.
Practical
Learning: Editing a Store Item
|
|
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class StoreItemEditor
Inherits Form
Private lblItemNumber As Label
Public txtItemNumber As TextBox
Private WithEvents btnFind As Button
Private lblManufacturer As Label
Public cbxManufacturers As ComboBox
Private WithEvents btnNewManufacturer As Button
Private lblCategory As Label
Public cbxCategories As ComboBox
Private WithEvents btnNewCategory As Button
Private lblSubCategory As Label
Public cbxSubCategories As ComboBox
Private WithEvents btnNewSubCategory As Button
Private lblItemName As Label
Public txtItemName As TextBox
Private lblItemSize As Label
Public txtItemSize As TextBox
Private lblUnitPrice As Label
Public txtUnitPrice As TextBox
Private lblDiscountRate As Label
Public txtDiscountRate As TextBox
Private lblDiscountPercent As Label
Private WithEvents btnUpdate As Button
Private WithEvents btnClose As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Item Number
lblItemNumber = New Label()
lblItemNumber.AutoSize = True
lblItemNumber.Location = New Point(17, 24)
lblItemNumber.TabIndex = 2
lblItemNumber.Text = "Item Number:"
Controls.Add(lblItemNumber)
txtItemNumber = New TextBox()
txtItemNumber.Location = New Point(96, 21)
txtItemNumber.Size = New System.Drawing.Size(75, 20)
txtItemNumber.TabIndex = 3
Controls.Add(txtItemNumber)
' Button: New Find
btnFind = New Button()
btnFind.Location = New Point(180, 20)
btnFind.Size = New System.Drawing.Size(50, 23)
btnFind.TabIndex = 21
btnFind.Text = "Find"
Controls.Add(btnFind)
' Label: Manufacturer
lblManufacturer = New Label()
lblManufacturer.AutoSize = True
lblManufacturer.Location = New Point(17, 54)
lblManufacturer.TabIndex = 6
lblManufacturer.Text = "Manufacturer:"
Controls.Add(lblManufacturer)
' Combo Box: Manufacturers
cbxManufacturers = New ComboBox()
cbxManufacturers.Location = New Point(96, 50)
cbxManufacturers.Size = New System.Drawing.Size(200, 21)
cbxManufacturers.TabIndex = 7
cbxManufacturers.Sorted = True
Controls.Add(cbxManufacturers)
' Button: New Manufacturer
btnNewManufacturer = New Button()
btnNewManufacturer.Location = New Point(302, 49)
btnNewManufacturer.Size = New System.Drawing.Size(50, 23)
btnNewManufacturer.TabIndex = 21
btnNewManufacturer.Text = "New..."
Controls.Add(btnNewManufacturer)
' Label: Category
lblCategory = New Label()
lblCategory.AutoSize = True
lblCategory.Location = New Point(17, 82)
lblCategory.TabIndex = 8
lblCategory.Text = "Category:"
Controls.Add(lblCategory)
' Combo Box: Categories
cbxCategories = New ComboBox()
cbxCategories.Location = New Point(96, 79)
cbxCategories.Size = New System.Drawing.Size(200, 21)
cbxCategories.TabIndex = 9
cbxCategories.Sorted = True
Controls.Add(cbxCategories)
' Button: New Category
btnNewCategory = New Button()
btnNewCategory.Location = New Point(302, 77)
btnNewCategory.Size = New System.Drawing.Size(50, 23)
btnNewCategory.TabIndex = 22
btnNewCategory.Text = "New..."
Controls.Add(btnNewCategory)
' Label: Sub-Category
lblSubCategory = New Label()
lblSubCategory.AutoSize = True
lblSubCategory.Location = New Point(17, 113)
lblSubCategory.TabIndex = 10
lblSubCategory.Text = "Sub-Category:"
Controls.Add(lblSubCategory)
' Combo Box: Sub-Categories
cbxSubCategories = New ComboBox()
cbxSubCategories.Location = New Point(96, 109)
cbxSubCategories.Size = New System.Drawing.Size(200, 21)
cbxSubCategories.TabIndex = 11
cbxSubCategories.Sorted = True
Controls.Add(cbxSubCategories)
' Button: New Sub-Category
btnNewSubCategory = New Button()
btnNewSubCategory.Location = New Point(302, 107)
btnNewSubCategory.Size = New System.Drawing.Size(50, 23)
btnNewSubCategory.TabIndex = 23
btnNewSubCategory.Text = "New..."
Controls.Add(btnNewSubCategory)
' Label: Item Name
lblItemName = New Label()
lblItemName.AutoSize = True
lblItemName.Location = New Point(17, 142)
lblItemName.TabIndex = 12
lblItemName.Text = "Item Name:"
Controls.Add(lblItemName)
' Text Box: Item Name
txtItemName = New TextBox()
txtItemName.Location = New Point(96, 139)
txtItemName.Size = New System.Drawing.Size(256, 20)
txtItemName.TabIndex = 13
Controls.Add(txtItemName)
' Label: Item Size
lblItemSize = New Label()
lblItemSize.AutoSize = True
lblItemSize.Location = New Point(17, 172)
lblItemSize.TabIndex = 14
lblItemSize.Text = "Item Size:"
Controls.Add(lblItemSize)
' Text Box: Item Size
txtItemSize = New TextBox()
txtItemSize.Location = New Point(96, 169)
txtItemSize.Size = New System.Drawing.Size(256, 20)
txtItemSize.TabIndex = 15
Controls.Add(txtItemSize)
' Label: Unit Price
lblUnitPrice = New Label()
lblUnitPrice.AutoSize = True
lblUnitPrice.Location = New Point(17, 201)
lblUnitPrice.TabIndex = 16
lblUnitPrice.Text = "Unit Price:"
Controls.Add(lblUnitPrice)
' Text Box: Unit Price
txtUnitPrice = New TextBox()
txtUnitPrice.Location = New Point(96, 198)
txtUnitPrice.Size = New System.Drawing.Size(94, 20)
txtUnitPrice.TabIndex = 17
txtUnitPrice.Text = "0.00"
txtUnitPrice.TextAlign = HorizontalAlignment.Right
Controls.Add(txtUnitPrice)
' Label: Discount Rate
lblDiscountRate = New Label()
lblDiscountRate.AutoSize = True
lblDiscountRate.Location = New Point(200, 201)
lblDiscountRate.Size = New System.Drawing.Size(78, 13)
lblDiscountRate.TabIndex = 18
lblDiscountRate.Text = "Discount Rate:"
Controls.Add(lblDiscountRate)
' Text Box: Discount Rate
txtDiscountRate = New TextBox()
txtDiscountRate.Location = New Point(284, 198)
txtDiscountRate.Size = New System.Drawing.Size(47, 20)
txtDiscountRate.TabIndex = 19
txtDiscountRate.Text = "0.00"
txtDiscountRate.TextAlign = HorizontalAlignment.Right
Controls.Add(txtDiscountRate)
' Label: Discount Percent
lblDiscountPercent = New Label()
lblDiscountPercent.AutoSize = True
lblDiscountPercent.Location = New Point(334, 201)
lblDiscountPercent.TabIndex = 20
lblDiscountPercent.Text = "%"
Controls.Add(lblDiscountPercent)
' Button: Update
btnUpdate = New Button()
btnUpdate.Location = New Point(196, 231)
btnUpdate.Size = New System.Drawing.Size(75, 23)
btnUpdate.TabIndex = 25
btnUpdate.Text = "Update"
Controls.Add(btnUpdate)
' Button: Close
btnClose = New Button()
btnClose.Location = New Point(275, 231)
btnClose.Size = New System.Drawing.Size(75, 23)
btnClose.TabIndex = 24
btnClose.Text = "Close"
Controls.Add(btnClose)
' Dialog Box: New Store Item
ClientSize = New System.Drawing.Size(372, 276)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - Edit Store Item"
End Sub
Private Sub PopulateStoreItem()
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
cbxManufacturers.Items.Clear()
cbxCategories.Items.Clear()
cbxSubCategories.Items.Clear()
If File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlCategories As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/Category")
Dim xnlSubCategories As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/SubCategory")
Dim xnlManufacturers As XmlNodeList = xdStoreItems.SelectNodes("/StoreItems/StoreItem/Manufacturer")
For Each xnManufacturer As XmlNode In xnlManufacturers
If Not cbxManufacturers.Items.Contains(xnManufacturer.InnerText) Then
cbxManufacturers.Items.Add(xnManufacturer.InnerText)
End If
Next
For Each xnCategory As XmlNode In xnlCategories
If Not cbxCategories.Items.Contains(xnCategory.InnerText) Then
cbxCategories.Items.Add(xnCategory.InnerText)
End If
Next
For Each xnSubCategory As XmlNode In xnlSubCategories
If Not cbxSubCategories.Items.Contains(xnSubCategory.InnerText) Then
cbxSubCategories.Items.Add(xnSubCategory.InnerText)
End If
Next
End Using
End If
End Sub
Private Sub StoreItemLoad(ByVal sender As Object, ByVal e As EventArgs) Handles me.load
PopulateStoreItem()
End Sub
Private Sub btnNewManufacturerClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewManufacturer.Click
Dim man As Manufacturer = New Manufacturer()
' Show the New Manufacturer dialog box.
' Find out if the user clicked OK after using the dialog box
If man.ShowDialog() = DialogResult.OK Then
' If the user clicked OK...
' ... if the Manufacturer text box was empty, do nothing
If String.IsNullOrEmpty(man.txtManufacturer.Text) Then
MsgBox("You must enter a manufacturer's name.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
Else
If Not cbxManufacturers.Items.Contains(man.txtManufacturer.Text) Then
cbxManufacturers.Items.Add(man.txtManufacturer.Text)
cbxManufacturers.Text = man.txtManufacturer.Text
End If
End If
End If
End Sub
Private Sub btnNewCategoryClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewCategory.Click
Dim cat As Category = New Category()
If cat.ShowDialog() = DialogResult.OK Then
If String.IsNullOrEmpty(cat.txtCategory.Text) Then
MsgBox("You must enter a category's name.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
Else
If Not cbxCategories.Items.Contains(cat.txtCategory.Text) Then
cbxCategories.Items.Add(cat.txtCategory.Text)
cbxCategories.Text = cat.txtCategory.Text
End If
End If
End If
End Sub
Private Sub btnNewSubCategoryClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewSubCategory.Click
Dim sc As SubCategory = New SubCategory()
If sc.ShowDialog() = DialogResult.OK Then
If String.IsNullOrEmpty(sc.txtSubCategory.Text) Then
MsgBox("You must enter a sub-category's name.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
Else
If Not cbxSubCategories.Items.Contains(sc.txtSubCategory.Text) Then
cbxSubCategories.Items.Add(sc.txtSubCategory.Text)
cbxSubCategories.Text = sc.txtSubCategory.Text
End If
End If
End If
End Sub
Private Sub btnFindClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnFind.Click
Dim itemFound As Boolean = False
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If String.IsNullOrEmpty(txtItemNumber.Text) Then
MsgBox("You must provide an item number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
For Each xnStoreItem As XmlNode In xnlStoreItems
If xnStoreItem.InnerText = txtItemNumber.Text Then
itemFound = True
cbxManufacturers.Text = xnStoreItem.NextSibling.InnerText
cbxCategories.Text = xnStoreItem.NextSibling.NextSibling.InnerText
cbxSubCategories.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.InnerText
txtItemName.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtItemSize.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtUnitPrice.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtDiscountRate.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
Exit Sub
End If
Next
If itemFound = False Then
MsgBox("There is no item with that number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
End If
End Using
End If
End Sub
Private Sub btnUpdateClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
Dim itemFound As Boolean = False
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If String.IsNullOrEmpty(txtItemNumber.Text) Then
MsgBox("You must provide an item number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strStoreItemsFile) Then
xdStoreItems.Load(strStoreItemsFile)
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
For Each xnStoreItem As XmlNode In xnlStoreItems
If xnStoreItem.InnerText = txtItemNumber.Text Then
itemFound = True
xnStoreItem.ParentNode.InnerXml = "<ItemNumber>" & txtItemNumber.Text & "</ItemNumber>" &
"<Manufacturer>" & cbxManufacturers.Text & "</Manufacturer>" &
"<Category>" & cbxCategories.Text & "</Category>" &
"<SubCategory>" & cbxSubCategories.Text & "</SubCategory>" &
"<ItemName>" & txtItemName.Text & "</ItemName>" &
"<ItemSize>" & txtItemSize.Text & "</ItemSize>" &
"<UnitPrice>" & txtUnitPrice.Text & "</UnitPrice>" &
"<DiscountRate>" & txtDiscountRate.Text & "</DiscountRate>"
Exit For
End If
Next
If (itemFound = True) Then
xdStoreItems.Save(strStoreItemsFile)
MsgBox("The store item has been updated.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
PopulateStoreItem()
txtItemNumber.Text = ""
End If
End If
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
- On the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top combo box, make sure the FunDS1 folder is displaying, Set the Save As Type
to All Files
- Set the name to StoreItemEditor.vb
- Click Save
To make sure we cover most aspects of data maintenance are
covered, we will give the company the ability to delete an item from the
inventory.
Practical
Learning: Deleting an Item
|
|
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class StoreItemDelete
Inherits Form
Private lblItemNumber As Label
Public txtItemNumber As TextBox
Private WithEvents btnFind As Button
Private lblManufacturer As Label
Public txtManufacturer As TextBox
Private lblCategory As Label
Public txtCategory As TextBox
Private lblSubCategory As Label
Public txtSubCategory As TextBox
Private lblItemName As Label
Public txtItemName As TextBox
Private lblItemSize As Label
Public txtItemSize As TextBox
Private lblUnitPrice As Label
Public txtUnitPrice As TextBox
Private lblDiscountRate As Label
Public txtDiscountRate As TextBox
Private lblDiscountPercent As Label
Private WithEvents btnDelete As Button
Private WithEvents btnClose As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Label: Item Number
lblItemNumber = New Label()
lblItemNumber.AutoSize = True
lblItemNumber.Location = New Point(17, 24)
lblItemNumber.TabIndex = 0
lblItemNumber.Text = "Item Number:"
Controls.Add(lblItemNumber)
txtItemNumber = New TextBox()
txtItemNumber.Location = New Point(96, 21)
txtItemNumber.Size = New System.Drawing.Size(75, 20)
txtItemNumber.TabIndex = 1
Controls.Add(txtItemNumber)
' Button: New Find
btnFind = New Button()
btnFind.Location = New Point(180, 20)
btnFind.Size = New System.Drawing.Size(50, 23)
btnFind.TabIndex = 2
btnFind.Text = "Find"
Controls.Add(btnFind)
' Label: Manufacturer
lblManufacturer = New Label()
lblManufacturer.AutoSize = True
lblManufacturer.Location = New Point(17, 54)
lblManufacturer.TabIndex = 5
lblManufacturer.Text = "Manufacturer:"
Controls.Add(lblManufacturer)
' Combo Box: Manufacturers
txtManufacturer = New TextBox()
txtManufacturer.Location = New Point(96, 50)
txtManufacturer.Size = New System.Drawing.Size(200, 21)
txtManufacturer.TabIndex = 6
Controls.Add(txtManufacturer)
' Label: Category
lblCategory = New Label()
lblCategory.AutoSize = True
lblCategory.Location = New Point(17, 82)
lblCategory.TabIndex = 7
lblCategory.Text = "Category:"
Controls.Add(lblCategory)
' Combo Box: Categories
txtCategory = New TextBox()
txtCategory.Location = New Point(96, 79)
txtCategory.Size = New System.Drawing.Size(200, 21)
txtCategory.TabIndex = 8
Controls.Add(txtCategory)
' Label: Sub-Category
lblSubCategory = New Label()
lblSubCategory.AutoSize = True
lblSubCategory.Location = New Point(17, 113)
lblSubCategory.TabIndex = 9
lblSubCategory.Text = "Sub-Category:"
Controls.Add(lblSubCategory)
' Combo Box: Sub-Categories
txtSubCategory = New TextBox()
txtSubCategory.Location = New Point(96, 109)
txtSubCategory.Size = New System.Drawing.Size(200, 21)
txtSubCategory.TabIndex = 10
Controls.Add(txtSubCategory)
' Label: Item Name
lblItemName = New Label()
lblItemName.AutoSize = True
lblItemName.Location = New Point(17, 142)
lblItemName.TabIndex = 11
lblItemName.Text = "Item Name:"
Controls.Add(lblItemName)
' Text Box: Item Name
txtItemName = New TextBox()
txtItemName.Location = New Point(96, 139)
txtItemName.Size = New System.Drawing.Size(256, 20)
txtItemName.TabIndex = 12
Controls.Add(txtItemName)
' Label: Item Size
lblItemSize = New Label()
lblItemSize.AutoSize = True
lblItemSize.Location = New Point(17, 172)
lblItemSize.TabIndex = 13
lblItemSize.Text = "Item Size:"
Controls.Add(lblItemSize)
' Text Box: Item Size
txtItemSize = New TextBox()
txtItemSize.Location = New Point(96, 169)
txtItemSize.Size = New System.Drawing.Size(256, 20)
txtItemSize.TabIndex = 14
Controls.Add(txtItemSize)
' Label: Unit Price
lblUnitPrice = New Label()
lblUnitPrice.AutoSize = True
lblUnitPrice.Location = New Point(17, 201)
lblUnitPrice.TabIndex = 15
lblUnitPrice.Text = "Unit Price:"
Controls.Add(lblUnitPrice)
' Text Box: Unit Price
txtUnitPrice = New TextBox()
txtUnitPrice.Location = New Point(96, 198)
txtUnitPrice.Size = New System.Drawing.Size(94, 20)
txtUnitPrice.TabIndex = 16
txtUnitPrice.Text = "0.00"
txtUnitPrice.TextAlign = HorizontalAlignment.Right
Controls.Add(txtUnitPrice)
' Label: Discount Rate
lblDiscountRate = New Label()
lblDiscountRate.AutoSize = True
lblDiscountRate.Location = New Point(200, 201)
lblDiscountRate.Size = New System.Drawing.Size(78, 13)
lblDiscountRate.TabIndex = 17
lblDiscountRate.Text = "Discount Rate:"
Controls.Add(lblDiscountRate)
' Text Box: Discount Rate
txtDiscountRate = New TextBox()
txtDiscountRate.Location = New Point(284, 198)
txtDiscountRate.Size = New System.Drawing.Size(47, 20)
txtDiscountRate.TabIndex = 18
txtDiscountRate.Text = "0.00"
txtDiscountRate.TextAlign = HorizontalAlignment.Right
Controls.Add(txtDiscountRate)
' Label: Discount Percent
lblDiscountPercent = New Label()
lblDiscountPercent.AutoSize = True
lblDiscountPercent.Location = New Point(334, 201)
lblDiscountPercent.TabIndex = 19
lblDiscountPercent.Text = "%"
Controls.Add(lblDiscountPercent)
' Button: Delete
btnDelete = New Button()
btnDelete.Location = New Point(196, 231)
btnDelete.Size = New System.Drawing.Size(75, 23)
btnDelete.TabIndex = 3
btnDelete.Text = "Delete"
Controls.Add(btnDelete)
' Button: Close
btnClose = New Button()
btnClose.Location = New Point(275, 231)
btnClose.Size = New System.Drawing.Size(75, 23)
btnClose.TabIndex = 4
btnClose.Text = "Close"
Controls.Add(btnClose)
' Dialog Box: New Store Item
ClientSize = New System.Drawing.Size(372, 276)
FormBorderStyle = FormBorderStyle.FixedDialog
MaximizeBox = False
MinimizeBox = False
ShowInTaskbar = False
StartPosition = FormStartPosition.CenterScreen
Text = "FunDS - Store Item Deletion"
End Sub
Private Sub btnFindClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnFind.Click
Dim itemFound As Boolean = False
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If String.IsNullOrEmpty(txtItemNumber.Text) Then
MsgBox("You must provide an item number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
For Each xnStoreItem As XmlNode In xnlStoreItems
If xnStoreItem.InnerText = txtItemNumber.Text Then
itemFound = True
txtManufacturer.Text = xnStoreItem.NextSibling.InnerText
txtCategory.Text = xnStoreItem.NextSibling.NextSibling.InnerText
txtSubCategory.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.InnerText
txtItemName.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtItemSize.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtUnitPrice.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
txtDiscountRate.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
Exit Sub
End If
Next
If itemFound = False Then
MsgBox("There is no item with that number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
End If
End Using
End If
End Sub
Private Sub btnDeleteClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnDelete.Click
Dim itemFound As Boolean = False
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If String.IsNullOrEmpty(txtItemNumber.Text) Then
MsgBox("You must provide an item number.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
Exit Sub
End If
If File.Exists(strStoreItemsFile) Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
For Each xnStoreItem As XmlNode In xnlStoreItems
If xnStoreItem.InnerText = txtItemNumber.Text Then
itemFound = True
xdStoreItems.DocumentElement.RemoveChild(xnStoreItem.ParentNode)
Exit For
End If
Next
End Using
If itemFound = True Then
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Create, FileAccess.Write)
xdStoreItems.Save(fsStoreItems)
MsgBox("The store item has been deleted.", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "FunDS - Employees Records")
End Using
txtItemNumber.Text = ""
txtManufacturer.Text = ""
txtCategory.Text = ""
txtSubCategory.Text = ""
txtItemName.Text = ""
txtItemSize.Text = ""
txtUnitPrice.Text = "0.00"
txtDiscountRate.Text = "0.00"
End If
End If
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
End Class
- On the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top
combo box, make sure the FunDS1 folder is displaying, Set the Save As Type
to All Files
- Set the File Name to StoreItemDelete.vb
- Click Save
- In the empty document, type the following:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Drawing
Imports System.Windows.Forms
Public Class StoreItems
Inherits Form
Private colStoreItemID As ColumnHeader
Private colItemNumber As ColumnHeader
Private colManufacturer As ColumnHeader
Private colCategory As ColumnHeader
Private colSubCategory As ColumnHeader
Private colItemName As ColumnHeader
Private colItemSize As ColumnHeader
Private colUnitPrice As ColumnHeader
Private colDiscountRate As ColumnHeader
Private colDiscountAmount As ColumnHeader
Private colMarkedPrice As ColumnHeader
Private WithEvents lvwStoreItems As ListView
Private lblNumberOfItems As Label
Private txtNumberOfItems As TextBox
Private WithEvents btnNewStoreItem As Button
Private WithEvents btnEditStoreItem As Button
Private WithEvents btnDeleteStoreItem As Button
Private WithEvents btnClose As Button
Public Sub New()
InitializeComponent()
End Sub
Private Sub InitializeComponent()
' Column: umn: Store Item ID
colStoreItemID = New ColumnHeader()
colStoreItemID.Text = "Item ID"
colStoreItemID.Width = 50
' Column: umn: Item Number
colItemNumber = New ColumnHeader()
colItemNumber.Text = "Item #"
colItemNumber.TextAlign = HorizontalAlignment.Center
' Column: umn: Manufacturer
colManufacturer = New ColumnHeader()
colManufacturer.Text = "Manufacturer"
colManufacturer.Width = 130
' Column: umn: Category
colCategory = New ColumnHeader()
colCategory.Text = "Category"
colCategory.Width = 70
' Column: umn: Sub-Category
colSubCategory = New ColumnHeader()
colSubCategory.Text = "Sub-Category"
colSubCategory.Width = 80
' Column: umn: Item Name
colItemName = New ColumnHeader()
colItemName.Text = "Item Name"
colItemName.Width = 300
' Column: umn: Item Size
colItemSize = New ColumnHeader()
colItemSize.Text = "Size"
colItemSize.Width = 80
' Column: umn: Unit Price
colUnitPrice = New ColumnHeader()
colUnitPrice.Text = "Unit Price"
colUnitPrice.TextAlign = HorizontalAlignment.Right
' Column: umn: Discount Rate
colDiscountRate = New ColumnHeader()
colDiscountRate.Text = "Disc Rate"
colDiscountRate.TextAlign = HorizontalAlignment.Right
colDiscountRate.Width = 60
' Column: umn: Discount Amount
colDiscountAmount = New ColumnHeader()
colDiscountAmount.Text = "Disc Amt"
colDiscountAmount.TextAlign = HorizontalAlignment.Right
' Column: umn: Marked Price
colMarkedPrice = New ColumnHeader()
colMarkedPrice.Text = "Marked Price"
colMarkedPrice.TextAlign = HorizontalAlignment.Right
colMarkedPrice.Width = 75
lvwStoreItems = New ListView()
lvwStoreItems.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
lvwStoreItems.Columns.AddRange(new ColumnHeader() {
colStoreItemID, colItemNumber, colManufacturer,
colCategory, colSubCategory, colItemName, colItemSize,
colUnitPrice, colDiscountRate, colDiscountAmount, colMarkedPrice })
lvwStoreItems.FullRowSelect = True
lvwStoreItems.GridLines = True
lvwStoreItems.Location = New Point(15, 15)
lvwStoreItems.Size = New System.Drawing.Size(1050, 340)
lvwStoreItems.TabIndex = 3
lvwStoreItems.View = View.Details
lblNumberOfItems = New Label()
lblNumberOfItems.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
lblNumberOfItems.AutoSize = True
lblNumberOfItems.Location = New Point(15, 370)
lblNumberOfItems.TabIndex = 6
lblNumberOfItems.Text = "Number of Items:"
' Text Box: Number of Items
txtNumberOfItems = New TextBox()
txtNumberOfItems.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
txtNumberOfItems.Location = New Point(111, 368)
txtNumberOfItems.Size = New System.Drawing.Size(60, 20)
txtNumberOfItems.TabIndex = 7
txtNumberOfItems.TextAlign = HorizontalAlignment.Right
btnNewStoreItem = New Button()
btnNewStoreItem.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
btnNewStoreItem.Location = New Point(530, 366)
btnNewStoreItem.Size = New System.Drawing.Size(125, 32)
btnNewStoreItem.TabIndex = 5
btnNewStoreItem.Text = "New Store Item ..."
' Button: Edit Item
btnEditStoreItem = New Button()
btnEditStoreItem.Location = New Point(659, 366)
btnEditStoreItem.Size = New System.Drawing.Size(125, 32)
btnEditStoreItem.Text = "Edit Store Item..."
btnEditStoreItem.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
' Button: Remove Item
btnDeleteStoreItem = New Button()
btnDeleteStoreItem.Location = New Point(792, 366)
btnDeleteStoreItem.Size = New System.Drawing.Size(125, 32)
btnDeleteStoreItem.Text = "Delete Store Item..."
btnDeleteStoreItem.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
btnClose = New Button()
btnClose.Location = New Point(922, 366)
btnClose.Size = New System.Drawing.Size(125, 32)
btnClose.TabIndex = 4
btnClose.Text = "Close"
btnClose.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
ClientSize = New System.Drawing.Size(1080, 410)
Controls.Add(txtNumberOfItems)
Controls.Add(lblNumberOfItems)
Controls.Add(btnNewStoreItem)
Controls.Add(btnEditStoreItem)
Controls.Add(btnDeleteStoreItem)
Controls.Add(btnClose)
Controls.Add(lvwStoreItems)
StartPosition = FormStartPosition.CenterScreen
Text = "Fun Department Store - Store Items"
End Sub
Private Sub ShowStoreItems()
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If File.Exists(strStoreItemsFile) Then
lvwStoreItems.Items.Clear()
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim itemName As String = ""
Dim itemSize As String = ""
Dim strDiscountRate As String = ""
Dim itemNumber As String = ""
Dim manufacturer As String = ""
Dim category As String = ""
Dim subCategory As String = ""
Dim unitPrice As Double = 0.0
Dim discountRate As Double = 0.0
Dim discountAmount As Double = 0.0
Dim markedPrice As Double = 0.0
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
Dim i = 1
For Each xnStoreItem As XmlNode In xnlStoreItems
itemNumber = xnStoreItem.InnerText
manufacturer = xnStoreItem.NextSibling.InnerText
category = xnStoreItem.NextSibling.NextSibling.InnerText
subCategory = xnStoreItem.NextSibling.NextSibling.NextSibling.InnerText
itemName = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
itemSize = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
unitPrice = CDbl(xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText)
strDiscountRate = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
If (String.IsNullOrEmpty(strDiscountRate)) Then
discountRate = 0.0
discountAmount = 0.0
markedPrice = unitPrice
Else
discountRate = CDbl(strDiscountRate) / 100.0
discountAmount = unitPrice * discountRate
markedPrice = unitPrice - discountAmount
End If
Dim lviStoreItem As ListViewItem = New ListViewItem(CStr(i))
lviStoreItem.SubItems.Add(itemNumber) ' Item Number
lviStoreItem.SubItems.Add(manufacturer) ' Manufacturer
lviStoreItem.SubItems.Add(category) ' Category
lviStoreItem.SubItems.Add(subCategory) ' Sub-Category
lviStoreItem.SubItems.Add(itemName) ' Item Name
lviStoreItem.SubItems.Add(itemSize) ' Item Size
lviStoreItem.SubItems.Add(FormatNumber(unitPrice))
If discountRate = 0.0 Then
lviStoreItem.SubItems.Add("") ' Discount Rate
lviStoreItem.SubItems.Add("") ' Discount Amount
lviStoreItem.SubItems.Add(FormatNumber(unitPrice)) ' Marked Price
Else
lviStoreItem.SubItems.Add(FormatNumber(discountRate * 100) & "%")
lviStoreItem.SubItems.Add(FormatNumber(discountAmount))
lviStoreItem.SubItems.Add(FormatNumber(markedPrice)) ' Marked Price
End If
lvwStoreItems.Items.Add(lviStoreItem)
i = i + 1
Next
txtNumberOfItems.Text = xnlStoreItems.Count.ToString()
End Using
End If
End Sub
Private Sub StoreItemsLoad(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
ShowStoreItems()
End Sub
Private Sub btnNewStoreItemClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnNewStoreItem.Click
Dim sin As StoreItemNew = New StoreItemNew()
sin.ShowDialog()
ShowStoreItems()
End Sub
Private Sub btnEditStoreItemClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnEditStoreItem.Click
Dim sie As StoreItemEditor = New StoreItemEditor()
sie.ShowDialog()
ShowStoreItems()
End Sub
Private Sub btnDeleteStoreItemClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnDeleteStoreItem.Click
Dim sid As StoreItemDelete = New StoreItemDelete()
sid.ShowDialog()
ShowStoreItems()
End Sub
Private Sub lvwStoreItemsDoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles lvwStoreItems.DoubleClick
Dim sie As StoreItemEditor = New StoreItemEditor()
Dim xdStoreItems As XmlDocument = New XmlDocument()
Dim strStoreItemsFile As String = "C:\Fun Department Store1\StoreItems.xml"
If lvwStoreItems.Items.Count <= 0 Then
Exit Sub
End If
Using fsStoreItems As FileStream = New FileStream(strStoreItemsFile, FileMode.Open, FileAccess.Read)
xdStoreItems.Load(fsStoreItems)
Dim xnlStoreItems As XmlNodeList = xdStoreItems.GetElementsByTagName("ItemNumber")
For Each xnStoreItem As XmlNode In xnlStoreItems
If xnStoreItem.InnerText = lvwStoreItems.SelectedItems(0).SubItems(1).Text Then
sie.txtItemNumber.Text = xnStoreItem.InnerText
sie.cbxManufacturers.Text = xnStoreItem.NextSibling.InnerText
sie.cbxCategories.Text = xnStoreItem.NextSibling.NextSibling.InnerText
sie.cbxSubCategories.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.InnerText
sie.txtItemName.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
sie.txtItemSize.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
sie.txtUnitPrice.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
sie.txtDiscountRate.Text = xnStoreItem.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.NextSibling.InnerText
End If
Next
End Using
sie.ShowDialog()
ShowStoreItems()
End Sub
Private Sub btnCloseClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Close()
End Sub
- On the main menu, click File -> New
- When asked whether you want to save, click Save
- In the top
combo box, make sure the FunDS1 folder is displaying, Set the Save As Type
to All Files
- Set the File Name to Inventory.vb
- Save the file
|
|