You are on page 1of 36

.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 4: Creating the UML Static Model Diagram from the Query Tracker Application.......1
Architecture of the Query Tracker Application.......................................................................1
Creating the Database Schema.............................................................................................3
Creating the QueryTrackerAdministrator Application.............................................................5
Creating the Application Manager Window......................................................................5
Creating the Login Manager Window...............................................................................6
Creating the Executive Manager Window........................................................................7
Creating the Query Manager Window............................................................................10
Creating the Forward Pending Query to Executive Window..........................................12
Creating the View Query Status Window.......................................................................15
Creating the QueryTrackerRemotingObject Project............................................................22
Creating the QueryTrackerServerListener Project...............................................................24
Creating the QueryTrackerClient Application.......................................................................25
Creating the Executive Login Window...........................................................................25
Creating the Query Tracker Client Window....................................................................25
Creating the InitializeQueryProvider Module..................................................................27
Unit Testing..........................................................................................................................28
Downloads...........................................................................................................................34
Chapter 4: Creating the UML Static Model Diagram
from the Query Tracker Application

Download CD Content
Reverse engineering in Visual Studio .NET 2003 enables you to generate Unified Modeling
language (UML) static model diagram from code in .NET applications. Reverse engineering maps
the classes, namespaces, and methods in the .NET application code to the UML static model
diagram and generates classes in the UML Model Explorer window of Visio.

This chapter explains how to create a QueryTracker UML static model diagram by reverse
engineering the code of the Query Tracker application, which is a Visual Studio.NET application.

Architecture of the Query Tracker Application


The Query Tracker application consists of four projects:

• QueryTrackerAdministrator

• QueryTrackerRemotingObject

• QueryTrackerServerListener

• QueryTrackerClient

The QueryTrackerAdministrator project enables the administrator to enter customer queries in the
database and assign them later to customer support executives to resolve queries. The
QueryTrackerAdministrator application connects to the SQL Server, retrieves a list of existing
executives and their departments, and provides the status of registered queries.

The QueryTrackerRemotingObject project provides the remoting object that retrieves the queries
meant for a particular customer support executive from the QueryTracker database and updates the
status of the queries when customer service executives have resolved these queries.

The QueryTrackerServerListener project registers the remoting object provided by the


QueryTrackerRemotingObject project to a particular Transfer Control protocol (TCP) channel. This
project provides the server that enables the QueryTrackerClient project to retrieve queries from the
remoting object.

The QueryTrackerClient project enables executives to access queries provided by the remoting
object and to mark the queries as attended to when the executives have dealt with the queries.

Figure 4−1 shows the architecture of the Query Tracker application:

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

Figure 4−1: The Query Tracker Application Architecture


The QueryTrackerAdministrator project consists of the following files:

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


Application Manager window, using which the administrator can access information about
executives and queries.

• frmLoginManager.vb: Provides the LoginManager class that defines the Login Manager
window, which enables the administrator to log on to the application.

• frmExecutiveManager.vb: Provides the ExecutiveManger class that defines the Executive


Manager window, where the administrator can add information about an executive into the
database.

• frmQueryManager.vb: Provides the QueryManager class that defines the Query Manager
window, where the administrator can register customer queries into the database.

• frmForwardQueryToExecutive.vb: Provides the ForwardQueryToExecutive class that defines


the Forward Pending Query To Executive window, which enables the administrator to assign
customer queries to customer support executives.

• frmViewStatus.vb: Provides the ViewStatus class that defines the View Query Status
window, which enables the administrator to view the status of the queries.

The QueryTrackerRemotingObject project consists of one file, QueryProvider.vb that provides the
QueryProvider class, which defines the remoting object. When the executive logs on to the
QueryTrackerClient application, the remoting object retrieves the queries meant for that executive.

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

When the executive marks the query as attended to, the remoting object updates the database
information for that query.

The QueryTrackerServerListener project consists of one file, Server.vb that provides the Server
class, which defines the server that registers the remoting object and listens for the request to
activate remoting object from the QueryTrackerClient application. The administrator runs the server
before the executives access the QueryTrackerClient application.

The QueryTrackerClient project consists of the following files:

• frmExecutiveLogin.vb: Provides the ExecutiveLogin class that defines the Executive Login
window, which enables the executives to log on to the application.

• frmQueryTrackerClient.vb: Provides the QueryTrackerClient class that defines the Query


Tracker Client window, where the executives can view and access the queries.

• InitializeQueryProvider.vb: Provides the InitializeQueryProvider module that creates and


registers a TCP channel to enable the application to access the QueryProvider remoting
object.

Figure 4−2 shows the class diagram for the Query Tracker application:

Figure 4−2: The Class Diagram for the Query Tracker Application

Creating the Database Schema


The Query Tracker application uses the QueryTracker database to store information about the
executives and the queries they handle.

Listing 4−1 shows the SQL script to generate the database on the SQL Server:
Listing 4−1: Creating the QueryTracker Database

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


[CustSupportExecutives]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 4

drop table [dbo].[CustSupportExecutives]


GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Departments]') _
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Departments]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ExecDept]') _
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ExecDept]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ExecQuery]') _
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ExecQuery]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[LoginAdministrator]') _
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[LoginAdministrator]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Queries]') _
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Queries]
GO
CREATE TABLE [dbo].[CustSupportExecutives] (
[EId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[FirstName] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[LastName] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Address] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Title] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Pwd] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Departments] (
[DId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[Name] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[ExecDept] (
[EId] [int] NOT NULL ,
[DId] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[ExecQuery] (
[EId] [int] NOT NULL ,
[QueryId] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[LoginAdministrator] (
[AdminName] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[AdminPwd] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Queries] (
[QueryId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[QueryTitle] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[QueryDesc] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[QueryDate] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Customer] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Status] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[CompDate] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

Download this Listing.

The above listing creates the QueryTracker database for the Query Tracker application. The above
code creates the following tables in the database:

• CustSupportExecutives: Stores information about the executives, such as the executive id,
name, contact details, and the password assigned to the executive.

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

• Departments: Stores information about the departments in the organization, such as the
dept ID and department name.

• Queries: Stores information about customer queries, such as the query ID, title, description
of the query, date of the query, status of the query, and date on which the customer support
executives attended the query.

• LoginAdministrator: Stores the user name and password for the administrator.

• ExecDept: Stores information about executives and their departments.

• ExecQuery: Stores the mapping of queries to executives.

Creating the QueryTrackerAdministrator Application


To create the QueryTrackerAdministrator application, you need to create the Application Manager,
Executive Manager, Forward Pending Query To Executive, Login Manager, Query Manager, and
View Query Status windows.

Creating the Application Manager Window


The frmApplicationManager class defines the Application Manager window.

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

Public Class frmApplicationManager


Inherits System.Windows.Forms.Form
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
'An object reference to class ExecutiveManager to define window Executives Manager
Dim objExecManager As New ExecutiveManager
objExecManager.ShowDialog()
End Sub
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
'An object reference to class QueryManager to define window Query Manager
Dim objQueryManager As New QueryManager
objQueryManager.ShowDialog()
End Sub
Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
'An object reference to class ForwardQueryToExecutive to define window Forward Query To E
Dim objForwardQuery As New ForwardQueryToExecutive
objForwardQuery.ShowDialog()
End Sub
Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
'An object reference to class ViewStatus to define window View Query Status
Dim objViewStatus As New ViewStatus
objViewStatus.ShowDialog()
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 6

• MenuItem2_Click(): Executes when the administrator selects the Executive Manager−>Add


Executive menu option. This method invokes the Executive Manager window.

• MenuItem6_Click(): Executes when the administrator selects the Query Manager−>Add


Query menu option. This method invokes the Query Manager window.

• MenuItem7_Click(): Executes when the administrator selects the Query Manager−>View


Status menu option. This method invokes the View Query Status window.

• MenuItem9_Click(): Executes when the administrator selects the Query Manager−>Forward


Query To Executive menu option. This method invokes the Forward Pending Query to
Executive window.

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

Figure 4−3: The Application Manager Window in Design View


Creating the Login Manager Window
The LoginManager class defines the Login Manager window. This window enables the administrator
to log on, enter new queries, and view the status of existing queries.

Listing 4−3 shows the code for the frmLoginManager.vb file that defines the LoginManager class:
Listing 4−3: The frmLoginManager.vb File

Imports System.Data.SqlClient
Imports System.IO
Imports System.Collections
Public Class LoginManager
Inherits System.Windows.Forms.Form
Dim strSqlConnection As String
Dim SqlConn As New SqlConnection
Dim dataReader As SqlDataReader
Dim SqlCom As New SqlCommand
Private Sub LoginManager_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles M
'Try to establish connection with database QueryTracker through SQLClient Connection obje
Try
Try
'Read the connection string from a text file settings.txt located in
'/bin folder of the application.
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=QueryTracker"
End Try
SqlConn.ConnectionString = strSqlConnection
SqlConn.Open()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
Exit Sub
End Try
End Sub
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Try

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

'Verifying the specified information for Administrator Login


SqlCom.CommandText = "select * from LoginAdministrator where adminName='" & _
txtUserName.Text & "' and adminPwd='" & txtPassWord.Text & "'"
SqlCom.Connection = SqlConn
dataReader = SqlCom.ExecuteReader
Catch ex As Exception
MsgBox("Error in administrator login", MsgBoxStyle.OKOnly, "LOGIN ERROR")
txtUserName.Focus()
Exit Sub
End Try
'To check whether the login attempt is successful
If dataReader.HasRows Then
'An object reference to frmMain form
Dim objApplicationManager As New frmApplicationManager
objApplicationManager.ShowDialog()
Me.Dispose()
txtUserName.Text = ""
txtPassWord.Text = ""
Else
MsgBox("Error in administrator login.Login Unsuccessful", MsgBoxStyle.OKOnly, "INVALID
txtUserName.Focus()
Exit Sub
End If
'closing the connection to the QueryTracker database
SqlConn.Close()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• LoginManager_Load(): Establishes a connection with the QueryTracker database through


an SQLConnection object.

• cmdGo_Click(): Executes when the administrator specifies the login credentials and clicks
the Login button. This method verifies the login credentials and enables the administrator to
log on to the application.

Figure 4−4 shows the output of Listing 4−3:

Figure 4−4: The Login Manager Window


Creating the Executive Manager Window
The ExecutiveManager class defines the Executive Manager window. This window enables the
administrator to add information about the new executive to the database.

Listing 4−4 shows the code for the frmExecutiveManager.vb file that defines the ExecutiveManager
class:
Listing 4−4: The frmExecutiveManager.vb File

Imports System.Data.SqlClient
Imports System.IO
Imports System.Collections
Public Class ExecutiveManager
Inherits System.Windows.Forms.Form
Dim sqlCon As New SqlConnection

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

Dim sqlCom As New SqlCommand


Dim dataReader As SqlDataReader
Dim strSQLConnection As String
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
'To check whether the required parameters are specified by the end user or not
'Checking for First Name
If txtFirstName.Text = "" Then
MsgBox("Please enter first name of the executive", MsgBoxStyle.OKOnly, "ENTER FIRST NA
txtFirstName.Focus()
Exit Sub
End If
'Checking for Last Name
If txtLastName.Text = "" Then
MsgBox("Please enter last name of the executive", MsgBoxStyle.OKOnly, "ENTER LAST NAME
txtLastName.Focus()
Exit Sub
End If
'Checking for Address
If txtAddress.Text = "" Then
MsgBox("Please enter address of the executive", MsgBoxStyle.OKOnly, "ENTER ADDRESS")
txtAddress.Focus()
Exit Sub
End If
'Checking for Job Title
If txtJobTitle.Text = "" Then
MsgBox("Please enter job title of the executive", MsgBoxStyle.OKOnly, "ENTER JOB TITLE
txtJobTitle.Focus()
Exit Sub
End If
'Checking for Password
If txtPassWord.Text = "" Then
MsgBox("Please enter password for the executive", MsgBoxStyle.OKOnly, "ENTER PASSWORD"
txtPassWord.Focus()
Exit Sub
End If
'If no department exists
If ListDept.SelectedItems.Count = 0 Then
MsgBox("Please select a department for the employee", MsgBoxStyle.OKOnly, "SELECT DEPA
ListDept.Focus()
Exit Sub
End If
'Inserting executive information into database
Try
sqlCom.CommandText = "insert into CustSupportExecutives values('" & _
txtFirstName.Text & "','" & txtLastName.Text & "','" & _
txtAddress.Text & "','" & txtJobTitle.Text & "','" & _
txtPassWord.Text & "')"
sqlCom.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error in inserting new executive information", MsgBoxStyle.OKOnly, "INSERTION
Exit Sub
End Try
'Getting the Department Id of the department selected for the executive
Dim DeptId As Integer
Try
sqlCom.CommandText = "Select DId from departments where name='" & _
ListDept.SelectedItem & "'"
dataReader = sqlCom.ExecuteReader()
If dataReader.HasRows Then
While dataReader.Read
DeptId = dataReader.GetValue(0)
End While
End If
dataReader.Close()
Catch ex As Exception
Exit Sub
End Try
'Getting the Executive Id of the newly added executive
Dim ExecId As Integer
Try
sqlCom.CommandText = "Select EId from CustSupportExecutives where firstname='" & _
txtFirstName.Text & "' and lastname='" & txtLastName.Text & _
"' and pwd='" & txtPassWord.Text & "'"
dataReader = sqlCom.ExecuteReader()
If dataReader.HasRows Then
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 9

While dataReader.Read
ExecId = dataReader.GetValue(0)
End While
End If
dataReader.Close()
Catch ex As Exception
Exit Sub
End Try
'Inserting information of executive's department
Try
sqlCom.CommandText = "insert into ExecDept values(" & ExecId & "," & DeptId & ")"
sqlCom.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error in inserting executive's department information", MsgBoxStyle.OKOnly, "I
Exit Sub
End Try
'Clear the fields
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtJobTitle.Text = ""
txtPassWord.Text = ""
txtFirstName.Focus()
End Sub
Private Sub ExecutiveManager_Load(ByVal sender As System.Object, ByVal e As System.EventArgs
'Try to establish SQL connection to database QueryTracker through SQL Connection object
Try
Try
'Read connectionstring from a text file settings.txt located in /bin folder of the
Dim sr As New StreamReader("Settings.txt")
strSQLConnection = sr.ReadLine
sr.Close()
Catch ex As Exception
strSQLConnection = "SERVER=localhost;UID=sa;PWD=sa;Initial Catalog=QueryTracker"
End Try
sqlCon.ConnectionString = strSQLConnection
sqlCon.Open()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
cmdAdd.Enabled = False
Exit Sub
End Try
Try
'Retrieving departments from the database
sqlCom.CommandText = "select * from departments"
sqlCom.Connection = sqlCon
dataReader = sqlCom.ExecuteReader
If dataReader.HasRows Then
'Populating ListDept with departments fetched by the datareader
While dataReader.Read
ListDept.Items.Add(dataReader.GetValue(1))
End While
Else
MsgBox("First enter the department details in the database table departments", _
MsgBoxStyle.OKOnly, "NO DEPARTMENT FOUND")
cmdAdd.Enabled = False
Exit Sub
End If
dataReader.Close()
Catch ex As Exception
MsgBox("Error in retrieving departments", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
cmdAdd.Enabled = False
Exit Sub
End Try
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 10

• ExecutiveManager_Load(): Establishes a connection with the QueryTracker database


through an SQLConnection object. This method then retrieves the available departments
and loads the ListDept list box control with the retrieved departments.

• cmdAdd_Click(): Executes when the administrator specifies the information for the executive
and clicks the Add New Executive button. This method checks for the validity of the specified
information and if the information is valid, the code adds information about the new
executive into the CustSupportExecutives table.

Figure 4−5 shows the output of Listing 4−4:

Figure 4−5: The Executive Manager Window


Creating the Query Manager Window
The QueryManager class defines the Query Manager window. This window enables the
administrator to specify new queries and related information.

Listing 4−5 shows the code for the frmQueryManager.vb file that defines the QueryManager class:
Listing 4−5: The frmQueryManager.vb File

Imports System.Data.SqlClient
Imports System.IO
Public Class QueryManager
Inherits System.Windows.Forms.Form
Dim sqlCon As New SqlConnection
Dim sqlCom As New SqlCommand
Dim dataReader As SqlDataReader
Dim strSQLConnection As String
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
'Verifying whether the required parameters are specified by the end user
'Checking for the Query Title
If txtCompTitle.Text = "" Then
MsgBox("Please enter title of the Query", MsgBoxStyle.OKOnly, "ENTER QUERY TITLE")
txtCompTitle.Focus()
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 11

Exit Sub
End If
'Checking for the Query Description
If txtCompDesc.Text = "" Then
MsgBox("Please enter description of the Query", MsgBoxStyle.OKOnly, "ENTER QUERY DESCR
txtCompDesc.Focus()
Exit Sub
End If
'Checking for the Customer Information who registered the query
If txtCustInfo.Text = "" Then
MsgBox("Please enter customer information", MsgBoxStyle.OKOnly, "ENTER CUSTOMER INFORM
txtCustInfo.Focus()
Exit Sub
End If
'Inserting query information into database
Try
sqlCom.CommandText = "insert into Queries values('" & txtCompTitle.Text & _
"','" & txtCompDesc.Text & "','" & _
selQueryDate.Value.ToShortDateString & "','" & txtCustInfo.Text & "','pending',NULL)"
sqlCom.Connection = sqlCon
sqlCom.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error in inserting query information", MsgBoxStyle.OKOnly, "INSERTION ERROR")
Exit Sub
End Try
'Clear the fields
txtCompTitle.Text = ""
txtCompDesc.Text = ""
txtCustInfo.Text = ""
txtCompTitle.Focus()
End Sub
Private Sub QueryManager_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles M
'Try to establish SQL connection to database QueryTracker through SQL Connection object
Try
Try
'Read connection string from a text file settings.txt located in /bin folder of the
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=QueryTracker"
End Try
sqlCon.ConnectionString = strSQLConnection
sqlCon.Open()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
cmdAdd.Enabled = False
Exit Sub
End Try
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handl
Me.Close()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• QueryManager_Load(): Establishes a connection with the database through an


SQLConnection object.

• cmdAdd_Click(): Executes when the administrator specifies the information for the query
such as the query description, query title, and customer name, and clicks the Add Query
button. This method checks for the validity of the specified information and if the information
is valid, the code adds the query information into the Queries table.

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

Figure 4−6 shows the output of Listing 4−5:

Figure 4−6: The Query Manager Window in Design View


Creating the Forward Pending Query to Executive Window
The ForwardQueryToExecutive class defines the Forward Pending Query to Executive window.
This window enables the administrator to forward pending queries submitted by customers to
customer support executives.

Listing 4−6 shows the code for the frmForwardQueryToExecutive.vb file that defines the
ForwardQueryToExecutive class:
Listing 4−6: The frmForwardQueryToExecutive.vb File

Imports System.Data.SqlClient
Imports System.IO
Imports System.Collections
Public Class ForwardQueryToExecutive
Inherits System.Windows.Forms.Form
Dim sqlCon As New SqlConnection
Dim sqlCom As New SqlCommand
Dim dataReader As SqlDataReader
Dim tempListViewItem As ListViewItem
Dim strSQLConnection As String
Private Sub ForwardQueryToExecutive_Load(ByVal sender As Object, ByVal e As System.EventArgs
'Try to establish SQL connection to database QueryTracker through SQL Connection object
Try
Try
'Read the connection string from a text file settings.txt located in /bin folder of
Dim sr As New StreamReader("Settings.txt")
strSQLConnection = sr.ReadLine
sr.Close()
Catch ex As Exception
strSQLConnection = "SERVER=localhost;UID=sa;PWD=sa;Initial Catalog=QueryTracker"
End Try
sqlCon.ConnectionString = strSQLConnection
sqlCon.Open()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
cmdForward.Enabled = False
Exit Sub
End Try
Try
'Retrieving pending Queries information
sqlCom.CommandText = "select QueryId, QueryTitle, QueryDesc, QueryDate from Queries wh
sqlCom.Connection = sqlCon

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

dataReader = sqlCom.ExecuteReader
If dataReader.HasRows Then
While dataReader.Read
'Populating ListViewQuery with Query information fetched by the datareader
tempListViewItem = ListViewQuery.Items.Add(dataReader.GetValue(0))
tempListViewItem.SubItems.Add(dataReader.GetValue(1))
tempListViewItem.SubItems.Add(dataReader.GetValue(2))
tempListViewItem.SubItems.Add(dataReader.GetValue(3))
End While
Else
'No queries found pending
cmdForward.Enabled = False
Exit Sub
End If
dataReader.Close()
Catch ex As Exception
MsgBox("Error in retrieving queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
cmdForward.Enabled = False
Exit Sub
End Try
Try
'Retrieving executives from database
sqlCom.CommandText = "select EId, FirstName, LastName, Title from CustSupportExecutive
Dim adapter As New SqlDataAdapter(sqlCom)
Dim ds As New DataSet
'Filling dataset with the retrieved executives
adapter.Fill(ds)
'A variable to iterate through the data set
Dim cnt As Integer
Dim deptds As New DataSet
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
'Populating ListViewExec with Executives related information fetched by the dat
tempListViewItem = ListViewExec.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
sqlCom.CommandText = "Select Name from departments where DId= _
(select DId from ExecDept where EId=" & ds.Tables(0).Rows(cnt).Item(0) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(deptds)
tempListViewItem.SubItems.Add(deptds.Tables(0).Rows(0).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(3))
Next
Else
'No Executives found
cmdForward.Enabled = False
Exit Sub
End If
Catch ex As Exception
MsgBox("Error in retrieving executives", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
cmdForward.Enabled = False
Exit Sub
End Try
End Sub
Private Sub cmdForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Han
'Checking whether the end user has selected any pending Query to be forwarded
If ListViewQuery.SelectedItems.Count = 0 Then
MsgBox("Please select the query to be forwarded", MsgBoxStyle.OKOnly, "SELECT QUERY")
Exit Sub
End If
'Checking whether the end user has selected an Executive to whom the selected Query is to
If ListViewExec.SelectedItems.Count = 0 Then
MsgBox("Please select the executive whom the query is to be forwarded", _
MsgBoxStyle.OKOnly, "SELECT EXECUTIVE")
Exit Sub
End If
Try
'Inserting the Executive−Query related information
sqlCom.CommandText = "insert into ExecQuery values(" & _
ListViewExec.SelectedItems(0).Text & " , " & _
ListViewQuery.SelectedItems(0).Text & ")"
sqlCom.ExecuteNonQuery()
'Updating the status of the selected Query
sqlCom.CommandText = "update Queries set status='forwarded' where QueryId=" & _
ListViewQuery.SelectedItems(0).Text & ""
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 14

sqlCom.ExecuteNonQuery()
'Removing the forwarded Query from the ListViewQuery
ListViewQuery.Items.RemoveAt(ListViewQuery.SelectedItems(0).Index)
Catch ex As Exception
MsgBox("Error in forwarding query to executive", MsgBoxStyle.OKOnly, "INSERTION ERROR"
End Try
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handl
Me.Close()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• ForwardQueryToExecutive_Load(): Establishes a connection to the QueryTracker database


and retrieves information regarding pending queries. It then displays the result in the
ListViewQuery list view control. This method also retrieves information regarding executives
and displays the results in the ListViewExec list view control.

• cmdForward_Click(): Executes when the administrator selects a pending query from the
pending queries list, selects a particular executive to resolve the query, and clicks the
Forward button. This method forwards the query to the selected executive, updates the
status of the query, and removes the query from the pending queries list.

Figure 4−7 shows the output of Listing 4−6:

Figure 4−7: The Forward Pending Query to Executive Window

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

Creating the View Query Status Window


The ViewStatus class defines the View Query Status window. This window enables the
administrator to view the status of queries and provides the flexibility to filter the information based
on department, executive, and date.

Listing 4−7 shows the code for the frmViewStatus.vb file that defines the ViewStatus class:
Listing 4−7: The frmViewStatus.vb File

Imports System.IO
Imports System.Data.SqlClient
Public Class ViewStatus
Inherits System.Windows.Forms.Form
Dim sqlCon As New SqlConnection
Dim sqlCom As New SqlCommand
Dim dataReader As SqlDataReader
Dim strSQLConnection As String
Dim tempListViewItem As ListViewItem
Dim boolPending As Boolean
Dim boolForwarded As Boolean
Dim boolAttended As Boolean
Private Sub ViewStatus_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyB
Try
Try
'Read the connection string from a text file settings.txt located in
'/bin folder of the application
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=QueryTracker"
End Try
sqlCon.ConnectionString = strSQLConnection
sqlCon.Open()
Catch ex As Exception
MsgBox("Error in establishing connection", MsgBoxStyle.OKOnly, "CONNECTION ERROR")
Exit Sub
End Try
showPending()
boolPending = True
End Sub
'This method is used to show pending Queries which are not assigned to any Executive yet.
Public Sub showPending()
Try
'Retrieving Information of the pending Queries
sqlCom.CommandText = _
"select QueryId, QueryTitle, QueryDate, CompDate from Queries where status='pending'"
sqlCom.Connection = sqlCon
Dim ds As New DataSet
Dim execds As New DataSet
Dim adapter As New SqlDataAdapter(sqlCom)
'Filling dataset with the Query Information
adapter.Fill(ds)
Dim cnt As Integer
ListViewQuery.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
'Population ListViewQuery with the information fetched by the dataset
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("pending")
Next
End If
Catch ex As Exception
MsgBox("Error in retrieving pending queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Exit Sub
End Try
End Sub
'This method is used to show Queries which forwarded to Executives.
Public Sub showForwarded()
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 16

Try
'Retrieving Information of the forwarded Queries
sqlCom.CommandText = _
"select QueryId,QueryTitle,QueryDate,CompDate from Queries where status='forwarded'"
Dim ds As New DataSet
Dim execds As New DataSet
Dim adapter As New SqlDataAdapter(sqlCom)
adapter.Fill(ds)
Dim cnt As Integer
ListViewQuery.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
'Population ListViewQuery with the information fetched by the dataset
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("forwarded")
'Fetching the Executive Name to whom the Query is forwared
sqlCom.CommandText = _
"Select FirstName,LastName from CustSupportExecutives where EId= _
(Select EId from ExecQuery where QueryId=" & ds.Tables(0).Rows(cnt).Item(0) & ")
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
'Adding Executive Name
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(0).Item(0) & _
" " & execds.Tables(0).Rows(0).Item(1))
execds.Clear()
Next
End If
Catch ex As Exception
MsgBox("Error in retrieving forwarded queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Exit Sub
End Try
End Sub
'This method is used to show Queries which attended by the respective Executives.
Public Sub showAttended()
Try
'Retrieving Information of the attended Queries
sqlCom.CommandText = "select QueryId,QueryTitle,QueryDate,CompDate from Queries where
Dim ds As New DataSet
Dim execds As New DataSet
Dim adapter As New SqlDataAdapter(sqlCom)
adapter.Fill(ds)
Dim cnt As Integer
ListViewQuery.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("attended")
sqlCom.CommandText = _
"Select FirstName,LastName from CustSupportExecutives where EId= _
(Select EId from ExecQuery where QueryId=" & ds.Tables(0).Rows(cnt).Item(0) & ")
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(0).Item(0) & _
" " & execds.Tables(0).Rows(0).Item(1))
If ds.Tables(0).Rows(cnt).IsNull(3) = True Then
tempListViewItem.SubItems.Add("")
Else
'Adding Query Attended On Date
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(3))
End If
execds.Clear()
Next
End If
Catch ex As Exception
MsgBox("Error in retrieving attended queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Exit Sub
End Try
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
boolPending = True
boolForwarded = False
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 17

boolAttended = False
showPending()
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
boolPending = False
boolForwarded = True
boolAttended = False
showForwarded()
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand
boolPending = False
boolForwarded = False
boolAttended = True
showAttended()
End Sub
Private Sub ViewNoFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Label1.Visible = False
ListFilter.Visible = False
cmdShow.Visible = False
End Sub
Private Sub ViewFilterExec_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handle
Label1.Visible = True
Label1.Text = "Select Executive"
ListFilter.Visible = True
cmdShow.Visible = True
showExec()
End Sub
'This method is used to retrieve Executives for filtering purpose
Public Sub showExec()
Try
sqlCom.CommandText = "select FirstName,LastName from CustSupportExecutives"
sqlCom.Connection = sqlCon
dataReader = sqlCom.ExecuteReader
ListFilter.Items.Clear()
If dataReader.HasRows Then
While dataReader.Read
ListFilter.Items.Add(dataReader.GetValue(0) & " " & dataReader.GetValue(1))
End While
End If
dataReader.Close()
Catch ex As Exception
MsgBox("Error in retrieving executives", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Label1.Visible = False
ListFilter.Visible = False
cmdShow.Visible = False
Exit Sub
End Try
End Sub
'This method is used to retrieve Departments for filtering purpose
Public Sub ShowDept()
Try
sqlCom.CommandText = "select * from departments"
dataReader = sqlCom.ExecuteReader
ListFilter.Items.Clear()
If dataReader.HasRows Then
While dataReader.Read
ListFilter.Items.Add(dataReader.GetValue(1))
End While
End If
dataReader.Close()
Catch ex As Exception
MsgBox("Error in retrieving departments", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Label1.Visible = False
ListFilter.Visible = False
cmdShow.Visible = False
End Try
End Sub
'This method is used to retrieve Dates for filtering purpose
Public Sub ShowDate()
Try
sqlCom.CommandText = "select distinct QueryDate from Queries"
dataReader = sqlCom.ExecuteReader
ListFilter.Items.Clear()
If dataReader.HasRows Then
While dataReader.Read
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 18

ListFilter.Items.Add(dataReader.GetValue(0))
End While
End If
dataReader.Close()
Catch ex As Exception
MsgBox("Error in retrieving query dates", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Label1.Visible = False
ListFilter.Visible = False
cmdShow.Visible = False
End Try
End Sub
Private Sub ViewFilterDept_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handle
Label1.Visible = True
Label1.Text = "Select Department"
ListFilter.Visible = True
cmdShow.Visible = True
ShowDept()
End Sub
Private Sub ViewFilterDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handle
Label1.Visible = True
Label1.Text = "Select Date"
ListFilter.Visible = True
cmdShow.Visible = True
ShowDate()
End Sub
Private Sub cmdShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSh
'Check whether there are Queries for filtering
If ListViewQuery.Items.Count = 0 Then
MsgBox("No queries to be filter", MsgBoxStyle.OKOnly)
Exit Sub
End If
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim cnt As Integer
Dim execds As New DataSet
Dim count As Integer
'If the end user chooses Filter by Department
If Label1.Text = "Select Department" Then
'If pending Queries Information is displayed in the ListViewQuery
If boolPending = True Then
MsgBox("Pending queries are not assigned to any executive", MsgBoxStyle.OKOnly, "PL
Exit Sub
End If
'If any department is selected
If ListFilter.SelectedItems.Count > 0 Then
Dim DeptId As Integer
Dim ExecId As Integer
Try
'Retrieve the Dept Id of the department selected
sqlCom.CommandText = "select DId from departments where name='" & _
ListFilter.SelectedItem & "'"
adapter.SelectCommand = sqlCom
adapter.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
DeptId = ds.Tables(0).Rows(0).Item(0)
End If
ds.Clear()
Catch ex As Exception
MsgBox("Error retrieving department information", MsgBoxStyle.OKOnly, "RETRIEVAL ER
Exit Sub
End Try
Try
'Retrieve information of all the Executives of the selected Department
sqlCom.CommandText = _
"select EId,FirstName,LastName from CustSupportExecutives where EId in _
(select EId from ExecDept where DId=" & DeptId & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(ds)
Catch ex As Exception
MsgBox("Error retrieving executives information", MsgBoxStyle.OKOnly, "RETRIEVAL ER
Exit Sub
End Try
ListViewQuery.Items.Clear()
For cnt = 0 To ds.Tables(0).Rows.Count − 1
'If forward Queries Information is displayed
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 19

If boolForwarded = True Then


Try
'Retrieve Query Information of Queries which are forwarded to the
Executives of the selected Department
sqlCom.CommandText = _
"select QueryId,QueryTitle,QueryDate,CompDate from Queries where status= _
'forwarded' and QueryId in (select QueryId from ExecQuery where EId=" & _
ds.Tables(0).Rows(cnt).Item(1) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
If execds.Tables(0).Rows.Count > 0 Then
For count = 0 To execds.Tables(0).Rows.Count − 1
tempListViewItem = _
ListViewQuery.Items.Add(execds.Tables(0).Rows(count).Item(0))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(1))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(2))
tempListViewItem.SubItems.Add("forwarded")
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2) & _
" " & ds.Tables(0).Rows(cnt).Item(3))
Next
End If
execds.Clear()
Catch ex As Exception
MsgBox("Error in retrieving forwarded queries", MsgBoxStyle.OKOnly, "RETRIEVAL E
Exit For
End Try
End If
'If attended Queries are displayed
If boolAttended = True Then
Try
'Retrieve Query Information of Queries which are attended by the
'Executives of the selected Department
sqlCom.CommandText = _
"select QueryId,QueryTitle,QueryDate,CompDate from Queries where status='attende
and QueryId in (select QueryId from ExecQuery where EId=" & _
ds.Tables(0).Rows(cnt).Item(1) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
If execds.Tables(0).Rows.Count > 0 Then
For count = 0 To execds.Tables(0).Rows.Count – 1
tempListViewItem = _
ListViewQuery.Items.Add(execds.Tables(0).Rows(count).Item(0))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(1))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(2))
tempListViewItem.SubItems.Add("attended")
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2) & _
" " & ds.Tables(0).Rows(cnt).Item(3))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(3))
Next
End If
execds.Clear()
Catch ex As Exception
MsgBox("Error in retrieving attended queries ", MsgBoxStyle.OKOnly, "RETRIEVAL E
Exit For
End Try
End If
Next
ds.Clear()
Else
MsgBox("First select a department", MsgBoxStyle.OKOnly, "SELECT DEPARTMENT")
End If
'If the end user selects the filtering criteria as Filter By Executive
ElseIf Label1.Text = "Select Executive" Then
If boolPending = True Then
MsgBox("Pending queries are not assigned to any executive", MsgBoxStyle.OKOnly, "PLEAS
Exit Sub
End If
'To check whether an Executive is selected
If ListFilter.SelectedItems.Count > 0 Then
Dim strTempName As String
Dim strTempNameSplit(2) As String
Dim strTempFirstName As String
Dim strTempLastName As String
strTempName = ListFilter.SelectedItem
'Break the name of the selected EXecutive into First Name and Last Name
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 20

strTempNameSplit = strTempName.Split(" "c)


strTempFirstName = strTempNameSplit(0)
strTempLastName = strTempNameSplit(1)
Try
sqlCom.CommandText = "select EId from CustSupportExecutives where FirstName='" & _
strTempFirstName & "' and LastName='" & strTempLastName & "'"
adapter.SelectCommand = sqlCom
adapter.Fill(ds)
Catch ex As Exception
MsgBox("Error retrieving executives information", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR
Exit Sub
End Try
ListViewQuery.Items.Clear()
If boolForwarded = True Then
Try
'Retrieve Query Information of Queries which are forwarded to the selected Executiv
sqlCom.CommandText = _
"select QueryId, QueryTitle, QueryDate, CompDate from Queries where _
status='forwarded' and QueryId in (select QueryId from ExecQuery where EId=" _
& ds.Tables(0).Rows(0).Item(0) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
If execds.Tables(0).Rows.Count > 0 Then
For count = 0 To execds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(execds.Tables(0).Rows(count).Item(0))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(1))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(2) _
tempListViewItem.SubItems.Add("forwarded")
tempListViewItem.SubItems.Add(ListFilter.SelectedItem)
Next
End If
execds.Tables.Clear()
Catch ex As Exception
MsgBox("Error in retrieving forwarded queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
End Try
End If
If boolAttended = True Then
Try
'Retrieve Query Information of Queries which are attended by the selected Executive.
sqlCom.CommandText = "select QueryId, QueryTitle, QueryDate, CompDate from Queries whe
status='attended' and QueryId in (select QueryId from ExecQuery where EId=" & _
ds.Tables(0).Rows(0).Item(0) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
If execds.Tables(0).Rows.Count > 0 Then
For count = 0 To execds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(execds.Tables(0).Rows(count).Item(0))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(1))
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(2))
tempListViewItem.SubItems.Add("attended")
tempListViewItem.SubItems.Add(ListFilter.SelectedItem)
'Adding Query Attended On Date
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(count).Item(3))
Next
End If
execds.Clear()
Catch ex As Exception
MsgBox("Error in retrieving attended queries ", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
End Try
End If
ds.Clear()
Else
MsgBox("First select an executive", MsgBoxStyle.OKOnly, "SELECT EXECUTIVE")
End If
Else
'The end user chooses Filter By Date option
If boolPending = True Then
Try
'Retrieve Query Information of pending Queries for a selected date
sqlCom.CommandText = _
"select QueryId, QueryTitle, QueryDate, CompDate from Queries where status='pending' a
& ListFilter.SelectedItem & "'"
adapter.SelectCommand = sqlCom
adapter.Fill(ds)
ListViewQuery.Items.Clear()
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 21

ds.Tables(0).Rows.Count > 0 Then


For cnt = 0 To ds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("pending")
Next
End If
Catch ex As Exception
MsgBox("Error in retrieving pending queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Exit Sub
End Try
ds.Clear()
ElseIf boolForwarded = True Then
Try
'Retrieve Query Information of forwarded Queries for a selected date
sqlCom.CommandText = _
"select QueryId,QueryTitle,QueryDate,CompDate from Queries where status='forwarded' and Q
& ListFilter.SelectedItem & "'"
adapter.SelectCommand = dsqlCom
adapter.Fill(ds)
ListViewQuery.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("forwarded")
sqlCom.CommandText = _
"Select FirstName,LastName from CustSupportExecutives where EId= _
(Select EId from ExecQuery where QueryId=" _
& ds.Tables(0).Rows(cnt).Item(0) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(0).Item(0) & _
" " & execds.Tables(0).Rows(0).Item(1))
execds.Clear()
Next
End If
Catch ex As Exception
MsgBox("Error in retrieving forwarded queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")
Exit Sub
End Try
ds.Clear()
Else
Try
'Retrieve Query Information of attended Queries for a selected date
sqlCom.CommandText = _
"select QueryId, QueryTitle, QueryDate, CompDate from Queries where status='attended'
& ListFilter.SelectedItem & "'"
adapter.SelectCommand = sqlCom
adapter.Fill(ds)
ListViewQuery.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
For cnt = 0 To ds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(cnt).Item(0))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(1)
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(2))
tempListViewItem.SubItems.Add("attended")
sqlCom.CommandText = "Select FirstName,LastName from CustSupportExecutives where EI
(Select EId from ExecQuery where QueryId=" & ds.Tables(0).Rows(cnt).Item(0) & ")"
adapter.SelectCommand = sqlCom
adapter.Fill(execds)
tempListViewItem.SubItems.Add(execds.Tables(0).Rows(0).Item(0) & _
" " & execds.Tables(0).Rows(0).Item(1))
'Check whether the Query Attended On Date is not null
If ds.Tables(0).Rows(cnt).IsNull(3) = True Then
tempListViewItem.SubItems.Add("")
Else
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(cnt).Item(3))
End If
execds.Clear()
Next
End If
Catch ex As Exception
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 22

MsgBox("Error in retrieving attended queries", MsgBoxStyle.OKOnly, "RETRIEVAL ERROR")


Exit Sub
End Try
End If
End If
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• ViewStatus_Load(): Retrieves pending queries and loads their information in the


ListViewQuery list view control.

• MenuItem3_Click(): Executes when the administrator selects the View Options−>Forwarded


Queries menu option. This method calls the showForwarded() method that retrieves
information about the queries that have been forwarded to executives.

• MenuItem4_Click(): Executes when the administrator selects the View Options−>Attended


Queries menu option. This method calls the showAttended() method that retrieves
information about the queries attended to by executives.

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

Figure 4−8: The View Query Status Window

Creating the QueryTrackerRemotingObject Project


To create the QueryTrackerRemotingObject project, you need to create the QueryProvider class
that defines the remoting object. The QueryProvider.vb file provides the QueryProvider class, which
provides methods to retrieve and update query information in the database.

Listing 4−8 shows the code for the QueryProvider.vb file that defines the QueryProvider class:
Listing 4−8: The QueryProvider.vb File

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

Imports System.Data.SqlClient
'The QueryProvider class that defines the remoting object
Public Class QueryProvider
Inherits MarshalByRefObject
Dim ds As New DataSet
Dim sqlcon As New SqlClient.SqlConnection
Sub New()
'Establishing a connection with QueryTracker Database
Try
sqlcon.ConnectionString = "SERVER=192.168.0.12;UID=sa;PWD=sa;Initial Catalog=QueryTrac
sqlcon.Open()
Catch ex As Exception
MsgBox("Connection Error", MsgBoxStyle.OKOnly, "Attempt to connection to data source f
End Try
End Sub
'This function returns the queries meant for a particular executive in form of a dataset
Public Function getQuery(ByVal id As Integer) As DataSet
Try
Dim sqlcmd As New SqlClient.SqlCommand("select * from queries where QueryId in _
(select QueryId from execquery where eid=" & id & ") and status='forwarded'", sqlcon)
Dim sqlda As New SqlClient.SqlDataAdapter(sqlcmd)
'Filling the data set
sqlda.Fill(ds)
'returning the data set
Return ds
Catch ex As Exception
'In case any exception occurs then returning a blank data set
Return ds
End Try
End Function
'This function allows the executive to log on and returns the executive id
Public Function login(ByVal strUserName As String, ByVal strpwd As String) As Integer
Try
'Verifying the specified information for Executive Login
Dim sqlcom As New SqlClient.SqlCommand("select * from CustSupportExecutives where Firs
& strUserName & "' and Pwd='" & strpwd & "'", sqlcon)
Dim sqldr As SqlClient.SqlDataReader
sqldr = sqlcom.ExecuteReader
'To check whether the login attempt is successful
If sqldr.HasRows Then
'return the executive id
sqldr.Read()
Return sqldr.GetInt32(0)
Else
'in case the login is unsuccessful return 0
MsgBox("Login Unsuccessful", MsgBoxStyle.OKOnly, "INVALID LOGIN")
Return 0
End If
Catch ex As Exception
MsgBox("Error in executive login", MsgBoxStyle.OKOnly, "LOGIN ERROR")
Return 0
End Try
End Function
'This function accepts a dataset containing the queries to be marked as
'attended for a particular executive
Public Function updateQuery(ByVal ds As DataSet)
Try
'Updating the dataset ds contents back to database QueryTracker
Dim sqlcmd As New SqlCommand("Update Queries set status='attended' where QueryId=@Quer
sqlcmd.Parameters.Add(New SqlParameter("@QueryID", SqlDbType.Int))
Dim rowcount As Integer
If ds.Tables.Count <> 0 Then
If ds.Tables(0).Rows.Count <> 0 Then
For rowcount = 0 To ds.Tables(0).Rows.Count – 1
sqlcmd.Parameters("@QueryID").Value = ds.Tables(0).Rows(rowcount).Item(0)
sqlcmd.ExecuteNonQuery()
Next
End If
End If
Catch ex As Exception
MsgBox("Unable to update", MsgBoxStyle.OKOnly, "Update Error")
End Try
End Function
End Class

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

Download this Listing.

The above listing defines the following methods:

• getQuery(): Retrieves the queries meant for a specific executive.

• login(): Validates the login information provided by executives.

• updateQuery(): Updates the queries attended to by executives in the database.

Creating the QueryTrackerServerListener Project


To create the QueryTrackerServerListener server, you need to create the Server class that registers
the QueryProvider remoting object on a TCP channel and listens for the request for that remoting
object made by the Query Tracker client application.

Listing 4−9 shows the code for the Server.vb that defines the Server class:
Listing 4−9: The Server.vb File

Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
'This class defines the server listener that registers the remoting object on a TCP channel
Public Class Server
Dim tcp As TcpChannel
Dim cs As ChannelServices
Public Sub RegisterObject()
'Creating a new TcpChannel
tcp = New TcpChannel(8080)
'Registering the new TcpChannel
cs.RegisterChannel(tcp)
Dim objQueryProvider As New QueryTrackerRemotingObject.QueryProvider
'Registering the service provided by QueryProvider Remoting Business object
RemotingConfiguration.RegisterWellKnownServiceType(objQueryProvider.GetType, _
"QueryProvider", WellKnownObjectMode.SingleCall)
'This message box confirms that the server listener is running
MsgBox("Server Running")
End Sub
End Class
Public Class start
Public Shared Sub Main()
Dim server As New Server
server.RegisterObject()
End Sub
End Class

Download this Listing.

In the above listing, the RegisterObject() method creates a TCP channel and listens for the request
for the QueryProvider remoting object at port 8080. The server starts before any executive requests
the remoting object to retrieve and update queries into the database.

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

Creating the QueryTrackerClient Application


To create the QueryTrackerClient application, you need to create the Executive Login and the
Query Tracker Client windows, as well as the InitializeQueryProvider module.

Creating the Executive Login Window


The ExecutiveLogin class defines the Executive Login window.

Listing 4−10 shows the code for the frmExecutiveLogin.vb file that defines the ExecutiveLogin class:
Listing 4−10: The frmExecutiveLogin.vb File

Imports System.Data.SqlClient
Imports System.IO
Imports System.Collections
Imports System.Runtime.Remoting.Channels
Public Class ExecutiveLogin
Inherits System.Windows.Forms.Form
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
'Calling the Login function
executiveId = objQueryProvider.login(txtUserName.Text, txtPassWord.Text)
'Checking whether the login is succesful
If executiveId <> 0 Then
boolLoginConfirmaion = True
strUserName = txtUserName.Text
Dim objQueryTrackerClient As New QueryTrackerClient
objQueryTrackerClient.ShowDialog()
End If
Me.Close()
End Sub
End Class

Download this Listing.

Figure 4−9 shows the output of Listing 4−10:

Figure 4−9: The Executive Login Window in Design View


Creating the Query Tracker Client Window
The QueryTrackerClient class defines the Query Tracker Client window.

Listing 4−11 shows the code for the frmQueryTrackerClient.vb file that defines the
QueryTrackerClient class:
Listing 4−11: The frmQueryTrackerClient.vb File

'This class provides methods to allow the executives to view the queries meant
'for them and mark them as attended when they have attended the query
Public Class QueryTrackerClient
Inherits System.Windows.Forms.Form
'Dataset variable to receive the dataset from queryprovider getQuery method
Dim ds As DataSet
'Dataset variable to return the dataset containing the queries that
'has to be marked as attended in the QueryTracker database
Dim updateds As New DataSet
'A datatable to store the QueryId of the queries that has been marked as attended by the exe
Dim queryTable As New DataTable("Queries")
Private Sub QueryTrackerClient_Closing(ByVal sender As Object, ByVal e As _
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If queryTable.Rows.Count = 0 Then
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 26

Exit Sub
End If
'Assigning the queryTable datatable to updateds dataset
updateds.Tables.Add(queryTable)
objQueryProvider.updateQuery(updateds)
End Sub
Private Sub cmdAttended_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles cmdAttended.Click
'Check whether a query has been selected from the list view ListViewQuery
If ListViewQuery.SelectedItems.Count = 0 Then
MsgBox("Please select a query first", MsgBoxStyle.OKOnly, "WAIT HERE")
ListViewQuery.Focus()
Exit Sub
End If
'Marking the selected query as attended
ListViewQuery.SelectedItems.Item(0).SubItems(6).Text = "A"
Try
If queryTable.Rows.Count = 0 Then
'Creating the queryTable DataTable to contain the QueryId of the
'queries to be marked as attended
Dim queryDataColumn As New DataColumn
queryDataColumn.DataType = System.Type.GetType("System.Int32")
queryDataColumn.ColumnName = "QueryId"
queryTable.Columns.Add(queryDataColumn)
Dim querydataRow As DataRow = queryTable.NewRow
querydataRow.Item(0) = ListViewQuery.SelectedItems.Item(0).Text
queryTable.Rows.Add(querydataRow)
Else
'Adding new row to queryTable DataTable
Dim querydataRow As DataRow = queryTable.NewRow
querydataRow.Item(0) = ListViewQuery.SelectedItems.Item(0).Text
queryTable.Rows.Add(querydataRow)
End If
Catch ex As Exception
End Try
End Sub
Private Sub QueryTrackerClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Han
If boolLoginConfirmaion = True Then
'Splashing a welcome message to the executive
lblWelcome.Text = "Welcome " & InitializeQueryProvider.strUserName
'Retrieving the queries for the executive
ds = objQueryProvider.getQuery(executiveId)
Try
If ds.Tables(0).Rows.Count = 0 Then
lblWelcome.Text = lblWelcome.Text & " : " & "No Queries For You."
ElseIf ds.Tables(0).Rows.Count = 1 Then
lblWelcome.Text = lblWelcome.Text & " : " & _
ds.Tables(0).Rows.Count & " Query For You."
Else
lblWelcome.Text = lblWelcome.Text & " : " & _
ds.Tables(0).Rows.Count & " Queries For You."
End If
'Enabling the cmdAttended command button
cmdAttended.Enabled = True
Dim rowcount As Integer
Dim tempListViewItem As ListViewItem
'Populating ListViewQuery with Query information retrieved by the dataset
For rowcount = 0 To ds.Tables(0).Rows.Count − 1
tempListViewItem = ListViewQuery.Items.Add(ds.Tables(0).Rows(rowcount).Item(0))
tempListViewItem.SubItems.Add(rowcount + 1)
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(rowcount).Item(1))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(rowcount).Item(2))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(rowcount).Item(4))
tempListViewItem.SubItems.Add(ds.Tables(0).Rows(rowcount).Item(3))
'marking the query as unattended
tempListViewItem.SubItems.Add("U")
Next
Catch ex As Exception
MsgBox("Unable to retrieve queries", MsgBoxStyle.OKOnly, "Retrieval Error")
End Try
Else
Me.Close()
End If
End Sub
Reprinted for milanm, Avanade SkillSoft, SkillSoft Corporation (c) 2004, Copying Prohibited
.NET InstantCode: UML with Visio and Visual Studio .NET 27

Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handl


Me.Close()
End Sub
End Class

Download this Listing.

The above listing defines the following methods:

• QueryTrackerClient_Load(): Retrieves and loads the queries specified for the executive in
the ListViewQuery list view control.

• cmdAttended_Click(): Executes when an executive selects a query from the list and clicks
on the Mark as Attended button to mark that query as attended to. This method updates the
query status in the list as ‘A’.

• QueryTrackerClient_Closing(): Executes when an executive closes the Query Tracker Client


window. This method makes a request to the remoting object to update all the queries
marked as attended.

Figure 4−10 shows the output of Listing 4−11:

Figure 4−10: The Query Tracker Client Window


Creating the InitializeQueryProvider Module
The InitializeQueryProvider.vb file defines the InitializeQueryProvider module.

Listing 4−12 shows the code for the InitializeQueryProvider.vb file:


Listing 4−12: The InitializeQueryProvider.vb File

Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Module InitializeQueryProvider
'A boolean variable to store the login status of the executive
Public boolLoginConfirmaion As Boolean
'A string variable to store the user name of the executive
Public strUserName As String
'A channelservices variable to register the tcp channel
Public cs As ChannelServices

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

'A tcpchannel variable to create an instance of tcpchannel


Public tcpchannel As New tcpchannel
'An instance of queryprovider remoting object
Public objQueryProvider As New QueryTrackerRemotingObject.QueryProvider
'A variable to hold the executive id returned by the login function provided by QueryProvide
Public executiveId As Integer
Sub main()
Try
'creating and registering tcp channel and as this is client you do not need to specify
tcpchannel = New tcpchannel
'registering the channel
cs.RegisterChannel(tcpchannel)
'create an instance of the remote object
objQueryProvider = Activator.GetObject(objQueryProvider.GetType, _
"tcp://192.168.0.12:8080/QueryProvider")
'Opening the frmExecutiveLogin form
Dim objExecutiveLogin As New ExecutiveLogin
objExecutiveLogin.ShowDialog()
Catch ex As Exception
MsgBox("Unable to locate the server", MsgBoxStyle.OKOnly, "Server not found")
End Try
End Sub
End Module

Download this Listing.

In the above listing, the main() function creates a TCP channel as well as an instance of the
remoting object, and invokes the Executive Login window.

Unit Testing
To execute the QueryTrackerAdministrator application:

1. Execute the QueryTrackerAdministrator.exe file. This file is located in the /bin folder of the
QueryTrackerAdministrator project. The Login Manager window appears, as shown in Figure
4−11:

Figure 4−11: The Login Manager Window

2. Enter the user name and password, and click the Login button. If the login information is
correct, the Application Manager window appears, as shown in Figure 4−12:

Figure 4−12: The Application Manager Window

3. Select Executive Manager−>Add Executive to add information about a new executive. The
Executive Manager window appears, as shown in Figure 4−13:

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

Figure 4−13: The Executive Manager Window with List of Departments

4. Specify the executive information and click the Add New Executive button to add the
information about the executive, as shown in Figure 4−14:

Figure 4−14: The Executive Information

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

5. Select Query Manager−>Add Query in the Application Manager window to add a query into
the database. The Query Manager window appears, as shown in Figure 4−15:

Figure 4−15: The Query Manager Window

6. Specify the query information and click the Add Query button to save the information about
the query in the database, as shown in Figure 4−16:

Figure 4−16: The Query Information

7. Select Query Manager−>Forward Query To Executive in the Application Manager window to


assign queries to customer support executives, as shown in Figure 4−17:

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

Figure 4−17: The Forward Pending Query to Executive Window with Query List

8. Select a pending query from the pending queries list, select an executive, and click the
Forward button to forward the selected query to a selected executive.

To execute the QueryTrackerClient application:

1. Execute the QueryTrackerServerListener.exe file. This file is located in the /bin folder of the
QueryTrackerServerListener project. A confirmation message box appears, as shown in
Figure 4−18:

Figure 4−18: The Confirmation Message Box

2. Execute the QueryTrackerClient.exe file. This file is located in the /bin folder of the
QueryTrackerClient project. The Executive Login window appears, as shown in Figure 4−19:

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

Figure 4−19: The Executive Login Window

3. Enter the user name and password and click Login to access the queries. If the login is
correct, the Query Tracker Client window appears, as shown in Figure 4−20:

Figure 4−20: The Query Tracker Client Window with a Query

4. Select a query and click the Mark as Attended button to mark that query as attended. The
query status changes to ‘A’, as shown in Figure 4−21:

Figure 4−21: The Query Status

5. Click the Close button to update the status of the queries marked as attended to into the
database.

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

To create a UML static model diagram from the Query Tracker application:

1. Open the QueryTracker.sln file located in the QueryTracker folder.

2. Select View−>Solution Explorer to view the Solution Explorer for the QueryTracker
application. The Solution Explorer appears, as shown in Figure 4−22:

Figure 4−22: The Solution Explorer

3. Click the solution, QueryTracker, in the Solution Explorer.

4. Select Project−>Visio UML−>Reverse Engineer to reverse engineer the QueryTracker


application code to a UML static model diagram. The Select Visio UML file dialog box
appears, as shown in Figure 4−23:

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

Figure 4−23: The Select Visio UML File Dialog Box

5. Specify the file name as QueryTrackerClient.vsd and click the Save button. Microsoft Visio
opens up automatically and displays the UML static model in the Model Explorer, as shown
in Figure 4−24:

Figure 4−24: The QueryTracker UML model

Downloads
To download the code files, click here.

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

You might also like