You are on page 1of 39

.NET InstantCode: UML with Visio and Visual Studio .

NET
SkillSoft Corporation. (c) 2004. Copying Prohibited.

Reprinted for Milan Maksimovic, Avanade


milanm@avanade.com

Reprinted with permission as a subscription benefit of Books24x7,


http://www.books24x7.com/

All rights reserved. Reproduction and/or distribution in whole or in part in


electronic,paper or other forms without written permission is prohibited.
i

Table of Contents
Chapter 2: Creating the Order Processing Application...............................................................1
Architecture of the Order Processing Application..................................................................1
Creating the Database Schema.............................................................................................4
Creating the Order Processing Application............................................................................6
Creating the Customers Class.........................................................................................6
Creating the Orders Class................................................................................................7
Creating the OrderInformation Class...............................................................................9
Creating the Invoices Class...........................................................................................10
Creating the InvoiceCreditCardInfo Class......................................................................11
Creating the Shared Module..........................................................................................12
Creating the Login Manager Window.............................................................................13
Creating the Application Manager Window....................................................................14
Creating the Place Order Window..................................................................................15
Creating the View Order Status Window........................................................................18
Creating the Update Order Status Window....................................................................19
Creating the View Order Information Window................................................................21
Creating the Raise Invoice Window...............................................................................23
Creating the Invoice Window.........................................................................................25
Creating the Customer Registration Window.................................................................28
Unit Testing..........................................................................................................................30
Chapter 2: Creating the Order Processing
Application

Download CD Content
Unified Modeling Language (UML) enables you to create component diagrams that model the
physical system of an application. A component diagram consists of components, such as source
code, binary code, dynamic−link library files, or executable. The component diagram also illustrates
the dependencies between these components. You can use Visio to generate .NET skeleton code
for an application based on the UML component diagram. You can then customize this skeleton
code according to the requirements of the application.

This chapter demonstrates how you can use a UML component diagram that models the physical
system of the Order Processing application to create the .NET skeleton code and then customize it.

Architecture of the Order Processing Application


Using the Order Processing application, a prospective customer can register, place an order for a
product, and check the status of the order. The administrator of the Order Processing application
updates the status of the orders and generates invoices for the completed orders.

The Order Processing application consists of an OrderProcessing project, which utilizes the classes
that the UML component diagram creates. This project enables customers to register, select
products, and place an order.

Figure 2−1 shows the architecture of the Order Processing application:

Figure 2−1: The Order Processing Application Architecture


The ComponentDiagram.vsd file provides the component diagram for the Order Processing
application. The component model in the ComponentDiagram.vsd file depicts the Customer,
Invoice, and Order components and dependencies between them, as shown in Figure 2−2:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 2

Figure 2−2: The Component Diagram


For example, the arrows from the Invoice component to the Customer and Order components show
that the Invoice component is dependent on the Customer and Order components because the
administrator can generate invoices only after a customer places an order.

To create .NET skeleton code from ComponentDiagram.vsd file:

1. Open Microsoft Visio.

2. Open ComponentDiagram.vsd file.

3. Select UML−>Code−>Generate option.

4. Select the Target Language as Visual Basic

5. Specify the Project Name as OrderProcessing

6. Select the Template as Windows Application and Click OK.

The Customer component creates the .NET skeleton code for the Customers class. The Order
component creates the .NET skeleton code for the Orders and OrderInformation classes. The
Invoice component creates the .NET skeleton code for the Invoices and InvoiceCreditCardInfo
class.

The OrderProcessing project consists of the following files:

• Shared.vb: Provides the main() function that establishes a connection with the
OrderProcessing database and invokes the Login Manager window to let customers and
administrator log on to the Order Processing application.

• frmLoginManager.vb: Provides the LoginManager class that defines the Login Manager
window that customers and administrator use to log on to the Order Processing application.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 3

• frmApplicationManager.vb: Provides the ApplicationManager class that defines the


Application Manger window that customers and administrator use to browse through the
Order Processing application.

• Customers.vb: Provides the Customers class that registers a new customer and retrieves
information about a particular customer.

• Orders.vb: Provides the Orders class to save the orders that a customer places, in the
database. The Orders class also retrieves the status of an order, sorts information based on
the status of an order, and updates the status of an order.

• OrderInformation.vb: Provides the OrderInformation class that saves and retrieves product
information for an order.

• Invoices.vb: Provides the Invoices class that generates a new invoice and retrieves invoice
information for an order.

• InvoiceCreditCardInfo.vb: Provides the InvoiceCreditCardInfo class that saves the credit


card information of a customer when the administrator generates the invoice for an order.

• frmCustomerRegistration.vb: Provides the CustomerRegistration class that defines the


Customer Registration window, where a customer provides information required for
registration.

• frmPlaceOrder.vb: Provides the PlaceOrder class that defines the Place Order window,
where the customer can select products and place an order.

• frmViewOrderStatus.vb: Provides the ViewOrderStatus class that defines the View Order
Status window, where a customer views the status of an order after providing its order id.

• frmViewOrderInfo.vb: Provides the ViewOrderInfo class that defines the View Order
Information window, where a customer views the product information included in an order,
such as the product name and the quantity ordered.

• frmUpdateOrderStatus.vb: Provides the UpdateOrderStatus class that defines the Update


Order Status window, where the administrator updates the status of an order after it is
completed.

• frmRaiseInvoice.vb: Provides the RaiseInvoice class that defines the Raise Invoice window,
where the administrator views information on completed orders and raises invoices
accordingly.

• frmInvoice.vb: Provides the Invoice class that defines the Invoice window, where the
administrator views information on the customer and order, and generates the invoice for
that order.

Figure 2−3 shows the class diagram for the Order Processing application:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 4

Figure 2−3: The Class Diagram for the Order Processing Application

Creating the Database Schema


The Order Processing application uses the OrderProcessing database to store information about
the customers, orders, products, and invoices.

Listing 2−1 shows the SQL script to generate the database on the SQL Server:
Listing 2−1: Creating the OrderProcessing Database

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Company]')


and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Company]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Customers]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Customers]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InvoiceCreditCardInfo]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[InvoiceCreditCardInfo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Invoices]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Invoices]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OrderInformation]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[OrderInformation]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Orders]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Orders]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Products]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Products]
GO
CREATE TABLE [dbo].[Company] (
[Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Address] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[City] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Country] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 5

[ZipCode] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,


[Phone] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Customers] (
[customerId] [int] IDENTITY (1, 1) NOT NULL ,
[username] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[password] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[firstName] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[lastName] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[address1] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[address2] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[city] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[country] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[zipCode] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[InvoiceCreditCardInfo] (
[invoiceID] [int] NOT NULL ,
[nameOnCard] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[creditCardNumber] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Invoices] (
[invoiceId] [int] IDENTITY (1, 1) NOT NULL ,
[invoiceDate] [datetime] NOT NULL ,
[orderId] [int] NOT NULL ,
[customerId] [int] NOT NULL ,
[subTotal] [float] NOT NULL ,
[shipping_handlingCost] [float] NOT NULL ,
[totalAmount] [float] NOT NULL ,
[paymentMode] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[OrderInformation] (
[orderId] [int] NOT NULL ,
[productId] [int] NOT NULL ,
[qty] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Orders] (
[orderId] [int] IDENTITY (1, 1) NOT NULL ,
[orderDate] [datetime] NOT NULL ,
[amount] [float] NOT NULL ,
[customerId] [int] NOT NULL ,
[status] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[completionDate] [datetime] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Products] (
[productId] [int] IDENTITY (1, 1) NOT NULL ,
[product] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[unitPrice] [float] NOT NULL ,
[qtyInHand] [int] NOT NULL
) ON [PRIMARY]
GO

Download this Listing.

The above listing creates the OrderProcessing database for the Order Processing application. The
above code creates the following tables in the database:

• Company: Stores information about the company that uses the Order Processing
application. It stores the company name, address, city, country, zip code, and phone.

• Customers: Stores information about the customers. It stores the customer id, user name,
password, first name, last name, address1, address2, city, country, and zip code.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 6

• InvoiceCreditCardInfo: Stores information about the credit card that a customer uses to pay
for an order when an invoice is generated. It stores the invoice id, name on the credit card,
and credit card number.

• Invoices: Stores information about the invoices that the administrator generates when an
order is completed. It stores the invoice id, order id, customer id, invoice date, subtotal,
shipping and handling cost, total amount, and payment mode.

• OrderInformation: Stores information about the products in the order that a customer places.
It stores the order id, product id, and quantity of product.

• Orders: Stores information about the orders. It stores the order id, order date, customer id,
amount, completion date, and order status.

• Products: Stores information about the products, such as product id, product name, unit
price, and quantity available.

Creating the Order Processing Application


To create the Order Processing application, you need to create the classes and windows that
enable customers and the administrator to use the Order Processing application.

Creating the Customers Class


The Customers.vb file defines the Customers class that provides the functions to register new
customers and retrieve information on an existing customer.

Listing 2−2 shows the code for the Customers.vb file:


Listing 2−2: The Customers.vb File

'Static Model
Imports System.Data.SqlClient
Public Class Customers
Public customerId As Integer
Public username As String
Public password As String
Public firstName As String
Public lastName As String
Public address1 As String
Public address2 As String
Public city As String
Public country As String
Public zipCode As String
Private ds As DataSet
Private sqlCommand As sqlCommand
Private sqlda As SqlDataAdapter
'This method registers a new customer and returns the id of the newly registered
customer
Public Function addCustomerInformation() As Integer
sqlCommand = New SqlCommand("insert into customers values('" &
username & "','" & password & "','" & firstName &
"','" & lastName & "','" & address1 & "','" & address2 &
"','" & city & "','" & country & "','" & zipCode & "' )",
sqlConnection)
sqlCommand.ExecuteNonQuery()
sqlCommand = New SqlCommand("select max(customerId) from customers", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 7

sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Return ds.Tables(0).Rows(0).Item(0)
Else
Return 0
End If
End Function
'This method retrieves the information for a specified customer
Public Sub retrieveCustomerInformation(ByVal cId As Integer)
sqlCommand = New SqlCommand("select firstname,lastname,address1,address2,
city,country,zipcode from Customers where customerId='" & cId & "'",
sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
firstName = ds.Tables(0).Rows(0).Item(0)
If Not IsDBNull(ds.Tables(0).Rows(0).Item(1)) Then
lastName = ds.Tables(0).Rows(0).Item(1)
Else
lastName = ""
End If
address1 = ds.Tables(0).Rows(0).Item(2)
If Not IsDBNull(ds.Tables(0).Rows(0).Item(3)) Then
address2 = ds.Tables(0).Rows(0).Item(3)
Else
address2 = ""
End If
city = ds.Tables(0).Rows(0).Item(4)
country = ds.Tables(0).Rows(0).Item(5)
zipCode = ds.Tables(0).Rows(0).Item(6)
Else
firstName = ""
lastName = ""
address1 = ""
address2 = ""
city = ""
country = ""
zipCode = ""
End If
End Sub
End Class 'END CLASS DEFINITION Customers

Download this Listing.

The above listing defines the following methods:

• addCustomerInformation(): Registers a new customer and returns the id of the newly


registered customer.

• retrieveCustomerInformation(): Retrieves the information for a specific customer.

Creating the Orders Class


The Orders.vb file defines the Orders class that saves and retrieves information about the orders
placed by a customer using the Place Order window.

Listing 2−3 shows the code for the Orders.vb file:


Listing 2−3: The Orders.vb File

'Static Model
Imports System.Data.SqlClient
Public Class Orders
Public orderDate As Date
Public customerId As Integer

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 8

Public status As String


Public completionDate As Date
Public amount As Double
Public orderId As Integer
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
'This method saves the order in the database and returns the order Id of the newly saved ord
If this method fails to execute it returns 0
Public Function SaveOrder() As Integer
Try
sqlCommand = New SqlCommand("insert into orders(orderDate,amount,customerId,status) va
& orderDate & "'," & amount & "," & customerId & ",'P')", sqlConnection)
sqlCommand.ExecuteNonQuery()
sqlCommand = New SqlCommand("select max(orderId) from orders", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Return ds.Tables(0).Rows(0).Item(0)
Else
Return 0
End If
Catch ex As Exception
Return 0
End Try
End Function
Public Sub New()
orderId = 0
End Sub
'This method retrieves the orders according to their status. This method returns an ArrayLis
containing Orders objects that represents the orders placed by the customers
Public Function RetrieveOrderByStatus(ByVal strstatus As String) As ArrayList
Dim arrayOrders As New ArrayList
sqlCommand = New SqlCommand("select orderId,orderDate,amount,
customerID,completionDate from
orders where status='" & strstatus & "'", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Dim rowCount As Integer
For rowCount = 0 To ds.Tables(0).Rows.Count − 1
Dim objOrders As New Orders
'Retrieve orderId
objOrders.orderId = ds.Tables(0).Rows(rowCount).Item(0)
'Retrieve orderDate
objOrders.orderDate = ds.Tables(0).Rows(rowCount).Item(1)
'Retrieve customer id
objOrders.customerId = ds.Tables(0).Rows(rowCount).Item(3)
'Retrieve amount
objOrders.amount = ds.Tables(0).Rows(rowCount).Item(2)
'Retrieve completion date
If Not IsDBNull(ds.Tables(0).Rows(rowCount).Item(4)) Then
objOrders.completionDate = ds.Tables(0).Rows(rowCount).Item(4)
End If
arrayOrders.Add(objOrders)
Next
Return arrayOrders
Else
'return empty arraylist
Return arrayOrders
End If
End Function
'This method retrieves the status of the order. This method returns the status as pending,
completed, or invoiced. If the status is completed then this method returns the completion d
along with the status. If the status is invoiced, this method returns the invoice id and inv
date along with the status.
Public Function RetrieveOrderStatus(ByVal orderId As Integer) As String
sqlCommand = New SqlCommand("select status,completionDate from orders where orderId=" &
orderId & " and customerId=" & custId & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 9

If ds.Tables(0).Rows(0).Item(0) = "P" Then


Return "pending"
ElseIf ds.Tables(0).Rows(0).Item(0) = "C" Then
Return "completed;" & ds.Tables(0).Rows(0).Item(1)
Else
'Retrieve the invoice id and invoice date for the specified order
Dim objInvoices As New Invoices
Return "invoiced;" & objInvoices.retrieveInvoiceInfo(orderId)
End If
Else
Return ""
End If
End Function
'This method updates the status of the order as completed (in the database as C) or invoiced
(in the database as I) depending on the update mode.
Public Sub UpdateOrderStatus(ByVal Id As Integer, ByVal mode As String)
If mode = "completed" Then
Dim dt As System.DateTime
sqlCommand = New SqlCommand("update Orders set status='C', completiondate='" &
dt.Today & "' where orderId=" & Id & "", sqlConnection)
sqlCommand.ExecuteNonQuery()
ElseIf mode = "invoiced" Then
sqlCommand = New SqlCommand("update Orders set status='I' where orderId=" &
Id & "", sqlConnection)
sqlCommand.ExecuteNonQuery()
End If
End Sub
End Class 'END CLASS DEFINITION Orders

Download this Listing.

The above listing defines the following methods:

• SaveOrder(): Saves the order in the Orders table and returns the order id of the newly saved
order.

• RetrieveOrderByStatus(): Accepts the order id as a parameter and retrieves the order status
whether it is pending, completed, or invoiced.

• UpdateOrderStatus(): Accepts the order id and status mode as parameters and updates the
order according to the status mode. This method updates the order status as ‘C’ if the status
mode is ‘completed’ and ‘I’ if the status mode is ‘invoiced’.

Creating the OrderInformation Class


The OrderInformation.vb file defines the OrderInformation class that saves and retrieves information
about the products in an order that a customer places using the Place Order window.

Listing 2−4 shows the code for the OrderInformation.vb file:


Listing 2−4: The OrderInformation.vb File

'Static Model
Imports System.Data.SqlClient
Public Class OrderInformation
Public orderId As Integer
Public productId As Integer
Public quantity As Integer
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
'This method saves the product wise order information
Public Sub SaveOrderInfo()
Try

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 10

sqlCommand = New SqlCommand("insert into OrderInformation values(" & orderId


&
"," & productId & "," & quantity & ")", sqlConnection)
sqlCommand.ExecuteNonQuery()
Catch ex As Exception
End Try
End Sub
'This method retrieves the product wise information for an order
Public Function RetrieveOrderInfo(ByVal Id As Integer) As ArrayList
Dim objOrderInformation As New ArrayList
sqlCommand = New SqlCommand("select OrderId,ProductId,sum(qty) as total from
OrderInformation
where OrderId=" & Id & " group by OrderId,ProductId", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Dim rowcount As Integer
For rowcount = 0 To ds.Tables(0).Rows.Count − 1
Dim tempObjOrderInformation As New OrderInformation
tempObjOrderInformation.orderId = Id
'Retrieve product id
tempObjOrderInformation.productId = ds.Tables(0).Rows(rowcount).Item(1)
'Retrieve quantity ordered for that product
tempObjOrderInformation.quantity = ds.Tables(0).Rows(rowcount).Item(2)
objOrderInformation.Add(tempObjOrderInformation)
Next
End If
Return objOrderInformation
End Function
End Class 'END CLASS DEFINITION OrderInformation

Download this Listing.

The above listing defines the following methods:

• SaveOrderInfo(): Saves the product information provided in an order, such as the product id
and quantity of that product.

• RetrieveOrderInfo(): Accepts the order id and returns product information for the order
referenced by that order id.

Creating the Invoices Class


The Invoices.vb file defines the Invoices class that saves and retrieves information about the invoice
that the administrator generates using the Invoice window.

Listing 2−5 shows the code for the Invoices.vb file:


Listing 2−5: The Invoices.vb File

'Static Model
Imports System.Data.SqlClient
Public Class Invoices
Public invoiceId As Integer
Public invoiceDate As Date
Public orderId As Integer
Public customerId As Integer
Public subTotal As Double
Public paymentMode As String
Public shipping_handlingCost As Double
Public totalAmount As Double
Private sqlCommand As sqlCommand
Private sqlda As SqlDataAdapter
Private ds As DataSet
'This method generates the invoice

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 11

Public Sub generateInvoice()


sqlCommand = New SqlCommand("insert into Invoices values('" & invoiceDate & "',"
& orderId & "," & customerId & "," & subTotal & "," &
shipping_handlingCost & "," & totalAmount & ",'" & paymentMode &
"')",
sqlConnection)
sqlCommand.ExecuteNonQuery()
End Sub
'This method returns the combination of Invoice Id and invoice date as string for the specif
order
Public Function retrieveInvoiceInfo(ByVal Id As Integer) As String
sqlCommand = New SqlCommand("select invoiceId,invoiceDate from invoices where orderId=" &
Id & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Return ds.Tables(0).Rows(0).Item(0) & ";" & ds.Tables(0).Rows(0).Item(1)
Else
Return ""
End If
End Function
'This method returns the Invoice Id of the last invoice raised
Public Function retrieveInvoiceId() As Integer
sqlCommand = New SqlCommand("select max(invoiceId) from invoices", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Return ds.Tables(0).Rows(0).Item(0)
Else
Return 0
End If
End Function
End Class 'END CLASS DEFINITION Invoices

Download this Listing.

The above listing defines the following methods:

• generateInvoice(): Generates a new invoice and stores the invoice information in the
Invoices table.

• retrieveInvoiceInfo(): Accepts the order id as a parameter and returns the combination of an


invoice id and invoice date as a string that corresponds to the order id.

• retrieveInvoiceId(): Retrieves the invoice id of the last invoice generated.

Creating the InvoiceCreditCardInfo Class


The Invoices.vb file defines the InvoiceCreditCardInfo class that saves the credit card information of
a customer that the administrator specifies using the Invoice window.

Listing 2−6 shows the code for the InvoiceCreditCardInfo.vb file:


Listing 2−6: The InvoiceCreditCardInfo.vb File

'Static Model
Imports System.Data.SqlClient
Public Class InvoiceCreditCardInfo
Public invoiceId As Integer
Public nameOnCard As String
Public creditCardNumber As String
Private sqlCommand As sqlCommand

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 12

Public Sub New(ByVal invoiceId As Integer, ByVal nameOnCard As String, ByVal creditCardNu
Me.invoiceId = invoiceId
Me.nameOnCard = nameOnCard
Me.creditCardNumber = creditCardNumber
End Sub
'This method saves the credit card information of the customer.
Public Sub saveCreditCardInfo()
sqlCommand = New SqlCommand("insert into InvoiceCreditCardInfo values(" & invoiceId
&
",'" & nameOnCard & "','" & creditCardNumber & "')", sqlConnection)
sqlCommand.ExecuteNonQuery()
End Sub
End Class
'END CLASS DEFINITION InvoiceCreditCardInfo

Download this Listing.

In the above listing, the saveCreditCardInfo method saves the customer’s credit card information
into the InvoiceCreditCardInfo table.

Creating the Shared Module


The Shared.vb file defines the Shared module that provides the main() function to initiate the Order
Processing application.

Listing 2−7 shows the code for the Shared.vb file:


Listing 2−7: The Shared.vb File

Imports System.Data.SqlClient
Imports System.IO
Module _Shared
'A variable to store the login role. The role can be of administrator or customer.
Public loginRole As String
'Stores the id of the customer
Public custId As Integer
'A boolean variable that keeps in track the success and failure of invoice generation proces
Public boolInvoiceGeneration As Boolean
Dim strSqlConnection As String
Public sqlConnection As New sqlConnection
Public Sub main()
'Try to establish connection with database OrderProcessing through SQLClient Connection o
Try
Try
'Read connection string from a text file settings,text located in /bin folder of the a
Dim sr As New StreamReader("Settings.txt")
strSqlConnection = sr.ReadLine
sr.Close()
Catch ex As Exception
'If file settings.txt not found
strSqlConnection = "SERVER=localhost;UID=sa;PWD=sa;Initial
Catalog=OrderProcessing"
End Try
sqlConnection.ConnectionString = strSqlConnection
sqlConnection.Open()
Dim objLoginManager As New LoginManager
objLoginManager.ShowDialog()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
Exit Sub
End Try
End Sub
End Module

Download this Listing.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 13

In the above listing, the main() function establishes a connection with the OrderProcessing
database through a SqlConnection object and invokes the Login Manager window.

Creating the Login Manager Window


The LoginManager class defines the Login Manager window. The LoginManager class enables a
customer to specify the login credentials to place an order. The LoginManager class also enables a
new customer to register.

Listing 2−8 shows the code for the frmLoginManager.vb that defines the LoginManager class:
Listing 2−8: The frmLoginManager.vb File

Imports System.Data.SqlClient
Imports System.IO
Public Class LoginManager
Inherits System.Windows.Forms.Form
Dim strSqlConnection As String
Dim ds As DataSet
Dim sqlda As SqlDataAdapter
Dim sqlCommand As sqlCommand
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
cmdGo.Click
'Verifying the login credentials
Try
sqlCommand = New SqlCommand("select customerId from Customers where username='" &
txtUserName.Text & "' and password='" & txtPassWord.Text & "'", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
Catch ex As Exception
MsgBox("Error in login.", MsgBoxStyle.OKOnly, "LOGIN ERROR")
txtUserName.Focus()
Exit Sub
End Try
'To check whether the login attempt is successful
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
If txtUserName.Text = "administrator" Then
loginRole = "administrator"
Else
loginRole = "customer"
End If
custId = ds.Tables(0).Rows(0).Item(0)
'An object reference to the ApplicationManager class
Dim objApplicationManager As New ApplicationManager
objApplicationManager.ShowDialog()
txtUserName.Text = ""
txtPassWord.Text = ""
Else
MsgBox("Login Unsuccessful.", MsgBoxStyle.OKOnly, "INVALID LOGIN CREDENTIALS")
txtUserName.Focus()
Exit Sub
End If
End Sub
Private Sub cmdRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdRegister.Click
Dim objCustomerRegisteration As New CustomerRegistration
objCustomerRegisteration.ShowDialog()
If Not custId = 0 Then
loginRole = "customer"
txtUserName.Text = ""
txtPassWord.Text = ""
'An object reference to the ApplicationManager class
Dim objApplicationManager As New ApplicationManager
objApplicationManager.ShowDialog()
End If
End Sub
End Class

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 14

Download this Listing.

The above listing defines the following methods:

• cmdGo_Click(): Executes when a customer specifies the user name and password and
clicks the Login button. This method checks for the validity of the login information and
invokes the Application Manager window if the login information is correct.

• cmdRegister_Click(): Executes when a prospective customer clicks the New User Sign In
Here button to register and obtain access to the Place Order window. This method invokes
the Customer Registration window.

Figure 2−4 shows the output of Listing 2−8:

Figure 2−4: The Login Manager Window


Creating the Application Manager Window
The ApplicationManager class defines the Application Manager window that enables a customer to
access the Place Order and the View Order Status windows, and enables an administrator to
access the Update Order Status and the Raise Invoice windows.

Listing 2−9 shows the code for the frmApplicationManager.vb that defines the ApplicationManager
class:
Listing 2−9: The frmApplicationManager.vb File

Public Class ApplicationManager


Inherits System.Windows.Forms.Form
Private Sub ApplicationManager_Load(ByVal sender As System.Object, ByVal e As _ System.EventArg
If loginRole = "administrator" Then
mnuItemUpdateOrder.Enabled = True
mnuitemInvoice.Enabled = True
mnuViewOrderStatus.Enabled = False
mnuPlaceOrder.Enabled = False
Else
mnuItemUpdateOrder.Enabled = False
mnuitemInvoice.Enabled = False
mnuViewOrderStatus.Enabled = True
mnuPlaceOrder.Enabled = True
End If
End Sub
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Dim objPlaceOrder As New PlaceOrder
objPlaceOrder.ShowDialog()
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) H
Dim objViewOrderStatus As New ViewOrderStatus
objViewOrderStatus.ShowDialog()
End Sub
Private Sub mnuItemUpdateOrder_Click(ByVal sender As System.Object, ByVal e As System.Eve
Handles mnuItemUpdateOrder.Click
Dim objUpdateOrderStatus As New UpdateOrderStatus
objUpdateOrderStatus.ShowDialog()
End Sub

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 15

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) H


Dim objRaiseInvoice As New RaiseInvoice
objRaiseInvoice.ShowDialog()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• MenuItem6_Click(): Executes when a customer selects the Orders−>Place Order option to


place orders. This method invokes the Place Order window.

• MenuItem1_Click(): Executes when a customer selects the Orders−>View Order Status


option to view the status of orders. This method invokes the View Order Status window.

• mnuItemUpdateOrder_Click(): Executes when the administrator selects the Orders−>Update


Order option to update the status of orders. This method invokes the Update Order Status
window.

• MenuItem4_Click(): Executes when the administrator selects the Invoice−>Raise Invoice


option to raise invoices for completed orders. This method invokes the Raise Invoice
window.

Figure 2−5 shows the output of Listing 2−9:

Figure 2−5: The Application Manager Window


The customer uses the Orders menu to place orders and view the status of orders. The
administrator uses the Orders menu to update the status of orders and uses the Invoices menu to
raise the invoices for completed orders.

Creating the Place Order Window


The PlaceOrder class defines the Place Order window. The PlaceOrder class displays the available
products and enables a customer to select products and place an order.

Listing 2−10 shows the code for the frmPlaceOrder.vb that defines the PlaceOrder class:
Listing 2−10: The frmPlaceOrder.vb File

Imports System.Data.SqlClient
Public Class PlaceOrder
Inherits System.Windows.Forms.Form
Dim ds As DataSet
Dim sqlda As SqlDataAdapter
Dim sqlCommand As sqlCommand

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 16

Dim tempListViewItem As ListViewItem


Private Sub PlaceOrder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'Retrieve product list from the database.
Try
sqlCommand = New SqlCommand("select product from products", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
Catch ex As Exception
MsgBox("Unable to retrieve products.", MsgBoxStyle.OKOnly, "Retrieval Error")
Exit Sub
End Try
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
Dim rowcount As Integer
For rowcount = 0 To ds.Tables(0).Rows.Count − 1
productCombo.Items.Add(ds.Tables(0).Rows(rowcount).Item(0))
Next
productCombo.SelectedIndex = 0
Else
MsgBox("No product found.", MsgBoxStyle.OKOnly, "First update product information")
Exit Sub
End If
End Sub
Private Sub productCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles productCombo.SelectedIndexChanged
If Not productCombo.Text = "" Then
'Retrieve quantity available and unit price of the selected product.
Try
sqlCommand = New SqlCommand("select unitPrice,qtyInHand from products where product
&
productCombo.Text & "'", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
txtUnitPrice.Text = ds.Tables(0).Rows(0).Item(0)
Dim itemCount As Integer
Dim qtyAvailable As Integer = ds.Tables(0).Rows(0).Item(1)
For itemCount = 0 To listviewOrder.Items.Count − 1
If listviewOrder.Items(itemCount).Text = productCombo.Text Then
qtyAvailable = qtyAvailable −
Integer.Parse(listviewOrder.Items(itemCount).SubItems(1).Text)
End If
Next
txtQuantityAvailable.Text = qtyAvailable
End If
Catch ex As Exception
MsgBox("Unable to retrieve information for the selected product.", MsgBoxStyle.OKOn
"Retrieval Error")
Exit Sub
End Try
End If
End Sub
Private Sub txtQuantity_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtQuantity.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
If e.KeyChar = vbBack Then
Exit Sub
End If
e.Handled = True
End If
End Sub
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
If Not productCombo.Text = "" And Not txtQuantity.Text = "" And Not txtQuantity.Text = "0
Then
If Double.Parse(txtQuantity.Text) > Double.Parse(txtQuantityAvailable.Text) Then
MsgBox("Order quantity cannot be greater than available quantity.", MsgBoxStyle.OKO
check the value")
txtQuantity.Focus()
Exit Sub
End If
'Add the product into the listviewOrder as listviewOrder displays the products in your
tempListViewItem = listviewOrder.Items.Add(productCombo.Text)
tempListViewItem.SubItems.Add(txtQuantity.Text)
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 17

tempListViewItem.SubItems.Add(Double.Parse(txtUnitPrice.Text) * Double.Parse(txtQuanti
txtQuantityAvailable.Text = Integer.Parse(txtQuantityAvailable.Text) −
Integer.Parse(txtQuantity.Text)
Dim itemCount As Integer
Dim dblTotalAmount As Double
For itemCount = 0 To listviewOrder.Items.Count − 1
dblTotalAmount = dblTotalAmount +
Double.Parse(listviewOrder.Items(itemCount).SubItems(2).Text)
Next
txtAmount.Text = dblTotalAmount
txtQuantity.Text = ""
productCombo.Focus()
End If
End Sub
Private Sub cmdPlaceOrder_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles cmdPlaceOrder.Click
If Not listviewOrder.Items.Count = 0 Then
Dim dt As System.DateTime
'Creating an object of type Orders
Dim objOrders As New Orders
objOrders.customerId = custId
objOrders.amount = Double.Parse(txtAmount.Text)
objOrders.orderDate = dt.Today
'Call the SaveOrder method of Orders class to save the order
Dim orderId As Integer = objOrders.SaveOrder
'If the order is successfully saved then
If orderId <> 0 Then
Try
Dim itemCount As Integer
For itemCount = 0 To listviewOrder.Items.Count − 1
'Save the product wise order information into the database
Dim objOrderInformation As New OrderInformation
objOrderInformation.orderId = orderId
'Retrieve the product Id of the selected product
sqlCommand = New SqlCommand("select productId from products where product='" &
listviewOrder.Items(itemCount).Text & "'", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
objOrderInformation.productId = ds.Tables(0).Rows(0).Item(0)
objOrderInformation.quantity = Integer.Parse(listviewOrder.Items(itemCount).SubI
'Call the SaveOrderInfo method of OrderInformantion class to save the product wi
of the order
objOrderInformation.SaveOrderInfo()
'Update the product quantity
sqlCommand = New SqlCommand("update products set qtyInHand=qtyInHand−" &
Integer.Parse(listviewOrder.Items(itemCount).SubItems(1).Text) & " where product
listviewOrder.Items(itemCount).Text & "'", sqlConnection)
sqlCommand.ExecuteNonQuery()
Next
Catch ex As Exception
MsgBox("Your order cannot be saved.", MsgBoxStyle.OKOnly, "Database Error")
Exit Sub
End Try
Else
MsgBox("Your order cannot be saved.", MsgBoxStyle.OKOnly, "Database Error")
Exit Sub
End If
MsgBox("Your order is saved successfully. Your ORDER ID is " & orderId & ".", MsgBoxStyle
listviewOrder.Items.Clear()
txtAmount.Text = ""
productCombo.Focus()
End If
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:


Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 18

• PlaceOrder_Load(): Retrieves the available products from the database and displays the
products in the productCombo drop−down list box.

• cmdAdd_Click(): Executes when a customer selects a product, specifies the quantity, and
clicks the Add to Order button to add the selected product in the current order. This method
adds the selected product in the listviewOrder list view control that represents the current
order.

• cmdPlaceOrder_Click(): Executes when a customer clicks the Place Order button to place
an order for the selected products. This method calls the SaveOrder() method of the Orders
class to save the order information, such as the order date, customer id, and total amount. It
then calls the SaveOrderInfo() method of the OrderInformation class to save the product
information, such as the product id and the quantity for that product in the order.

Figure 2−6 shows the output of Listing 2−10:

Figure 2−6: The Place Order Window


Creating the View Order Status Window
The ViewOrderStatus class defines the View Order Status window. The ViewOrderStatus class
enables a customer to view the status of an order.

Listing 2−11 shows the code for the frmViewOrderStatus.vb that defines the ViewOrderStatus class:
Listing 2−11: The frmViewOrderStatus.vb File

Imports System.Data.SqlClient
Public Class ViewOrderStatus
Inherits System.Windows.Forms.Form
Dim ds As DataSet
Dim sqlda As SqlDataAdapter
Dim sqlCommand As sqlCommand
Private Sub txtOrderId_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtOrderId.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
If e.KeyChar = vbBack Then
Exit Sub
End If
e.Handled = True
End If
End Sub
Private Sub cmdViewStatus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Hand
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 19

If Not txtOrderId.Text = "" Then


Dim strStatus As String
Try
Dim objOrders As New Orders
strStatus = objOrders.RetrieveOrderStatus(txtOrderId.Text)
If strStatus = "" Then
MsgBox("Invalid OrderId", MsgBoxStyle.OKOnly, "Please check the orderId")
Exit Sub
End If
If strStatus = "pending" Then
lblStatus.Text = "Your order referenced by Order Id " & txtOrderId.Text & "
is being processed."
Else
Dim tempArray() As String
tempArray = strStatus.Split(";")
'If the status of the order is completed then show the completion date
If tempArray(0) = "completed" Then
lblStatus.Text = "Your order has been processed. Completion date for your order is
tempArray(1) & "."
Else
'If the status of the order is invoiced then show the invoice id and invoice date
lblStatus.Text = "Your invoice for this order has been generated. Invoice Id is " &
tempArray(1) & " and date of generation is " & tempArray(2) & "."
End If
End If
Catch ex As Exception
MsgBox("Unable to view the order status", MsgBoxStyle.OKOnly, "Database Error")
End Try
End If
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha
cmdClose.Click
Me.Close()
End Sub
End Class

Download this Listing.

In the above listing, the cmdViewStatus_Click() method executes when a customer specifies an
order id and clicks the View Status button to view the status of the order referred to by that order id.
This method calls the RetrieveOrderStatus() method of the Orders class to retrieve the status and
displays the retrieved status in the lblStatus label.

Figure 2−7 shows the output of Listing 2−11:

Figure 2−7: The View Order Status Window


Creating the Update Order Status Window
The UpdateOrderStatus class defines the Update Order Status window. The UpdateOrderStatus
class displays all pending orders and enables the administrator to update the status of pending
orders as completed.

Listing 2−12 shows the code for the frmUpdateOrderStatus.vb that defines the UpdateOrderStatus
class:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 20
Listing 2−12: The frmUpdateOrderStatus.vb File

Imports System.Data.SqlClient
Public Class UpdateOrderStatus
Inherits System.Windows.Forms.Form
Dim tempListViewItem As ListViewItem
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdUpdate.Click
If Not listviewOrders.SelectedItems.Count = 0 Then
'Update the status of the order as completed
Dim dt As System.DateTime
Try
Dim objOrders As New Orders
'Call the UpdateOrderStatus method of the class Orders to update the status of _
the selected order as completed
objOrders.UpdateOrderStatus(listviewOrders.SelectedItems(0).Text, "completed")
listviewOrders.Items.Remove(listviewOrders.SelectedItems(0))
Catch ex As Exception
MsgBox("Unable to update the status of the selected order.", MsgBoxStyle.OKOnly,
Exit Sub
End Try
End If
End Sub
Private Sub UpdateOrderStatus_Load(ByVal sender As Object, ByVal e As System.EventArgs
Handles MyBase.Load
'An arraylist object to hold the order objects passed by RetrieveOrderByStatus method
Dim arrayOrders As ArrayList
Try
Dim objOrders As New Orders
arrayOrders = objOrders.RetrieveOrderByStatus("P")
If Not arrayOrders.Count = 0 Then
Dim cnt As Integer
For cnt = 0 To arrayOrders.Count − 1
Dim tempObjOrders As Orders
tempObjOrders = arrayOrders(cnt)
tempListViewItem = listviewOrders.Items.Add(tempObjOrders.orderId)
tempListViewItem.SubItems.Add(tempObjOrders.orderDate)
'Retrieving the customer name
sqlCommand = New SqlCommand("select firstname, lastname from customers where
tempObjOrders.customerId & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(0).Item(0) & " " &
ds.Tables(0).Rows(0).Item(1))
Else
tempListViewItem.SubItems.Add("")
End If
tempListViewItem.SubItems.Add(tempObjOrders.amount)
Next
Else
MsgBox("No orders are pending.", MsgBoxStyle.OKOnly, "No orders to be completed")
Exit Sub
End If
Catch ex As Exception
MsgBox("Unable to retrieve pending orders.", MsgBoxStyle.OKOnly, "Retrieval Error")
Exit Sub
End Try
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha
Me.Close()
End Sub
Private Sub cmdViewInformation_Click(ByVal sender As System.Object, ByVal e As _ System.E
Handles cmdViewInformation.Click
'Retrieve product wise information for the selected order.
If Not listviewOrders.SelectedItems.Count = 0 Then
Dim objViewOrderInfo As New ViewOrderInfo(listviewOrders.SelectedItems(0).Text)
objViewOrderInfo.ShowDialog()
End If
End Sub

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 21

End Class

Download this Listing.

The above listing defines the following methods:

• UpdateOrderStatus_Load(): Calls the RetrieveOrderByStatus() method of the Orders class


to retrieve the pending orders and displays the order information in the listViewOrders list
view control.

• cmdViewInformation_Click(): Executes when the administrator selects an order from


listViewOrders and clicks the View Information button to view the product information for the
selected order. This method invokes the View Order Information window that displays the
product information.

• cmdUpdate_Click(): Executes when the administrator selects an order from the


listViewOrders list view control and clicks the Update Order button to update the status of
the order as completed. This method calls the UpdateOrderStatus() method of the Orders
class to update the status.

Figure 2−8 shows the output of Listing 2−12:

Figure 2−8: The Update Order Status Window


Creating the View Order Information Window
The ViewOrderInfo class defines the View Order Information window. The ViewOrderInfo class
displays the products and the quantities required for a specific order.

Listing 2−13 shows the code for the frmViewOrderInfo.vb that defines the ViewOrderInfo class:
Listing 2−13: The frmViewOrderInfo.vb File

'This class displays the product wise information for an order


Imports System.Data.SqlClient
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 22

Public Class ViewOrderInfo


Inherits System.Windows.Forms.Form
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Dim orderId As Integer
Public Sub New(ByVal id As Integer)
MyBase.New()
InitializeComponent()
orderId = id
End Sub
Dim tempListViewItem As ListViewItem
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha
Me.Close()
End Sub
Private Sub ViewOrderInfo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handl
'An arraylist object to hold the OrderInformation objects passed by RetrieveOrderInfo _
method of OrderInformation class.
Dim arrayOrderInformation As ArrayList
Dim objOrderInformation As New OrderInformation
Try
arrayOrderInformation = objOrderInformation.RetrieveOrderInfo(orderId)
If Not arrayOrderInformation.Count = 0 Then
Dim cnt As Integer
For cnt = 0 To arrayOrderInformation.Count − 1
Dim tempObjOrderInformation As OrderInformation
tempObjOrderInformation = arrayOrderInformation(cnt)
tempListViewItem = listviewOrders.Items.Add(tempObjOrderInformation.orderId)
'Retrieving the product name
sqlCommand = New SqlCommand("select product from products where productId=" &
tempObjOrderInformation.productId & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(0).Item(0))
Else
tempListViewItem.SubItems.Add("")
End If
tempListViewItem.SubItems.Add(tempObjOrderInformation.quantity)
Next
End If
Catch ex As Exception
MsgBox("Unable to retrieve order information.", MsgBoxStyle.OKOnly, "Retrieval Error")
Me.Close()
End Try
End Sub
End Class

Download this Listing.

In the above listing, the ViewOrderInfo_Load() method calls the RetrieveOrderInfo() method of the
Orders class to retrieve the product information for the order and displays the information in the
listviewOrders list view control.

Figure 2−9 shows the output of Listing 2−13:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 23

Figure 2−9: The View Order Information Window


Creating the Raise Invoice Window
The RaiseInvoice class defines the Raise Invoice window. The RaiseInvoice class displays all the
orders that have been completed and enables the administrator to select an order and raise an
invoice for that order.

Listing 2−14 shows the code for the frmRaiseInvoice.vb that defines the RaiseInvoice class:
Listing 2−14: The frmRaiseInvoice.vb File

Imports System.Data.SqlClient
Public Class RaiseInvoice
Inherits System.Windows.Forms.Form
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Dim tempListViewItem As ListViewItem
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha
Me.Close()
End Sub
Private Sub RaiseInvoice_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handle
'An arraylist object to hold the order objects passed by RetrieveOrderByStatus method of
Dim arrayOrders As ArrayList
Try
Dim objOrders As New Orders
'Call the RetrieveOrderByStatus method to retrieve all completed orders
arrayOrders = objOrders.RetrieveOrderByStatus("C")
If Not arrayOrders.Count = 0 Then
Dim cnt As Integer
For cnt = 0 To arrayOrders.Count − 1
Dim tempObjOrders As Orders
tempObjOrders = arrayOrders(cnt)
tempListViewItem = listviewOrders.Items.Add(tempObjOrders.orderId)
tempListViewItem.SubItems.Add(tempObjOrders.orderDate)
tempListViewItem.SubItems.Add(tempObjOrders.customerId)
'Retrieving the customer name
sqlCommand = New SqlCommand("select firstname, lastname from customers where
customerId=" & tempObjOrders.customerId & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(0).Item(0) & " "
& ds.Tables(0).Rows(0).Item(1))
Else
tempListViewItem.SubItems.Add("")
End If
tempListViewItem.SubItems.Add(tempObjOrders.completionDate)

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 24

Next
Else
MsgBox("No orders are left to be invoiced.", MsgBoxStyle.OKOnly, "No orders left")
Me.Close()
End If
Catch ex As Exception
MsgBox("Unable to retrieve completed orders.", MsgBoxStyle.OKOnly, "Retrieval Error")
Me.Close()
End Try
End Sub
Private Sub cmdRaise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha
If Not listviewOrders.SelectedItems.Count = 0 Then
Dim objInvoice As New Invoice(listviewOrders.SelectedItems(0).Text, _
listviewOrders.SelectedItems(0).SubItems(2).Text)
objInvoice.ShowDialog()
End If
'If invoice generation was a success
If boolInvoiceGeneration = True Then
'Update the status of the selected order to invoiced(I)
Dim objOrders As New Orders
objOrders.UpdateOrderStatus(listviewOrders.SelectedItems(0).Text, "invoiced")
listviewOrders.Items.Remove(listviewOrders.SelectedItems(0))
End If
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• RaiseInvoice_Load(): Calls the RetrieveOrderByStatus() method of the Orders class to


retrieve information about the orders that have been completed and displays the information
in the listviewOrders list view control.

• cmdRaise_Click(): Executes when the administrator selects an order and clicks the Raise
button to raise an invoice for the selected order. This method invokes the Invoice window.

Figure 2−10 shows the output of Listing 2−14:

Figure 2−10: The Raise Invoice Window

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 25

Creating the Invoice Window


The Invoice class defines the Invoice window. The Invoice class displays the order, customer, and
company information and enables the administrator to generate the invoice for an order selected
from the Raise Invoice window.

Listing 2−15 shows the code for the frmInvoice.vb that defines the Invoice class:
Listing 2−15: The frmInvoice.vb File

Imports System.Data.SqlClient
Public Class Invoice
Inherits System.Windows.Forms.Form
Dim sqlCommand As sqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Dim orderId As Integer
Dim customerId As Integer
Dim tempListViewItem As ListViewItem
Dim invoiceId As Integer
Public Sub New(ByVal oId As Integer, ByVal cId As Integer)
MyBase.New()
InitializeComponent()
orderId = oId
customerId = cId
End Sub
Private Sub Invoice_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim dt As System.DateTime
dtPicker.Value = dt.Today
'Retrieve the invoice id of the last invoice generated
Try
Dim objInvoices As New Invoices
invoiceId = objInvoices.retrieveInvoiceId() + 1
Catch ex As Exception
invoiceId = 1
End Try
lblInvoiceId.Text = lblInvoiceId.Text & " " & invoiceId
lblOrderId.Text = lblOrderId.Text & " " & orderId
'Retrieve company information
Try
sqlCommand = New SqlCommand("select * from Company", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables(0).Rows.Count = 0 Then
lblCompanyName.Text = lblCompanyName.Text & " : " & _
ds.Tables(0).Rows(0).Item(0)
lblCompanyAddress.Text = lblCompanyAddress.Text & " : " & _
ds.Tables(0).Rows(0).Item(1)
& ", " & ds.Tables(0).Rows(0).Item(2) & ", " & _
ds.Tables(0).Rows(0).Item(3)
& ", " & ds.Tables(0).Rows(0).Item(4)
lblCompanyPhone.Text = lblCompanyPhone.Text & " : " & _
ds.Tables(0).Rows(0).Item(5)
End If
Catch ex As Exception
MsgBox("Unable to retrieve company information.", MsgBoxStyle.OKOnly, "Retrieval Error
Me.Close()
End Try
'Retrieve Customer Information
Try
Dim objCustomers As New Customers
objCustomers.retrieveCustomerInformation(customerId)
If objCustomers.firstName = "" Then
MsgBox("Customer information not found.", MsgBoxStyle.OKOnly, "Retrieval Error")
Me.Close()
Else
lblCustomerName.Text = lblCustomerName.Text & " : " & objCustomers.firstName & " "
& objCustomers.lastName
lblAddress.Text = lblAddress.Text & " : " & objCustomers.address1 & " " _
& objCustomers.address2
lblCity.Text = lblCity.Text & " : " & objCustomers.city
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 26

lblCountry.Text = lblCountry.Text & " : " & objCustomers.country


lblZipCode.Text = lblZipCode.Text & " : " & objCustomers.zipCode
End If
Catch ex As Exception
MsgBox("Unable to retrieve customer information.", MsgBoxStyle.OKOnly, "Retrieval Erro
Me.Close()
End Try
'Retrieve Order Information. An arraylist object to hold the OrderInformation objects pas
RetrieveOrderInfo method of OrderInformation class.
Dim arrayOrderInformation As ArrayList
Dim objOrderInformation As New OrderInformation
Try
arrayOrderInformation = objOrderInformation.RetrieveOrderInfo(orderId)
If Not arrayOrderInformation.Count = 0 Then
Dim cnt As Integer
'A variable to calculate total billing amount for the order
Dim dblTotalAmount As Double = 0
For cnt = 0 To arrayOrderInformation.Count − 1
Dim tempObjOrderInformation As OrderInformation
tempObjOrderInformation = arrayOrderInformation(cnt)
'Retrieving the product name
sqlCommand = New SqlCommand("select product,unitPrice from products where produc
tempObjOrderInformation.productId & "", sqlConnection)
sqlda = New SqlDataAdapter(sqlCommand)
ds = New DataSet
sqlda.Fill(ds)
If Not ds.Tables.Count = 0 And Not ds.Tables(0).Rows.Count = 0 Then
tempListViewItem = listviewOrders.Items.Add(ds.Tables(0).Rows(0).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(0).Item(1))
Else
tempListViewItem = listviewOrders.Items.Add("")
tempListViewItem.SubItems.Add("")
End If
tempListViewItem.SubItems.Add(tempObjOrderInformation.quantity)
tempListViewItem.SubItems.Add(tempObjOrderInformation.quantity *
Double.Parse(ds.Tables(0).Rows(0).Item(1)))
dblTotalAmount = dblTotalAmount + tempObjOrderInformation.quantity *
Double.Parse(ds.Tables(0).Rows(0).Item(1))
Next
txtSubTotal.Text = dblTotalAmount
txtTotal.Text = dblTotalAmount
End If
Catch ex As Exception
MsgBox("Unable to retrieve order information.", MsgBoxStyle.OKOnly, "Retrieval Error")
Me.Close()
End Try
End Sub
Private Sub txtSubTotal_KeyPress(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyPressEventArgs) Handles txtSubTotal.KeyPress
e.Handled = True
End Sub
Private Sub txtTotal_KeyPress(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyPressEventArgs) Handles txtTotal.KeyPress
e.Handled = True
End Sub
Private Sub txtshipping_KeyPress(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyPressEventArgs) Handles txtshipping.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
If e.KeyChar = vbBack Then
Exit Sub
End If
e.Handled = True
End If
End Sub
Private Sub txtshipping_TextChanged(ByVal sender As System.Object, ByVal e As System.Even
Handles txtshipping.TextChanged
If txtshipping.Text = "" Then
txtshipping.Text = "0"
End If
txtTotal.Text = Double.Parse(txtSubTotal.Text) + Double.Parse(txtshipping.Text)
End Sub
Private Sub txtCreditCardNumber_KeyPress(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyPressEventArgs) Handles txtCreditCardNumber.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
If e.KeyChar = vbBack Then
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 27

Exit Sub
End If
e.Handled = True
End If
End Sub
Private Sub cashRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles cashRadioButton.CheckedChanged
If cashRadioButton.Checked = True Then
creditCardGroupBox.Enabled = False
Else
creditCardGroupBox.Enabled = True
End If
End Sub
Private Sub creditRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles creditRadioButton.CheckedChanged
If creditRadioButton.Checked = True Then
creditCardGroupBox.Enabled = True
Else
creditCardGroupBox.Enabled = False
End If
End Sub
Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdGenerate.Click
Dim dt As System.DateTime
If creditRadioButton.Checked = True Then
If txtNameOnCard.Text = "" Then
MsgBox("Please specify Name as on the credit card.", MsgBoxStyle.OKOnly, "Please _
specify the information")
Exit Sub
End If
If txtCreditCardNumber.Text = "" Then
MsgBox("Please specify credit card number.", MsgBoxStyle.OKOnly, "Please specify th
Exit Sub
End If
If dt.Today > dtPicker.Value Then
MsgBox("Your credit card has expired.", MsgBoxStyle.OKOnly, "Please check the infor
Exit Sub
End If
End If
Try
If txtshipping.Text = "" Then
txtshipping.Text = "0"
End If
'Create an object of the type Invoices that represent as invoice
Dim objInvoices As New Invoices
objInvoices.invoiceDate = dt.Today
objInvoices.orderId = orderId
objInvoices.shipping_handlingCost = txtshipping.Text
objInvoices.subTotal = txtSubTotal.Text
objInvoices.totalAmount = txtTotal.Text
If creditRadioButton.Checked = True Then
objInvoices.paymentMode = "credit card"
Else
objInvoices.paymentMode = "cash"
End If
'Call the generateInvoice method of the class Invoices to save the Invoice
objInvoices.generateInvoice()
If creditRadioButton.Checked = True Then
'Create an object of the type InvoiceCreditCardInfo
Dim objInvoiceCreditCardInfo As New InvoiceCreditCardInfo(invoiceId,
txtNameOnCard.Text, txtCreditCardNumber.Text)
'Call the saveCreditCardInfo method to save the credit card information
objInvoiceCreditCardInfo.saveCreditCardInfo()
End If
boolInvoiceGeneration = True
Me.Close()
Catch ex As Exception
MsgBox("Unable to generate the invoice.", MsgBoxStyle.OKOnly, "Database Error")
boolInvoiceGeneration = False
Me.Close()
End Try
End Sub
End Class

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 28

Download this Listing.

The above listing defines the following methods:

• Invoice_Load(): Calls the retrieveInvoiceId() method of the Invoices class to retrieve the id of
the last invoice generated. This method also calls the retriveCustomerInformation() method
of the Customer class to retrieve the information of the customer who placed a particular
order. Then this method calls the RetrieveOrderInfo() method of the OrderInformation class
to display the product information in the listviewOrders list view control.

• cmdGenerate_Click(): Executes when the administrator specifies the shipping and handling
cost, selects the payment mode, and clicks the Generate Invoice button to generate the
invoice. This method calls the generateInvoice() method of the Invoice class that saves the
invoice information in the Invoices table.

Figure 2−11 shows the output of Listing 2−15:

Figure 2−11: The Invoice Window


Creating the Customer Registration Window
The CustomerRegistration class defines the CustomerRegistration window. The
CustomerRegistration class enables a prospective customer to specify the necessary information
for registration.

Listing 2−16 shows the code for the frmCustomerRegistration.vb that defines the
CustomerRegistration class:
Listing 2−16: The frmCustomerRegistration.vb File

Public Class CustomerRegistration


Inherits System.Windows.Forms.Form
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdAdd.Click
'Check for the completion of required information If txtUsername.Text = "" _

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 29

ThenMsgBox("Please specify user name.", MsgBoxStyle.OKOnly, "Please check the


information")
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox("Please specify the password.", MsgBoxStyle.OKOnly, "Please check the informati
Exit Sub
End If
If txtaddress1.Text = "" Then
MsgBox("Please specify address1.", MsgBoxStyle.OKOnly, "Please check the information")
Exit Sub
End If
If txtCity.Text = "" Then
MsgBox("Please specify city.", MsgBoxStyle.OKOnly, "Please check the information")
Exit Sub
End If
If txtCountry.Text = "" Then
MsgBox("Please specify country.", MsgBoxStyle.OKOnly, "Please check the information")
Exit Sub
End If
If txtZipcode.Text = "" Then
MsgBox("Please specify zip code.", MsgBoxStyle.OKOnly, "Please check the information"
Exit Sub
End If
If txtfirstname.Text = "" Then
MsgBox("Please specify user name.", MsgBoxStyle.OKOnly, "Please check the information"
Exit Sub
End If
Try
'An object of the class Customers that represents a customer
Dim objCustomers As New Customers
objCustomers.address1 = txtaddress1.Text
objCustomers.address2 = txtAddress2.Text
objCustomers.city = txtCity.Text
objCustomers.country = txtCountry.Text
objCustomers.firstName = txtFirstName.Text
objCustomers.lastName = txtLastName.Text
objCustomers.password = txtPassword.Text
objCustomers.username = txtUsername.Text
objCustomers.zipCode = txtZipcode.Text
custId = objCustomers.addCustomerInformation
If custId = 0 Then
MsgBox("Unable to save the information.", MsgBoxStyle.OKOnly,
"Database Error")
Else
MsgBox("You are registered sucessfully.Your username is " & txtUsername.Text
& ".",
MsgBoxStyle.OKOnly, "SUCCESS")
End If
Me.Close()
Catch ex As Exception
MsgBox("Unable to save the information", MsgBoxStyle.OKOnly, "Database Error")
Me.Close()
End Try
End Sub
Private Sub txtZipcode_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtZipcode.KeyPress
If Not Char.IsDigit(e.KeyChar) Then
If e.KeyChar = vbBack Then
Exit Sub
End If
e.Handled = True
End If
End Sub
End Class

Download this Listing.

In the above listing, the cmdAdd_Click() method executes when a prospective customer specifies
customer information and clicks the Save button to save the information and register. This method
checks the validity of the information and calls the addCustomerInformation() method of the
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 30

Customers class that inserts the customer information in the Customers table.

Figure 2−12 shows the output of Listing 2−16:

Figure 2−12: The Customer Registration Window

Unit Testing
To execute the Order Processing application:

1. Execute the OrderProcessing.exe file. This file is located in the /bin folder of the
OrderProcessing folder. The Login Manager window appears, as shown in Figure 2−13:

Figure 2−13: The Login Manager Window

2. Specify the user name and password for a customer and click the Login button. The
Application Manager window appears, as shown in Figure 2−14:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 31

Figure 2−14: The Application Manager Window

3. Select Orders−>Place Order to place an order. The Place Order window appears, as shown
in Figure 2−15:

Figure 2−15: The Place Order Window

4. Select a product, specify the quantity required, and click the Add to Order button to add the
product to the Your Order list, as shown in Figure 2−16:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 32

Figure 2−16: Your Order List after the Customer Adds a Product.

5. Add some more products to the Your Order list.

6. Click the Place Order button to confirm and place the order. A confirmation message box
appears that shows the order id of the order placed, as shown in Figure 2−17:

Figure 2−17: The Confirmation Message Box

7. Click the Close button to close the Place Order window.

8. Select Orders−>View Order Status to view the status of an order. The View Order Status
window appears, as shown in Figure 2−18:

Figure 2−18: The View Order Status Window

9. Specify the Order id of the order and click the View Status button to view the status of that
order. The order status appears, as shown in Figure 2−19:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 33

Figure 2−19: The Order Status

10. Click the Close button to close the View Order Status window.

11. Close the Application Manager window.

12. Specify the administrator login information in the Login Manager window and select Login.
The Application Manager window appears, as shown in Figure 2−20:

Figure 2−20: The Application Manager Window Displaying Options for Administrator

13. Select Orders−>Update Order to update the status of pending orders. The Update Order
Status window appears, as shown in Figure 2−21:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 34

Figure 2−21: The Update Order Status Window

14. Select an order from the Pending Orders list and click the View Information button to view
the product information for that order. The View Order Information window appears, as
shown in Figure 2−22:

Figure 2−22: The View Order Information Window

15. Click the Close button to close the View Order Information window.

16. Select an order from the Pending Orders list and click the Update Order button to update the
status of that order.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 35

17. Click the Close button to close the Update Order Status window.

18. Close the Application Manager window.

19. Specify the same login information, as done in Step 2.

20. Repeat Steps 8−9 to view the status of the order that the administrator has updated. The
order status appears, as shown in Figure 2−23:

Figure 2−23: The View Order Status Window after Order Update

21. Repeat Steps 10−12.

22. Select Invoice−>Raise Invoice to raise invoices for updated orders. The Raise Invoice
window appears, as shown in the Figure 2−24:

Figure 2−24: The Raise Invoice Window

23. Select an order and click the Raise button. The Invoice window appears, as shown in Figure
2−25:

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 36

Figure 2−25: The Invoice Window

24. Specify the shipping and handling cost and credit card information if required, and click the
Generate Invoice button to generate the invoice.

25. Click the Close button to close the Raise Invoice window.

26. Close the Application Manager window.

27. Repeat the Steps 8−9 to view the status of those orders where the invoice has been
generated by the administrator. The View Order Status window displays the status of the
invoiced order, as shown in Figure 2−26:

Figure 2−26: The View Order Status Window after Invoice Generation

28. Click the Close button to close the View Order Status window.

29. Close the Application Manger window.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 37

30. Close the Login Manager window.

Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited

You might also like