Purpose

Document Sample
Purpose Powered By Docstoc
					Technical Paper
Wine Shop Program Sample Application




Microsoft Business Solutions Retail Management System
Store Operations
Contents
CONTENTS .................................................................................................................................................. 1
1      INTRODUCTION ................................................................................................................................ 1
2      BUSINESS SCENARIO ....................................................................................................................... 1
    2.1       INTRODUCTION/EXECUTIVE SUMMARY........................................................................................... 1
    2.2       RMS SHOWCASE BEER, WINE, AND LIQUOR (BWL) BUSINESS SCENARIO – COHO WINE .............. 1
    2.3       SOLUTION APPROACH ..................................................................................................................... 2
    2.4       GOALS OF THIS BUSINESS SCENARIO ................................................................................................ 3
    2.5       TECHNICAL IMPLEMENTATION ........................................................................................................ 4
3      WINE SHOP PROGRAM INSTALLATION WIZARD .................................................................. 6
    3.1       PROCESS FLOW................................................................................................................................ 6
    3.2       UI FEATURES .................................................................................................................................. 6
    3.3       TECHNICAL IMPLEMENTATION ........................................................................................................ 7
4      MSI – WINE SHOP PROGRAM .......................................................................................................10
    4.1       PROCESS FLOW...............................................................................................................................10
    4.2       TECHNICAL IMPLEMENTATION .......................................................................................................12
5      WINE SHOP PROGRAM UNINSTALL ..........................................................................................13
    5.1       PROCESS FLOW...............................................................................................................................13
    5.2       TECHNICAL IMPLEMENTATION .......................................................................................................13
6      SECURITY ..........................................................................................................................................14
    6.1       PROCESS FLOW...............................................................................................................................14
    6.2       TECHNICAL IMPLEMENTATION .......................................................................................................16
7      SEND MAIL COMPONENT .............................................................................................................17
    7.1       PROCESS FLOW...............................................................................................................................17
    7.2       TECHNICAL IMPLEMENTATION .......................................................................................................19
8      LOYALTY PROGRAM CONFIGURATION ..................................................................................20
    8.1       PROCESS FLOW...............................................................................................................................20
    8.2       UI FEATURES .................................................................................................................................21
    8.3       TECHNICAL IMPLEMENTATION .......................................................................................................22
9      EVENTS CONFIGURATION ...........................................................................................................24
    9.1       PROCESS FLOW...............................................................................................................................24
    9.2       UI FEATURES .................................................................................................................................25
    9.3       TECHNICAL IMPLEMENTATION .......................................................................................................26
10         CUSTOMER PREFERENCES CONFIGURATION ..................................................................28
    10.1      PROCESS FLOW...............................................................................................................................28
    10.2      UI FEATURES .................................................................................................................................29
    10.3      TECHNICAL IMPLEMENTATION .......................................................................................................29
11         CASE DISCOUNT CONFIGURATION .......................................................................................31
    11.1      PROCESS FLOW...............................................................................................................................31
    11.2      UI FEATURES .................................................................................................................................32
    11.3      TECHNICAL IMPLEMENTATION .......................................................................................................32
12         WINES-OF-THE-MONTH CONFIGURATION .........................................................................34
 12.1      PROCESS FLOW...............................................................................................................................34
 12.2      UI FEATURES .................................................................................................................................35
 12.3      TECHNICAL IMPLEMENTATION .......................................................................................................36
13      DATA ACCESS COMPONENT ....................................................................................................37
 13.1      PROCESS FLOW...............................................................................................................................37
 13.2      TECHNICAL IMPLEMENTATION .......................................................................................................37
14      LOYALTY PROGRAM CUSTOM BUTTON .............................................................................39
 14.1      PROCESS FLOW...............................................................................................................................39
 14.2      UI FEATURES .................................................................................................................................44
 14.3      TECHNICAL IMPLEMENTATION .......................................................................................................44
15      EVENTS CUSTOM BUTTON .......................................................................................................45
 15.1      PROCESS FLOW...............................................................................................................................45
 15.2      UI FEATURES .................................................................................................................................46
 15.3      TECHNICAL IMPLEMENTATION .......................................................................................................47
16      SET CUSTOMER CUSTOM BUTTON .......................................................................................48
 16.1      PROCESS FLOW...............................................................................................................................48
 16.2      UI FEATURES .................................................................................................................................48
 16.3      TECHNICAL IMPLEMENTATION .......................................................................................................48
17      WINES-OF-THE-MONTH CUSTOM BUTTON ........................................................................49
 17.1      PROCESS FLOW...............................................................................................................................49
 17.2      UI FEATURES .................................................................................................................................49
 17.3      TECHNICAL IMPLEMENTATION .......................................................................................................50
18      HTML STATUS BAR .....................................................................................................................51
 18.1      PROCESS FLOW...............................................................................................................................51
 18.2      UI FEATURES .................................................................................................................................54
 18.3      TECHNICAL IMPLEMENTATION .......................................................................................................54
19      NET DISPLAY ................................................................................................................................55
 19.1      PROCESS FLOW...............................................................................................................................55
 19.2      UI FEATURES .................................................................................................................................59
 19.3      TECHNICAL IMPLEMENTATION .......................................................................................................59
20      MASS MAILINGS ..........................................................................................................................60
 20.1      PROCESS FLOW...............................................................................................................................60
 20.2      UI FEATURES .................................................................................................................................64
 20.3      TECHNICAL IMPLEMENTATION .......................................................................................................65
21      EXCEL REPORTS .........................................................................................................................66
 21.1      PROCESS FLOW...............................................................................................................................66
 21.2      UI FEATURES .................................................................................................................................72
 21.3      TECHNICAL IMPLEMENTATION .......................................................................................................72
22      ACTIVE REPORTS ........................................................................................................................73
 22.1      PROCESS FLOW...............................................................................................................................73
 22.2      UI FEATURES .................................................................................................................................75
 22.3      TECHNICAL IMPLEMENTATION .......................................................................................................75
23      LOYALTY PROGRAM RECEIPT TEMPLATE .......................................................................76
 23.1      PROCESS FLOW...............................................................................................................................76
 23.2      UI FEATURES .................................................................................................................................76
 23.3      TECHNICAL IMPLEMENTATION .......................................................................................................76
24      HOOKS ............................................................................................................................................78
 24.1      PROCESS FLOW...............................................................................................................................78
 24.2      UI FEATURES .................................................................................................................................79
 24.3      TECHNICAL IMPLEMENTATION .......................................................................................................79
25      ERROR HANDLER ........................................................................................................................80
 25.1      PROCESS FLOW...............................................................................................................................80
 25.2      UI FEATURES .................................................................................................................................80
 25.3      TECHNICAL IMPLEMENTATION .......................................................................................................80
26      BEST PRACTICES .........................................................................................................................81
 26.1      COMPONENT DEPLOYMENT ............................................................................................................81
 26.2      REFERENCING IN HTML ................................................................................................................81
 26.3      REFRESHING THE HTML DISPLAYS ...............................................................................................81
 26.4      SAFE FOR SCRIPTING ......................................................................................................................81
 26.5      OTHER BEST PRACTICES ................................................................................................................82
27      REFERENCES ................................................................................................................................83
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




1      Introduction
This technical paper describes all the components of the Wine Shop Program sample application
for Microsoft® Business Solutions Retail Management System, Store Operations.

This paper also includes a business scenario illustrating the use of a wine shop program in a
fictitious, but typical, retail store.

The wine shop program sample application is a part of the Microsoft Retail Management System
(RMS) Customization Kit.



2      Business Scenario
2.1     Introduction/Executive Summary
The goal of the showcase beer, wine, and liquor (BWL) RMS business scenario and solution set
is to provide partners with sample applications, code snippets, and white papers so that they can
quickly learn how to customize RMS to meet the needs of their customers. This information is a
supplement to the RMS Customization Kit.

The RMS showcase business scenario describes a BWL retailer, his profile, his success metrics,
his key challenges, and his approach for addressing those challenges.

The RMS solution set demonstrates how a partner could deliver a solution that addresses the
scenario using RMS customization components and other techniques. The solution set contains
the customization components that a partner would develop, as well as Microsoft PowerPoint
presentations and white papers that explain the technical details of the solution.


2.2     RMS Showcase Beer, Wine, and Liquor (BWL) Business
       Scenario – Coho Wine
John Rodman’s family has been in the retail wine business in Boston, MA for many years. He
actively participated in their business there, and was a 20% partner in the family business. His
partner got a job at Microsoft about a year back and moved to Bellevue, WA. John decided to
move with his partner, and cashed in his share of the family business.

Upon arrival, John decided to open a wine store in Bellevue. He considered his options and
decided to buy an existing store so he did not have to build up the store and its reputation.

After eight months of research, he decided to buy the Coho Wine store in Bellevue. Two months
ago, John purchased the store for $2,000,000, inheriting the staff, the inventory, the customers,
and the sales history of the store. He believes in his managerial, marketing, and technical
expertise, and hopes to build a successful establishment that will return his investment within
three years.

Store Profile

Owner                                   John Rodman
’03 Total Sales                         $ 2 million
’04 YTD Sales                           $ 1.1 million
Target ’04 Total Sales                  $ 2.3 million
’03 Net Margins                         $ 500,000



                                                                                                    1
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


Target ’04 Net Margins                   $ 600,000
# of Employees                           3
Store Hours:                             Mon – Sat 10:00 A.M. to 8:00 P.M.



He reviewed the inventory levels, the store financials, employee knowledge, the store sales over
the past few months, customers, and store processes. He was impressed by the knowledge of
the store employees, and decided to retain all three of them. He found the store financials to be in
order, but the sales volume was not as high as his stores in Boston. To improve sales, John
wants to forecast his sales and plan which products he will be able to push the fastest in which
season, and then build the inventory based on the sales forecast.

John was impressed by the number of customers that visited Coho Wine, but he realized that
these customers bought in limited quantities (one or two bottles at a time) and visited the store
only two or three times a month. He identified this as one of the factors that had a negative
impact on sales, and believed that sales could be increased by introducing incentives for the
following:

Bulk buying (case discounting)
Customer loyalty (repetitive buying)

John was impressed by Microsoft Retail Management System (RMS), which is used at Coho
Wine. His employees told him that RMS has been in use for the past 15 months. Since John
wants the additional forecasting and incentive features, he decided to contact the partner who
had sold and set up RMS.

2.3     Solution Approach
John talked to the partner and told them that he wants to add the following capabilities to RMS:
PLANNING
   Sales forecasting: Forecast the following:
             Sales growth based on historical sales
             Product seasonality
             item distribution as a part of his sales

   Better inventory management: Reduce inventory cost through more efficient inventory and
    purchase order management with the help of data from sales forecasts. He wants the
    inventory costs and the projected order costs stored in RMS.

INCENTIVES
   Loyalty incentives: Implement a loyalty program to build relationships with his customers.
    John wants to track each customer’s sales and provide incentives based on the sales history.

   Bulk discounting: Apply a discount to purchases of 6, 12, or 24 bottles to promote
    purchasing in bulk. One case of beer is treated as one bottle. The bulk discount is to be
    applied as follows:
        6 bottles: 5%
        12 bottles: 10%
        24 bottles: 15%




                                                                                                    2
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


   “Wines of the month”: Promote the concept of wines-of-the-month by convincing
    distributors to give him better deals for promoting certain wines. Increase the sales of the
    wines of the month by giving special offers on the wine and sending out mailers and e-mails
    to customers registered in the loyalty program.

CUSTOMER RELATIONS
   Loyalty incentives: Implement a loyalty program to build relationships with his customers.
    John wants to track each customer’s sales and provide incentives based on the sales history.
    This loyalty program should be based on points; each customer enrolled in the loyalty
    program will receive points based on the dollar amount of their purchases and their current
    loyalty level. Customers receive loyalty discounts based on their loyalty level.

   Targeted Marketing: Track each customer’s preferred taste in wines and their past
    purchases so that he can send personalized promotional letters and e-mails.

   Events: Organize and promote events, such as wine tasting and talks by wine experts.

   Customer Access: Give access to the customer to his data over the Internet.


2.4     Goals of this business scenario
Program Goals
       Improve planning by:
                 o Sales forecasting
                 o Better inventory management
       Increase sales by:
                 o Enabling a customer/store relationship to create loyalty, repeated visits,
                     and more purchases.
                 o Targeting customers selectively based on their preferences and their
                     loyalty levels.
                 o Organizing wines-of-the-month promotion offers, and advertising those
                     offers by sending mailers to frequent customers.
                 o Increasing purchases per visit using bulk discounts.
       Build relationships with customers by:
                 o Rewarding frequent customers using the loyalty program.
                 o Targeted marketing efforts.
                 o Organizing community events.
                 o Allowing the customer to access their data over the Internet.

Technical Goals
        Showcase the following:
                o Use of a predefined and customized database for a vertical market
                o Process of how to update RMS database while ensuring its integrity
                o Integration of Microsoft Excel for sales forecasting, inventory
                   management, and reporting using charts
                o Use of Microsoft SharePoint Server to give customers access to their
                   data over the Internet
                o Integration with Microsoft Outlook to send e-mails for targeted marketing
                o Implementation of case/bulk discounting
                o Implementation of a points-based loyalty program
                o Implementation of a magnetic card system for customer identification
                o Implementation of specialized discount categories such as wines of the
                   month



                                                                                                   3
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


                    o  Creation of reports in RMS
                    o  Creation of custom buttons and modification of HTML screens and
                       receipts
                   o Use of hooks and events
           Open sample application source code to VARs so that they can reuse components.
           Show VARs how to reapply components, for example, loyalty management, from one
            implementation to another.


2.5     Technical Implementation
Database
       Integrate a predefined items list for beer, wine, and liquor stores (BWL).
Manager
      Wizard add-ins
       Implement a points-based loyalty program, allowing the store manager to define the
         loyalty levels, points required to reach each level, and the dollars to be spent to gain
         points at each level. Apply the loyalty discount for customers enrolled in the loyalty
         program.
       Allow the manager to define and update the customer preferences to be tracked.
       Allow the manager to define and update the wines-of-the-month program, and to
         specify the wines in this program.
       Allow the manager to set up and update community events.
       Allow the manager to define and update the parameters of the case discounting
         program, and apply the discounts to each transaction.

        Reports
         RMS reports
                            o   Loyalty effectiveness report
                            o   Cashier signup report
                            o   Wines-of-the-month report
                            o   Customer preference report
                            o   Community event report
           Excel reports
                            o   Pie Chart to show loyalty level customer distribution
                            o   Pie chart to show loyalty level sales distribution
                            o   Bar chart to show comparison of number of customers to sales
                                for the loyalty levels
                            o   Pie chart to show sales across different item categories
                            o   Pivot table to show purchases made from different distributors
                            o   Pivot table to show inventory

        Targeted marketing (including mail merge)
         Allow the manager to design and send e-mail to a group of customers based selected
           based on a criteria, such as loyalty level and customer preferences.

        Microsoft Office integration
         Integrate with Excel for sales forecasting by importing monthly sales data at a
           category level into an Excel worksheet. Allow the manager to define annual growth,
           expected seasonality for each item, and the item distribution for each category to
           estimate sales for the next year.
         Output the sales forecast, including input from RMS on inventory cost, order cost,
           and order lead time to estimate inventory management parameters such as reorder
           size and frequency.
         Allow the manager to use Excel to view reports in pie charts, bar charts, and pivot
           tables. For more information, see the Reports section.



                                                                                                    4
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc



POS
        Customer Info
         Capture customer alcohol preferences based on customer input.
         Access the Internet through SharePoint Server to access and capture customer
           information.

        HTML displays
         Modify the status bar and Net display to show the different kinds of discounts
           received by the customer.
         Modify receipt templates to show the benefit of different kinds of discounts.
         Display the address of the Web site on the Net display.
         Display upcoming community events on the Net display.
         Display a list of wines of the month on the Net display.

        Custom Buttons
         Create a custom button to enroll and remove the customer from the loyalty program,
           display the customer’s profile, and set their preferences.
         Create a custom button to get a list of community events and the event registration
           form.

        Hooks
         Modify discounting to enable bulk discounts.
         Modify discounting to enable wines-of-the-month discounts.

        Receipts
        Modify receipts to show the following:
         Loyalty level
         Discounts obtained
         Number of wines-of-the-month bottles purchased
         Total number of bottles purchased and the percentage of the applicable case
           discount
         Upcoming community events
         Web site address

Internet
    Allow customers to do the following over the Internet, and store the updated information in
    the RMS database.
         Create a logon name and password for the store Web site using the e-mail address
            registered at the store
         Create or modify the password
         Log on to the store Web site
         View and update their profiles, including preferences
         View their loyalty levels
         View information about the loyalty program
         View a list of the wines of the month
         View, register, and cancel registration for events




                                                                                                  5
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




3       Wine Shop Program Installation Wizard
The Wine Shop Program Installation Wizard performs the following actions:
       Installs database components specific to the Wine Shop Program.
       Encrypts the connection string used to access the loyalty program database and stores it
        in the registry.
       Install the components such as HTMLs, Receipts, Reports, and Addins.
       Register the COM Components.
       Marks ActiveX components as safe by updating the registry.
       Automates hooks and status display by updating the registry keys. Automate custom
        buttons and net display by updating the Store Operations database.



3.1 Process Flow
The Wine Shop Program Installation Wizard is an executable that runs as a part of the Wine
Shop Program MSI. The wizard starts after the MSI has installed all of the components.

The wizard is composed of the following pages:
       Welcome
       Connect to the Store Database
       Installation Progress
       Completion
       Failure – displayed if an error occurs during setup

3.2 UI Features
    1. Welcome page

        Lists the prerequisite for the installation to succeed.

    2. Connect to the Store Database page

        The user specifies the following:

            o   Server name
                The server name of RMS database.
            o   Database name
                The name of RMS database.
            o   User name

                The user name can be up to eight characters long.




                                                                                               6
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


            o   Password

                The password must be between six and ten characters. The text entered in the
                Password and Confirm Password boxes must be identical.

        When the connection is successful, the version in the BWLVersion (if present) table is
        greater than the version in the resource file, then the database components will not be
        installed. Otherwise the database components such as Tables, Stored Procedures, and
        triggers will be installed.

    3. Completion page

        Lists the tasks the user completed.

3.3 Technical Implementation
Wine Shop Installation Wizard
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that contains user controls. There is a user control for every dialog that comes up on the wizard.
Visibility of the controls is set at run time when Next or Back is clicked. The panel that contains
the Back and Cancel buttons is placed on the main form because these buttons appear on every
wizard page. Next, the Back and Cancel click events are handled in the main form.

The wizard checks the version of the tables in the BWL database. If the version is smaller, then
the database components are installed. Executing the SQL scripts on the database server
creates the tables, stored procedures, and triggers.

The following example demonstrates how the connection is made to the database server.

Windows XP, Windows 2000
' Declare a connection object.
Private objConnection As New SqlConnection

' Set the connection string.
objConnection.ConnectionString = "Initial Catalog=Master;Data
Source=" & server & ";Integrated Security=SSPI;"

' Open the database connection.
objConnection.Open()

Windows 98
' Declare a connection object.
Private objConnection As New SqlConnection

' In Windows 98 you must set the connection string using the
' user ID and password for the server.
objConnection.ConnectionString = "Initial Catalog=Master;Data
Source=" & server & "; uid=" & serverUserId & ";pwd=" &
serverPassword

' Open the database connection.
objConnection.Open()

Note: In Windows 98, the wizard displays an additional dialog box to get the server name and
password from the user for the database connection.




                                                                                                      7
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The connection string is stored in the registry in an encrypted form. For details, see Section 8,
“Security”.

The following example demonstrates how the connection string is written to the registry.

Dim objSecurity As New
LoyaltyProgramSecurity.LoyaltyProgramSecurity

Dim connectionString As String = ""

Dim encryptedConn As String = ""

Dim keyConnection As RegistryKey

' Create the connection string.
connectionString = "Server=" & server & "; uid=" & userName &
";pwd=" & password & ";database=" & database

' Encrypt the connection string using the security component.
encryptedConn = objSecurity.EncryptConnection2K(connectionString)

Try

' Create the registry path.
keyConnection =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(registryPath)

' Set the encrypted connection string to the Data Source
' key.
       keyConnection.SetValue("Data Source", encryptedConn)


        keyConnection.SetValue("User Id", userName)

' Set the connection string to              an empty string.
 connectionString = ""

Finally

' Set the security object to Nothing.
 objSecurity = Nothing

End Try

' Close the registry key.
 keyConnection.Close()

All of the message strings and constants are defined in a resource file.

The following example demonstrates how the value is retrieved from the resource file.

' This method takes the name of the constant or message
' as input, reads the resource file, and returns its value.
Private Function GetValueFromResFile(ByVal name As String) As
String

' Create a resource manager to retrieve resources.


                                                                                                    8
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


Dim resManager As New
ResourceManager("LoyaltyConfiguration.LoyaltyConfigResource", _
           [Assembly].GetExecutingAssembly())

' Get the culture of the currently executing thread.
' The value of cultInfo determines the culture of
' the resources that the resource manager retrieves.
Dim cultInfo As CultureInfo = Thread.CurrentThread.CurrentCulture

' Retrieve the value of the string resource.
' This value is localized for the culture specified by cultInfo.
Dim value As String = resManager.GetString(name, cultInfo)

Return value

End Function


To create the loyalty program database on the server, the user must have Administrator
privileges on that computer.

The wizard uses the following common components:
       Data Access – See Section 10, “Data Access Component”
       Security – See Section 8, “Security”
       Error Handler – See Section 17, “Error Handler”

Deployment
The Wine Shop Installation Wizard executable file is deployed on the target computer using MSI
for the Wine Shop Installation add-in. The executable file is added to the custom action of MSI
under the install folder, and its installer property is set to False so that the executable runs after
MSI has installed all of the components.

The executable contains all components required for execution (Data Access, Security,
Encryption and Decryption, and Error Handler). When MSI is run on the target machine, it first
installs the files and components and then initiates the Wine Shop Program Setup Wizard.




                                                                                                         9
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




4     MSI – Wine Shop Program
The Wine Shop Program MSI installs the components on the target computer and starts the Wine
Shop Program Installation wizard. The wizard installs the database components after checking
the version and installs the POS and manager components.

The wizard also provides the option of repairing or removing the installed components.
Uninstalling MSI invokes the Uninstall Wine Shop Program executable file to drop the BWL tables
in the database from the server and delete the registry keys.

4.1 Process Flow
Double-clicking the .msi file starts the installation process. The installation wizard shows the
welcome page and then prompts for the installation path as shown in Fig 4.1; the default
installation path is C:\Program Files\Microsoft Retail Management System\. The installation path
must be the same as the path to the folder in which the RMS application is installed.




Figure 5.1

Install the application for everyone.

Click Next to start the installation process.

Files are installed in their respective folders under the Microsoft Retail Management System
folder:




                                                                                               10
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       HTML files are installed in this folder:
        Microsoft Retail Management System\Store Operations\HTML

       Image files are installed in this folder:
        Microsoft Retail Management System\Store Operations\HTML\Images

       Receipt templates are installed in this folder:
        Microsoft Retail Management System\Store Operations\Receipt Templates

       Reports are installed in this folder:
        Microsoft Retail Management System\Store Operations\Reports

       BWL Program.exe, Mass Mailings.exe and Excel Reports.xls is installed in this folder:
        Microsoft Retail Management System\Store Operations\AddIns

The Loyalty Program component is registered in the Global Assembly Cache (GAC).

The process is completed once all the files and components are registered and a connection to
the BWL database is successfully established.

After the Wine Shop Program Installation is complete, the MSI shows the installation complete
screen.




                                                                                                11
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




4.2 Technical Implementation
The Wine Shop Program is a Windows Installer project and is created using the .NET editor. The
MSI is created using Setup and Deployment Projects and the template used is Setup Project.

The Wine Shop Program Installation Wizard is added to the File System Editor of this project
under the application folder. All dependent files and components required for successful
execution are also added.

Setup and uninstall executables are then added to the custom action of the MSI and their installer
property is set to False. This allows executables to run as a part of setup and allows the user to
install the components.

The following folders are added in the File System Editor under the Application folder:
       \Store Operations\AddIns
       \Store Operations\HTML
       \Store Operations\Receipt Templates
       \Store Operations\Reports

After creating the folders, the respective files are added to the folders.

The Global Assemble Cache folder is added in the File System Editor to register the components
during installation. Placing the files in this folder and setting the Register property automatically
registers the components on the target machine at run time.

The default installation path of the application is specified in the Properties window of the
Application folder in the File System Editor. The default location of the Wine Shop Program is
C:\Program Files\Microsoft Retail Management System.

Building the solution creates an MSI in the Debug folder under the project folder. MSI can be
installed directly from the project solution or by double-clicking the Debug folder.




                                                                                                   12
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




5       Wine Shop Program Uninstall
The Wine Shop Program Uninstall component deletes the following:
       Drops the database components.
       Deletes the wine shop program login information
       Deletes the registry keys

5.1 Process Flow
When invoked, the Wine Shop Program Uninstall component deletes the wine shop program
application components in the following order. It first deletes the database components, then
deletes the login information stored in the registry, and then finally removes all wine shop
program registry keys from the computer.

5.2 Technical Implementation
Wine Shop Program Uninstall
This component is written in Visual Basic .NET using a class library.

The following example shows how a registry key is deleted.

' Delete a registry key tree.
Private registryPathDelete As String = "SOFTWARE\Microsoft\Retail
Management System\Loyalty Application"

Microsoft.Win32.Registry.LocalMachine.DeleteSubKeyTree(registryPathDele
te)

Deployment
The uninstall executable file is placed in the uninstall folder of the custom action of the Wine Shop
Program MSI, and its installer property is set to False.




                                                                                                  13
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




6     Security
The connection string used to connect to the store database is stored in the database in
encrypted form. This encryption is performed during installation and the encrypted connection
string is stored in the registry. Whenever a connection to the database is made, this connection
string is decrypted and used.

6.1 Process Flow
The security component used is dependent on the operating system.

Windows 2000 and Later Operating Systems
The Win32 Data Protection API (DPAPI) is used for encrypting and decrypting the connection
string in these operating systems. DPAPI is particularly useful in that it can eliminate the key
management problem exposed to applications that use cryptography. While encryption ensures
the data is secure, you must take additional steps to ensure the security of the key. DPAPI uses
the password of the user account associated with the code that calls the DPAPI functions in order
to derive the encryption key. As a result, the operating system (and not the application) manages
the key.

DPAPI can work with either the machine store or the user store; in the wine shop program
application, the machine store is used. This means that the encrypted string is specific to a
particular computer, so that the encrypted data is generated on every computer.

The following example demonstrates how to import Crypt32.dll.

Windows XP, Windows 2000
Private Declare Function CryptProtectData Lib "crypt32.dll" ( _
ByRef pDataIn As DATA_BLOB, ByVal szDataDescr As String, ByRef
 pOptionalEntropy As DATA_BLOB, ByVal pvReserved As IntPtr, ByVal
pPromptStruct As IntPtr, ByVal dwFlags As Integer, ByRef pDataOut As
DATA_BLOB) As Boolean

Private Declare Function CryptUnprotectData Lib "crypt32.dll" ( _
ByRef pDataIn As DATA_BLOB, ByVal szDataDescr As String, ByRef
pOptionalEntropy As DATA_BLOB, ByVal pvReserved As IntPtr, ByVal
pPromptStruct As IntPtr, ByVal dwFlags As Integer, ByRef pDataOut As
DATA_BLOB) As Boolean

The following example shows how the data is encrypted using DPAPI.

Windows XP, Windows 2000

dwFlags = CRYPTPROTECT_LOCAL_MACHINE Or CRYPTPROTECT_UI_FORBIDDEN

' Encrypts the data.

retVal = CryptProtectData(plainTextBlob, "LoyaltyCrypt", Nothing,
  Nothing, Nothing, dwFlags, cipherTextBlob)




                                                                                                   14
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The above example uses the following flags:

       CRYPTPROTECT_LOCAL_MACHINE: Associates the encrypted data with the current
        computer instead of with an individual user. Any user on the computer on which the
        CryptProtectData function is called can use the CryptUnprotectData function to decrypt
        the data.
       CRYPTPROTECT_UI_FORBIDDEN: Used for remote situations when the UI cannot be
        protected.

The following example shows how the data is decrypted using DPAPI.

Windows XP, Windows 2000
'LoyaltyCrypt is the description of data to be decrypted. This
parameter
'cannot be null in windows 2000
retVal = CryptUnprotectData(cipherBlob, "LoyaltyCrypt", Nothing,
Nothing, Nothing, dwFlags, plainTextBlob)

The second parameter to the CryptProtectData and CryptUnprotectData functions describes the
data to be encrypted. This parameter is required in Windows 2000.

Windows 98
The Crypto API component is used for encrypting and decrypting the connection string in
Windows 98. The encrypted connection string is stored in the registry as bytes. The Rijndael
algorithm is used for encryption and decryption. The key and initialization vector are declared
globally.

The following example shows how the data is encrypted using Crypto API.

' Set the key and initialization vector.
myRijndael.Key = key
myRijndael.IV = IV

' Get an encryptor.
Dim encryptor As ICryptoTransform = myRijndael.CreateEncryptor(key, IV)

' Encrypt the data.
Dim msEncrypt As New MemoryStream
Dim csEncrypt As New CryptoStream(msEncrypt, encryptor,
CryptoStreamMode.Write)

' Convert the data to a byte array.
toEncrypt = textConverter.GetBytes(dataString)

' Write all data to the crypto stream and flush it.
csEncrypt.Write(toEncrypt, 0, toEncrypt.Length)
sEncrypt.FlushFinalBlock()

' Get the encrypted array of bytes.
Encrypt98 = msEncrypt.ToArray()




                                                                                                  15
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The following example shows how the data is decrypted using Crypto API.

' Set the key and initialization vector (IV).
myRijndael.Key = key
myRijndael.IV = IV

' Get a decryptor that uses the same key and IV as the encryptor.
Dim decryptor As ICryptoTransform = myRijndael.CreateDecryptor(key, IV)

' Decrypt the previously encrypted message using the decryptor
' obtained in the previous step.
Dim msDecrypt As New MemoryStream(encrypted)
Dim csDecrypt As New CryptoStream(msDecrypt, decryptor,
CryptoStreamMode.Read)

' Holds the data to be encrypted in bytes.
fromEncrypt = New Byte(encrypted.Length) {}

' Read the data from the crypto stream.
csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length)

' Convert the byte array back into a string.
Decrypt98 = textConverter.GetString(fromEncrypt)

6.2 Technical Implementation
The security component is referenced in the Data Access class for connection to the database.
Depending on the operating system of the target machine, either the DPAPI or the Crypto API is
invoked.




                                                                                             16
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




7     Send Mail Component
This component is used to send e-mail. This component will open the message window.

7.1 Process Flow
Mailing component uses Simple MAPI component. The following code shows how to import
simple MAPI dll.

     <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
     Public Class MapiMessage
         Public reserved As Integer
         Public subject As String
         Public noteText As String
         Public messageType As String
         Public dateReceived As String
         Public conversationID As String
         Public flags As Integer
         Public originator As IntPtr
         Public recipCount As Integer
         Public recips As IntPtr
         Public fileCount As Integer
         Public files As IntPtr
     End Class
     <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
     Public Class MapiRecipDesc
         Public reserved As Integer
         Public recipClass As Integer
         Public name As String
         Public address As String
         Public eIDSize As Integer
         Public entryID As IntPtr
     End Class

    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    Public Class MapiFileDesc
        Public reserved As Integer
        Public flags As Integer
        Public position As Integer
        Public path As String
        Public name As String
        Public type As IntPtr
    End Class
    ' Importing the MAPISendMail functionality.
    Private Declare Auto Function MAPILogon Lib "MAPI32.DLL" (ByVal
UIParam As IntPtr, ByVal User As String, ByVal Password As String,
ByVal Flags As Integer, ByVal Reserved As Integer, ByRef Session As
IntPtr) As Integer

    Private Declare Auto Function MAPILogoff Lib "MAPI32.DLL" (ByVal
Session As IntPtr, ByVal UIParam As IntPtr, ByVal Flags As Integer,
ByVal Reserved As Integer) As Integer
    Private Declare Auto Function MAPISendMail Lib "MAPI32.DLL" _
    (ByVal Session As IntPtr, ByVal hwnd As IntPtr, ByVal Message As
MapiMessage, _



                                                                                       17
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


           ByVal Flags As Integer, ByVal Reserved As Integer) As Integer

The following are the steps to be followed while coding the component:

1. A Simple MAPI session is begun.

    err = MAPILogon(hwnd, Nothing, Nothing, 0, 0, session)

2. To recipient is set.

    ' Set the recipient.
    recpts(count) = New MapiRecipDesc
    recpts(count).recipClass = MAPI_TO
    recpts(count).name = toRecip(count)

3. CC, BCC recipient and the attachment path are set.
4. The recipients are allocated.

    Private Function AllocRecips(ByRef recipCount As Integer) As IntPtr

        recipCount = 0

        ' If the number of recipients is zero then return null pointer.
        If recpts.Length = 0 Then
               Return IntPtr.Zero
        End If
        ' Declare a type for recipient description.
        Dim rtype As Type = GetType(MapiRecipDesc)

        ' Retrieve the size.
        Dim rsize As Integer = Marshal.SizeOf(rtype)

        ' Declare a pointer.
        Dim ptrr As IntPtr = Marshal.AllocHGlobal(recpts.Length * rsize)

        Dim i As Integer = 0
        Dim ptrNext As IntPtr

        While i < recpts.Length

                ' Allocate the pointer.
                ptrNext = New IntPtr(ptrr.ToInt32 + rsize * i)

                ' Convert the structure passed as parameter to pointer.
                Marshal.StructureToPtr(recpts(i), ptrNext, False)

                i = i + 1

        End While

        recipCount = recpts.Length

       ' Return the pointer.
       AllocRecips = ptrr
    End Function




                                                                           18
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


5. The attachments are allocated. The message is formed and sent.

   lastMsg = New MapiMessage

   ' Set the subject.
   lastMsg.subject = subject

   ' Set the message.
   lastMsg.noteText = message

   ' Allocate the recipients.
   lastMsg.recips = AllocRecips(lastMsg.recipCount)

   ' Allocate the attachment paths.
   lastMsg.files = AllocAttachs(lastMsg.fileCount)

   ' Send the mail.
   err = MAPISendMail(session, hwnd, lastMsg, 8, 0)

   ' The MAPILogoff function ends a session with the messaging system.
   Dim l = MAPILogoff(session, hwnd, 0, 0)

   The MAPISendMail has the following parameters:
      Session: Session handle that represents a simple MAPI session
      UIParam: Handle for the dialog box
      Message: The message to be sent
      Flags: Option flags. If it is 8, then the mailing window will open.
      Reserved: Must be zero.

7.2 Technical Implementation
The data access component is packed in the MSI with every component that references it.




                                                                                          19
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




8       Loyalty Program Configuration
The following functionality is supported in this component:
       Creating, editing, or deleting the loyalty program name
       Creating, editing, or deleting the POS status bar prompt for cashiers
       Creating, editing, or deleting the net display message for customers
       Creating, editing, or deleting the loyalty program levels

8.1 Process Flow
Loyalty Program configuration is a tab in Coho Wine Program Settings executable file that is
accessed in Manager from the Utilities menu. This command displays the configuration form,
which displays all configuration information stored in the database. See Figure 8.1.




Figure 8.1

When first displayed, all the editable information in the dialog reflects the default values
configured in the resource file. This includes:
       Loyalty program name
       POS status bar prompt
       Net display message



                                                                                               20
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


      Points per dollar and sign up bonus
      Loyalty program level definitions

This information can be modified and then saved in the loyalty program database.

8.2 UI Features
      When the data grid is empty, the edit and delete buttons are disabled. This will be
       enabled only if there is data for level definitions.
      The loyalty program name, POS status bar prompt, and net display message are
       validated for null values and maximum length of 256 characters.
      Level definitions are displayed in a data grid control. The following conditions apply to the
       level definitions:
      The add-in displays a confirmation message when the information in the dialog is
       successfully saved in the database.
              Loyalty level names must be unique and have a maximum length of 25
               characters.
              The loyalty level datagrid is not editable. It can be modified with the help of pop
               up buttons Add, Edit and Delete as shown in figure 8.2.




               Figure 8.2


              Currency formatting is done for purchase amount with the help of following code.

               column = New DataGridTextBoxColumn
               column.MappingName = "Purchase Amount"
               column.HeaderText = "Purchase Amount"
               column.Format = "c"
               column.NullText = "$0.00"
               column.Width = (dgLevelDefinitions.Width - 130) / 3
               tableStyle.GridColumnStyles.Add(column)
              The row headers are made invisible. When a cell is selected the entire row is
               highlighted with the help of the following code.



                                                                                                     21
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc



                ' This method will select the entire row if the cell is
                clicked.
                Private Sub dgLevelDefinitions_CurrentCellChanged(ByVal
                sender As Object, ByVal e As System.EventArgs) Handles
                dgLevelDefinitions.CurrentCellChanged

                Dim index As Integer

                ' Deselect the previous selections.

                For index = 0 To dgLevelDefinitions.VisibleRowCount - 1

                        dgLevelDefinitions.UnSelect(index)

                Next

                ' Select the current cell.
                dgLevelDefinitions.Select
                (dgLevelDefinitions.CurrentRowIndex)

                End Sub


               The points can have a maximum value of 9999999999 and are only positive
                integers.
               The discounts are expressed as percentages and must be between 0 and 100.
               The purchase amount is computed based on the points entered for a loyalty level
                and points per dollar.
               Alphabetic characters, negative sign and decimal point cannot be keyed into the
                cells in the points, points per dollar and sign up bonus. Alphabetic characters and
                negative sign cannot be keyed into the discount field.


8.3 Technical Implementation
Loyalty Program Configuration
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for add, update, and delete operations. All the message strings and
constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”

Deployment
Loyalty Program configuration is incorporated in a tabbed form. This is added to MSI – Wine
Shop Program Setup for deployment on the target computer. The executable file is placed at the
following location under the Application folder: /Store Operations/AddIns/ BWL Program.exe.




                                                                                                22
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Error Handler and Send Mail). When MSI is run on the target computer, it
installs the file and its components in the Microsoft Retail Management System/Store Operations/
AddIns folder.




                                                                                              23
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




9       Events Configuration
The following functionality is supported in this component:
       Creating, editing, viewing, copying or deleting the events
       Sending e-mail to customers who are registered for an event that is to be canceled.
       Showing a particular event on the Web site.

9.1 Process Flow
Events configuration is a tab in Coho Wine Program Settings that is accessed in Manager from
the Utilities menu. This command displays the configuration form, which displays all configuration
information stored in the database. See Figure 9.1.




Figure 9.1

When the tab is selected for the first time, the events datagrid will be empty.

The details that will be shown in the datagrid are
       Show on website: Only those events that are selected here will be shown in website.
       Name of the event
       Description of the event




                                                                                                24
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       Date of occurrence of the event
       Capacity
       Special Guest
       Location of the event


The combination of Event name, date of occurrence, and location should be unique.
The following actions can be performed in the events configuration:
       Viewing past events
       Editing current events
       Deleting current events. If there are customers enrolled for the event, then deletion
        prompts a message; “There are customers enrolled for the event. Deleting the event will
        cancel all the enrollments to this event. Are you sure you want to delete the event?” is
        shown. If the user opts to delete, then the e-mail window opens with the mail id of the
        customers in the bcc field.
       Copying current or past events.


9.2 UI Features
       When the data grid is empty, only the add button is enabled. The other buttons are
        enabled only if there is data for events.
       The events are shown in the descending order of date. The past events are shown in red
        color. Also if a row is selected, the text color is changed to white. The coloring is done by
        overriding the class DataGridTextBoxColumn with the following code:

        ' Get the future events column.
        If grid.Item(rowNum, columnIndex) = 1 Then

        ' For future or current events, the color of the font must be
        black.
               foreBrush = New SolidBrush(Color.Black)
        Else

                 ' For past events, the font should be red.
                 foreBrush = New SolidBrush(Color.Red)

        End If

        ' If the row is selected then show the row in white.

        If grid.IsSelected(rowNum) = True Then
              ' For selected events, the font should be white.
              foreBrush = New SolidBrush(Color.White)

        End If


       The event name, description, occupancy and date of event cannot be empty.




                                                                                                   25
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       If past event is selected, View, Add and Copy buttons are visible and Delete button is
        disabled as deletion of past events is not allowed. When current or future event is
        selected, Edit, Add, Copy and Delete buttons are visible.
       The event name and special guest can have a maximum length of 50 characters, and
        event description is limited to 255 characters. Capacity should be positive integers with a
        maximum value of 999999. The location is limited to 76 characters.
       The datagrid is not editable The addition, edition and copying are done with the help of
        pop up windows as shown in Fig 9.2




        Figure 9.2

9.3 Technical Implementation
Events Configuration
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for add, update, and delete operations. All the message strings and
constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”

Deployment




                                                                                                   26
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


Events configuration is incorporated in a tabbed form. This is added to MSI – Wine Shop Program
Setup for deployment on the target computer. The executable file is placed at the following
location under the Application folder: /Store Operations/AddIns/ BWL Program.exe.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Error Handler and Send Mail). When MSI is run on the target computer, it
installs the file and its components in the Microsoft Retail Management System/Store Operations/
AddIns folder.




                                                                                              27
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




10 Customer Preferences Configuration
The following functionality is supported in this component:
       Adding and editing preferences on wine type, origin or vineyard, and brand.
       Deleting preferences which will also delete the customer – preference relationship for that
        preference.

10.1 Process Flow
Customer Preferences configuration is a tab in Coho Wine Program Settings that is accessed in
Manager from the Utilities menu. This command displays the configuration form, which displays
all configuration information stored in the database. See Figure 10.1.




Figure 10.1

When the tab is selected for the first time, the Wine Type, Origin/Vineyard, and Brand list boxes
will be empty.

The preferences entered are stored in the database with the corresponding preference types. The
preference types are stored in the resource file which is populated into the database during set
up.




                                                                                                28
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


10.2 UI Features
       When the list box is empty, the edit and delete buttons are disabled. This will be enabled
        only if there is data for preferences.
       Only one item across and within preference types can be deleted or edited at a time.
       The preference value can have a maximum length of 64 characters.
       The addition and edition are done with the help of pop up windows as shown in Figure
        9.2 and Figure 9.3.




        Figure 9.2 – Add Preference




        Figure 9.3 – Edit Preference


10.3 Technical Implementation
Preferences Configuration
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for add, update, and delete operations. All the message strings and
constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”



                                                                                                29
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


Deployment
Preferences configuration is incorporated in a tabbed form. This is added to MSI – Wine Shop
Program Setup for deployment on the target computer. The executable file is placed at the
following location under the Application folder: /Store Operations/AddIns/ BWL Program.exe.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Error Handler and Send Mail). When MSI is run on the target computer, it
installs the file and its components in the Microsoft Retail Management System/Store Operations/
AddIns folder.




                                                                                               30
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




11 Case Discount Configuration
The following functionality is supported in this component:
       Configuring the discount for different quantities
       Choosing the categories for which case discounting is applicable
       Choosing an option to make case discounting additive over loyalty discount.

11.1 Process Flow
Case Discount configuration is a tab in Coho Wine Program Settings that is accessed in Manager
from the Utilities menu. This command displays the configuration form, which displays all
configuration information stored in the database. See Figure 11.1.




Figure 11.1

When the tab is selected for the first time, both the discounts and categories will be empty.

The quantity and discount applicable for the quantity can be added. The categories for which
discount is applicable can also be modified.

When the check box, Make the case discount additive to the loyalty discount is chosen, then
while computing discount both loyalty and case discount are applied. When the check box is
deselected, then the greatest of loyalty or case discount will be applied to the transaction entries.



                                                                                                   31
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


11.2 UI Features
       When the discount quantity datagrid is empty, the edit and delete buttons are disabled.
        This will be enabled only if there is data for discount.
       The categories are selected in the pop up window as shown in Figure 11.2




        Figure 11.2
       The quantity can have a maximum value of 999999999. Only positive integers are
        allowed in the quantity field. The discount can have values in the range 0 to 100%.
       Only one discount percentage can be defined for a quantity. In other words, quantity is
        unique.
       Adding and editing discounts is done with the help of pop up windows as shown in Figure
        11.3




        Figure 11.3




Figure 9.2

11.3 Technical Implementation
Case Discount Configuration




                                                                                                  32
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for add, update, and delete operations. All the message strings and
constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”

Deployment
Case Discount configuration is incorporated in a tabbed form. This is added to MSI – Wine Shop
Program Setup for deployment on the target computer. The executable file is placed at the
following location under the Application folder: /Store Operations/AddIns/ BWL Program.exe.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Error Handler and Send Mail). When MSI is run on the target computer, it
installs the file and its components in the Microsoft Retail Management System/Store Operations/
AddIns folder.




                                                                                               33
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




12 Wines-of-the-Month Configuration
The following functionality is supported in this component:
       Adding/Deleting months
       Adding/Deleting wines for the months.
       Copy wines from any existing month to the new month.
       Editing the sale price for wines.

12.1 Process Flow
Wines-of-the-month configuration is a tab in Coho Wine Program Settings that is accessed in
Manager from the Utilities menu. This command displays the configuration form, which displays
all configuration information stored in the database. See Figure 12.1




Figure 12.1

When the tab is selected for the first time, both the months and wines datagrid will be empty.

Only current or future months can be added. And wines can be added for each of these months.
These wines are categories as “Wines-of-the-month”. The wines-of-the-month sale price (if it is
lesser than the RMS computed price) will be applied while ringing up the items if the item is wine
of the current month.




                                                                                                 34
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


While adding new month, an option to copy wines from the existing month is also provided. Wines
cannot be added for the past months. The sale price also cannot be edited.

12.2 UI Features
      Initially when the month list box is empty, the Delete Month button is disabled. This will be
       enabled only if there are months. When the datagrid is empty, the Delete Wine and Edit
       wine are disabled. These will be enabled only if there are wines present for a month.
      Past months are shown in red color.
      The adding/Copying of month are done in the pop up as shown in the Figure 12.2.




       Figure 12.2
      The Add Wine, will show a pop up, where items can be filtered based on the department
       and category. This is shown in Figure 12.3.




       Figure 12.3



                                                                                                 35
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       In the Wines datagrid, currency formatting is used for Retail Price and Wine of the month
        sale price.
       The datagrid cannot be edited in place. The sale price can be edited using a pop up as
        shown in Figure 12.4. The wine of the month sale price is a positive integer and cannot
        be larger than the retail price.




        Figure 12.4

12.3 Technical Implementation
Wines-of-the-month Configuration
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for add, update, and delete operations. All the message strings and
constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”

Deployment
Wines-of-the-month configuration is incorporated in a tabbed form. This is added to MSI – Wine
Shop Program Setup for deployment on the target computer. The executable file is placed at the
following location under the Application folder: /Store Operations/AddIns/ BWL Program.exe.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Error Handler and Resource). When MSI is run on the target computer, it
installs the file and its components in the Microsoft Retail Management System/Store Operations/
AddIns folder.



                                                                                                  36
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




13 Data Access Component
The data access component controls all interaction with the database. This ensures that each of
the other components does not need to define its own interaction.

This component supports the following functionality:
       Creates the database connection
       Reads the connection string from the registry and decrypts it
       Encrypts the connection string and stores it in the registry

Security (encryption and decryption) is only referenced in this component.

13.1 Process Flow
As described above, the data access component controls all interaction with the database.
Whenever a call is made to make a connection to the database, the data access component
reads the connection string from the registry, decrypts it using the security component, and
returns the connection.

When the loyalty program database is created, the connection string is passed to this class. This
class then encrypts the string using the security component and stores the string in the registry.
Because the security component uses different methods for different operating systems, the
appropriate call is made from the data access layer to encrypt or decrypt the connection string.

13.2 Technical Implementation
The data access component is written in Visual Basic .NET using a class library. Common
database operations and the calls to the security layer are made from within this class only.

This class uses the following common components:
       Security: see Section 6, “Security”
       Encryption and Decryption

The following example shows how the connection string is retrieved from the registry.

Imports Microsoft.Win32

' Declare the registry path at the class level.
Private registryPath As String = "SOFTWARE\Microsoft\Retail Management
System\Loyalty Application\Server\Database"

Dim keyConnection As RegistryKey

Dim decryptedConn As String = ""

' Connect to the registry and get the key.
keyConnection =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryPath)

' Get the connection string.
decryptedConn = keyConnection.GetValue("Data Source").ToString()




                                                                                                37
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


' Close the registry key.
keyConnection.Close()

' Return the decrypted connection string.
Return decryptedConn

The following example shows how the version of Windows running on the current computer is
determined.

 ' Get the minor version.
Dim minorVersion As String =
System.Environment.OSVersion.Version.Minor.ToString

' Get the major version.
Dim majorVersion As String =
System.Environment.OSVersion.Version.Major.ToString

'osFlag = 1 --> Win98
'osFlag = 2 --> Win2K
'osFlag = 3 --> XP

' Check whether the version is Windows 98.
If minorVersion = 10 And majorVersion = 4 Then
      osFlag = 1

' Check whether the version is Windows 2000.
ElseIf minorVersion = 0 And majorVersion = 5 Then
      osFlag = 2

' Check whether the version is Windows XP.
ElseIf minorVersion = 1 And majorVersion = 5 Then
      osFlag = 3

End If

' Return osFlag.
Return osFlag

Deployment
The data access component is packed in the MSI with every component that references it.




                                                                                            38
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




14 Loyalty Program Custom Button
The loyalty program custom button is used to enroll customers in the loyalty program or, if the
customer is already enrolled, to show the membership status. While enrolling, a customer loyalty
card is also issued. The customer can also enter preferences on additional properties of wine
such as wine type, origin or vineyard, and brand.

The following functionality is supported in this component:
       Enrolling an existing customer
       Issuing Loyalty Card
       Add/Edit Preferences for the enrolled customers
       Creating a new customer and then enrolling the customer
       Canceling a membership in the loyalty program
       Changing the option to receive mailings.

14.1 Process Flow
The loyalty program custom button is created from the Manager application.

When the custom button is clicked, there are three possible scenarios:

    1. Customer Already Added to Transaction, but Not Enrolled

        If the user clicks the Loyalty Program custom button during a transaction and a customer
        has already been added to the transaction but is not a member of the loyalty program,
        the enrollment screen appears, as shown in Figure 14.1.




                                                                                              39
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 14.1

       The customer can choose whether or not to receive mailings. The level definitions are
       also shown for the cashier’s reference. When the user clicks Enroll…, the Issue Card
       screen appears as shown in Figure 14.2. The card number is entered here and issue
       card button is clicked. If the card id entered is present already, error message is shown.
       When the issue card button is clicked, if the card id is unique, then the customer is
       enrolled. The card id is also stored in the database.




       Figure 14.2

       When the customer is enrolled, the Preferences screen is shown as in Figure 14.3. The
       preferences on wine type, origin/vineyard, and brand is chosen. The customer can
       choose preferences. To delete a preference, clear a checkbox before clicking Save.
       When the Save button is clicked, these preferences will be stored in the database and
       the membership screen will be shown.




                                                                                                40
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 14.3

   2. Customer Already Added to Transaction, and Already Enrolled

       If the user clicks the Loyalty Program custom button during a transaction and a customer
       has already been added to the transaction and is already a member of the loyalty
       program, the membership status appears, as shown in Figure 14.4.




                                                                                             41
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 14.4

       The screen shows the customer’s enrollment date, loyalty program level, current
       discount, and option choice for receiving mailings and preferences.

       Clicking Cancel removes the customer from the loyalty program. The loyalty program
       history of the customer is lost. The screen is immediately refreshed to show the
       enrollment UI.

       The option choice for receiving mailings can also be changed on the membership screen.

       When there are no preferences present, then preferences can be added. If preferences
       are present, they can be edited. When the Add Preferences or Edit Preferences button is
       clicked, then the Preferences screen will be shown. Figure 14.5 shows the membership
       status screen for a customer with no preferences. The Customer Preferences list box will
       be loaded with the preferences chosen for the customer. The existing preferences can be
       deleted and new preferences can be added.




                                                                                            42
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 14.5

   3. Customer Hasn’t Been Added to Transaction, Enrolled or Not

       If the user clicks the Loyalty Program custom button during a transaction and a customer
       has not been added to the transaction, the add-in displays the Customers dialog with a
       list of customers in the database.

       If the user then adds a customer to the transaction, the add-in displays the membership
       screen if the customer is already enrolled or the enrollment screen if she is not.

       If the user clicks Cancel in the Customers dialog, the add-in displays a confirmation
       message, as illustrated in Figure 14.6. (The title of the message is the loyalty program
       name, as entered in the configuration dialog.)


       The QSBridge SetCustomer and SelectCustomer events are used to set the selected
       customer.




       Figure 14.6




                                                                                                  43
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


14.2 UI Features
       Level definitions are shown in the enrollment screen. When levels are added or edited in
        Manager, the level definitions are refreshed in POS instantly; the POS terminal does not
        need to be restarted. Also, if the user clicks Enroll Now on the enrollment screen, the UI
        is immediately refreshed to show the membership screen.
       The preferences have to be unique.
       The card number has to be unique positive integers and it should have a maximum
        length of 9 characters.
       The level definitions in the enrollment screen are sorted by descending order of amount.

14.3 Technical Implementation
Custom Button
The loyalty program custom POS button can be edited in Manager. On the Database menu, point
to Registers, click Custom POS Buttons.

User Interface
The enrollment screen, membership screen, and preferences screen are created using HTML
scripts. The HTML pages access the Store Operations business logic through the QSBridge
ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty     = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.




                                                                                                44
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




15 Events Custom Button
The Events custom button is used to register customers for events. The customer need not be a
member of loyalty program to register for the events.

The following functionality is supported in this component:
       Register a customer for events
       Cancel the registration

15.1 Process Flow
The Events custom button is created from the Manager application.

In the events screen only the future events are shown.

The details of the events shown are:
    Checkbox to select the event.
    Event Title
    Event Description.
    Date of Event
    Seats Available
    Status of the event if registrations are open or closed.

When the customer is already registered for events, then the event will be shown selected. If the
number of registrations is greater than or equal to the capacity of the event, then the check box to
select the event will be shown disabled and status of the event will be shown closed.

The customer can register for events by clicking on the check box to "select" it and clicking on
Update/Save button. Now the seats available will be decremented by 1.

The customer can also cancel the registration for the event, by clicking on the check box to
"clear" it. When Update/Save is clicked, the registration will be cancelled. Then the Seats
Available will increase by 1.

When the custom button is clicked, there are two possible scenarios:

    1. Customer not loaded and Events customer button is clicked

        If the user clicks the Events custom button and a customer has not been loaded, the add-
        in displays the Customers dialog with a list of customers in the database.

        If the user then adds a customer, the add-in shows the community events page.

        If the user clicks Cancel in the Customers dialog, the add-in displays a confirmation
        message, as illustrated in Figure 15.1. (The title of the message is the loyalty program
        name, as entered in the configuration dialog.)




                                                                                                   45
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 15.1

       The QSBridge SetCustomer and SelectCustomer events are used to set the selected
       customer. Then the events are displayed.

   2. Customer not loaded and Events customer button is clicked

       In this case, the list of events will be displayed as shown in Figure 15.2




       Figure 15.2

15.2 UI Features
      The events are sorted by the date of event.
      The events screen will be refreshed only when Update/Save button is clicked.




                                                                                         46
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


15.3 Technical Implementation
Custom Button
The Community Events custom POS button can be edited in Manager. On the Database menu,
point to Registers, click Custom POS Buttons.

User Interface
The community events screen are created using HTML scripts. The HTML pages access the
Store Operations business logic through the QSBridge ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty     = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.




                                                                                             47
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




16 Set Customer Custom Button
The Set Customer custom button is used to set the customer when the card number is given.
This is applicable only for those customers who have enrolled in the loyalty program.


16.1 Process Flow
When the user clicks Set Customer custom button, the Set Customer pop up is shown as in
Figure 16.1. The user enters the card number. If there is customer for the card number entered,
then the customer will set using QSBridge SetCustomer and SelectCustomer fire events.

If there are no customers matching the card number, then an error message will be shown.




Figure 16.1

16.2 UI Features
       The card number has to be unique positive integers and it should have a maximum
        length of 9 characters.

16.3 Technical Implementation
Custom Button
The set customer custom POS button can be edited in Manager. On the Database menu, point to
Registers, click Custom POS Buttons.

User Interface
The set customer are created using HTML scripts. The HTML pages access the Store Operations
business logic through the QSBridge ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty       = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.




                                                                                              48
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




17 Wines-of-the-Month Custom Button

The wines-of-the-Month custom button is used to display the item list belonging to the Wines-of-
the-month category for the current month.


The details shown are:
        Item Description
        Retail Price
        Wine of the Month Sale Price.

17.1 Process Flow
         The wines of the current month are displayed.


17.2 UI Features
        When wines are added or edited in Manager for the current month, the wine list are
         refreshed in the POS screen. The wines of the month screen is shown in Figure 17.1




        Figure 17.1




                                                                                               49
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


17.3 Technical Implementation
Custom Button
The Wines of the Month custom POS button can be edited in Manager. On the Database menu,
point to Registers, and then click Custom POS Buttons.

User Interface
The Wines of the Month screen is created using HTML scripts. The HTML pages access the
Store Operations business logic through the QSBridge ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty     = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.




                                                                                             50
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




18 HTML Status Bar
The HTML status bar is displayed at the top of the POS screen. The HTML status bar is updated
when a customer is added to a transaction. If the customer is already enrolled in the loyalty
program, the membership status of the customer is displayed in the HTML status bar. If the
customer is not enrolled, the enrollment message is displayed.

18.1 Process Flow
When the cashier first logs on to the POS, the HTML status bar does not display any loyalty
program information. The HTML status bar is updated once a customer is added to the
transaction. There are three possible displays in the HTML status bar.

    1. Loyalty program status

        If the customer added to the transaction is already enrolled in the loyalty program, the
        membership status of the customer is displayed:

               The date the customer joined the loyalty program
               The discount applicable for the level
               The customer’s current loyalty program level
               The customer’s next loyalty program level
               Current Points
               The points required to reach the next level
               The community events the customer has registered for

        The loyalty program status can be seen in Figure 18.1.




                                                                                                   51
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 18.1

   2. Enrollment message

       If the customer added to the transaction is not enrolled in the loyalty program, the HTML
       status displays the enrollment message shown in Figure 18.2. This POS status bar
       prompt for cashiers is initially specified in the in the Loyalty Program Configuration dialog.
       (On Manager’s Utilities menu, point to Add-Ins, and then click BWL Program.exe.)




                                                                                                  52
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




       Figure 18.2

   3. No loyalty program information

       The HTML status bar displays no loyalty program information in the following situations:
              The cashier has logged on, but a customer has not been added to the
               transaction.
              The customer has been removed from the transaction.
              The transaction has been completed.




                                                                                              53
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




18.2 UI Features
       The date is displayed in this format: mm/dd/yyyy.
       The status display HTML file is automatically added to the registry as part of installation.
       The HTML status bar is updated every second.
       If the customer has not achieved the first loyalty level, the current level is shown as “No
        Level.”
       The POS status bar prompt for cashiers is restricted to a maximum length of 256
        characters.
       The events registered by the customers are appended with a comma and is shown. If the
        customer has not registered for any event, then “No Registrations” is shown.

18.3 Technical Implementation
User Interface
The HTML status bar displays are created using HTML scripts. The HTML pages access the
Store Operations business logic through the QSBridge ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty     = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.




                                                                                                   54
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




19 Net Display
The net display appears on a secondary customer-facing monitor.

19.1 Process Flow

                  Start




      Step 1: Is customer Loaded?                No




                                            Step 3: Display the loyalty
                  Yes                          advertisement page




    Step 2: Is customer signed up for
                                                      No
             loyalty program?




                  Yes



  Step 4: Display the discount amount
   when the transaction is performed.




  Step 5: Display the upcoming events,
   case discounting and wines of the
             current month.




                  End



Figure 19.1



                                                                          55
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc



Either the net display message or the amount saved on the current transaction is displayed
depending on the enrollment status of the customer. There are two possible scenarios:

Customer not enrolled
If the customer added to the transaction is not enrolled in the loyalty program, the net display
message is shown to the customer as in Figure 19.2. The net display message is configured in
the BWL Program. This message can be edited in Store Operations Manager. (On the Utilities
menu, point to Add-ins, and then click BWL Program.exe.




Figure 19.2

Customer enrolled
When a transaction is in progress for an enrolled customer, the loyalty program discount amount
for each item added to the transaction is displayed on the net display as shown in Figure 19.3.




                                                                                                   56
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 19.3

Either Case
The following details will be shown in either of the cases in a time based cycle in addition to the
screen above.

       Upcoming community event as shown in Figure 19.3
       Case discounting as shown in Figure 19.4
       Current Wines of the Month as shown in Figure 19.5.




                                                                                                      57
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 19.3




Figure 19.4




                                           58
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 19.5

19.2 UI Features
       The loyalty program discount amount is rounded off to two decimal places.
       The net display is refreshed every second.

19.3 Technical Implementation
User Interface
The messages on the net display are created using HTML/Scripting. The HTML page accesses
the Store Operations business logic through the QSBridge ActiveX control.

Database Interaction
Components in Visual Basic .NET are used to interact with the database. The object of this
component can be created using the following code:

Loyalty       = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.

Net Display Configuration
The net display HTML add-in is configured in Store Operations Manager. To add, delete, or
preview net display channels, on the Database menu, point to Registers, and then click Net
Display Channels.




                                                                                             59
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




20 Mass Mailings
The following functionality is supported in this component:
       Search for customers based on filter criteria on loyalty level, events, preferences and
        mailings option
       Search for customers based on advanced filter criteria
       Sending e-mail to selected customers
       Exporting the customer details to excel

20.1 Process Flow
The Mass Mailings is an executable file that is accessed in Manager from the Utilities menu (the
Mass Mailings.exe command on the Add-Ins command’s sub-menu). This command displays the
Mass Mailings dialog box, which displays search window to filter customers. See Figure 9.2.
Basic search is performed on following fields:
       Loyalty Level
       Customer Preferences 1
       Customer Preferences 2
       Events
       Option to select customers who want to receive mailings.
       Option to select customers with email address.
The basic search form is shown in Figure 20.1.




                                                                                                  60
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 20.1
The advanced search is performed on the following fields.
    Account Balance
    Address
    City
    Email
    Event
    First Name
    Last Name
    Loyalty Level
    Preference – Origin
    Preference – Taste


                                                            61
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       Preference – Vintage
       Preference – Wine Type
       Price Level
       State
       Total Sales
       Total Visits
       Zip
The conditions in advanced search are added to the datagrid. The advanced search form is
shown in Figure 20.2.




Figure 20.2
When Search is clicked, recipient list are generated matching the filter criteria and is shown in the
datagrid.

When E-mail button is clicked, the mail ids of customers selected are concatenated. Only the mail
ids of customers whose receive mailings is true are concatenated. Then Send Mail component is
invoked, with the mail ids forming the Bcc list.




                                                                                                  62
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The recipient list can also be exported to excel. When Export to Excel button is clicked, the file
dialog is shown where the user can choose the location of the file and enter the name of the file.
The selected recipient details are exported to excel using the following code:

' Get a new excel application object.
oXL = New Excel.Application

' Get a new workbook.
oWB = CType(oXL.Workbooks.Add(System.Reflection.Missing.Value),
Excel.Workbook)

' Get a new excel sheet.
oSheet = CType(oWB.ActiveSheet, Excel.Worksheet)

' With the workbook created and a reference to an Excel worksheet, we
can now add our columns.

For columnCount = 2 To customerData.Tables().Item(0).Columns.Count - 3

CType(oSheet.Cells(1, columnCount + 1), Excel.Range).Value2 =
customerData.Tables(0).Columns(columnCount).ColumnName

Next columnCount

' With the workbook created and a reference to an Excel worksheet, we
can now add our rows that has the values.
For rowCount = 0 To customerData.Tables(0).Rows.Count - 1

oSheet.Cells.Range(oSheet.Cells(rowCount + 2, 1), oSheet.Cells(rowCount
+ 2, customerData.Tables(0).Columns.Count - 2)).Value2() =
customerData.Tables(0).Rows(rowCount).ItemArray

Next rowCount

' Clear the first two cells.
oSheet.Cells.Range(oSheet.Cells(2, 1),
oSheet.Cells(customerData.Tables(0).Rows.Count + 2, 2)).Clear()

obj.ShowDialog()


fileName = obj.fileName

Dim pos As Integer = fileName.IndexOf(".xls")

If pos < 0 Then

         fileName = fileName + ".xls"

End If

' With the rows stored in Excel, our last step is to close the
application and display the Excel document to the user.
oWB.Close(True, fileName, Nothing)

' These lines of code are for memory management.



                                                                                                 63
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc



System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB)


System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL)

oXL = Nothing

oWB = Nothing

' Finally, we need to display the newly created Excel workbook to the
user.
Dim processExcel As Process = New Process

processExcel.StartInfo.FileName = fileName

processExcel.Start()


The details exported to excel are:
   First Name, Last Name
   Email Address
   Address
   City
   Zip
   Account Balance
   Total Sales
   Phone Number

20.2 UI Features
          In advanced search, the condition drop down will change depending on the data type of
           the field chosen.
            Data Type                     Condition
            String                         Contains
                                           DoesNotContain
                                           IsExactly
                                           IsNot
                                           IsEmpty *
                                           IsNotEmpty *
            Integer                        IsExactly
                                           IsNot
                                           IsGreaterThan
                                           IsLessThan
            Decimal                        IsExactly
                                           IsNot
                                           IsGreaterThan
                                           IsLessThan




                                                                                               64
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       If integer field is chosen, then the only numeric values can be entered in the value field.
       When Clear button is clicked, all the datagrids will be cleared.


20.3 Technical Implementation
Mailing Executable
This component is written in Visual Basic .NET using Windows Forms. It consists of a main form
that has a data access layer for retrieving the recipients. All the message strings and constants
are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 13, “Data Access Component”
       Security – See Section 6 “Security”
       Error Handler – See Section 25, “Error Handler”
       Send Email – See Section 7, “Send Mail”

Deployment
The mailing executable file is added to MSI - POS Setup for deployment on the target computer.
The executable file is placed at the following location under the Application folder: /Store
Operations/AddIns/Mass Mailings.exe.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption, Resource, Send Mail and Error Handler). When MSI is run on the target
computer, it installs the file and its components in the Microsoft Retail Management System/Store
Operations/ AddIns folder.




                                                                                                      65
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




21 Excel Reports
The following functionality is supported in this component:
       Pie chart showing loyalty level customer distribution
       Pie chart showing loyalty level sales distribution
       Bar chart showing comparison of number of number of customers to sales for the loyalty
        levels
       Pie chart showing sales across different item categories
       Pivot table showing purchases made from different distributors
       Pivot table showing inventory

21.1 Process Flow
Pie Chart – Loyalty Level Customer Distribution will show the customer distribution across
loyalty levels as shown in Figure 21.1. The loyalty level of the customers is retrieved from the
database. Then the pie chart is drawn.




Figure 21.1: Loyalty Level Customer Distribution – Pie Chart

Pie chart - loyalty level sales distribution will show the sum of loyalty sales for different loyalty
levels as shown in Figure 21.2.




                                                                                                   66
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 21.2: Loyalty Level Sales Distribution – Pie Chart

Pie chart - sales across different item categories will show the total sales of items against the
categories. The chart is shown in Figure 21.3




Figure 21.3: Sales across different item categories – Pie Chart



                                                                                               67
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


The following code shows how to draw a pie chart:

' Get the active worksheet.
Dim ThisWorksheet As Excel.Worksheet
ThisWorksheet = ReportWorkbook.ActiveSheet

' Delete existing charts if any.
Dim charts As Excel.ChartObjects = CType(ThisWorksheet.ChartObjects(),
Excel.ChartObjects)
charts.Delete()

' Adds a chart at x = 220, y = 40, 500 points wide and 300 tall.
Dim chartObj As Excel.ChartObject = charts.Add(250, 40, 530, 300)

xlChart = chartObj.Chart
xlChart.ChartType = Excel.XlChartType.xlPie

' Set source data and data range for the pie chart.
Dim cellRange As Excel.Range = DirectCast(xlSheet.Cells(4, 2),
Excel.Range)
xlChart.SetSourceData(cellRange.CurrentRegion,
Excel.XlRowCol.xlColumns)
xlChart.HasTitle = True

' Apply data label.

xlChart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowPercent)

Bar Chart – No- of customers to sales for loyalty levels shows the comparison of number of
customers to sales for loyalty levels as shown in Figure 21.4:




                                                                                         68
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 21.4: Number of customers to sales for loyalty levels – Bar Chart



The code to create bar chart is same as that of creating pie chart except that the chart type has to
be set.

xlChart.ChartType = Excel.XlChartType.xlColumnClustered

Pivot table – Display Inventory will generate the report and the pivot table in two different work
sheets. The pivot table for displaying inventory is shown in Figure 21.5:




                                                                                                 69
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 21.5: Display Inventory – Pivot Table

Pivot table – Purchases from different Distributors shows the pivot table based on the
purchases made from different distributors as shown in fig.




                                                                                         70
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




Figure 21.6: Purchases from different distributors – Pivot Table

The pivot table can be loaded using the following code:

xlSheet.Cells(1, 1) = chartTitle

' Set the column headers for the data.
For count = 0 To reportData.Tables(dataTableName).Columns.Count - 1

xlSheet.Cells(3, count + 1) =
reportData.Tables(dataTableName).Columns(count).ColumnName

Next


' Copy the data in from the dataset.
row = 3

For count = 0 To reportData.Tables(dataTableName).Rows.Count - 1

row = row + 1
For col = 0 To reportData.Tables(dataTableName).Columns.Count - 1

xlSheet.Cells(row, col + 1) =
reportData.Tables(dataTableName).Rows(count).Item(col).ToString()

Next col

Next
reportData = Nothing



                                                                      71
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




21.2 UI Features
       At any point of time, only one sheet will be shown to the user.
       The start date and end date are disabled for the reports Loyalty level customer
        distribution - Pie Chart, No. of customers to sales for loyalty levels - Bar Chart, Display
        Inventory - Pivot Table and Purchases made from different distributors - Pivot Table.


21.3 Technical Implementation
Excel Reports
This component is written in Visual Basic .NET using Windows Forms. All the message strings
and constants are defined in a resource file.

The executable uses the following common components:
       Data Access – See Section 10, “Data Access Component”
       Security – See Section 8, “Security”
       Error Handler – See Section 17, “Error Handler”


Deployment
To deploy excel reports, one of the following applications should be installed: Microsoft Office
Professional Edition 2003 or Microsoft Office Word 2003 or Microsoft Office Excel 2003; Microsoft
.NET Framework 1.1.

The Excel Reports are added to MSI - POS Setup for deployment on the target computer. The
executable file is placed at the following location under the Application folder: /Store
Operations/AddIns/Excel Reports.xls.

The executable is packed with the components it requires for execution (Data Access, Security,
Encryption/Decryption and Error Handler). When MSI is run on the target computer, it places the
file and its components in the Microsoft Retail Management System/Store Operations/ AddIns
folder.




                                                                                                      72
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




22 Active Reports
The Wine Shop Program generates the following three reports in Manager:

    1. Loyalty Effectiveness Report

        The store manager can use this report to judge the effectiveness of the loyalty program
        on a customer-by-customer basis by comparing the monthly purchases made by the
        customer after joining the loyalty program to the monthly purchases made by the
        customer before joining the program.

    2. Cashier Sign Up Report

        Shows the number of customers each cashier has enrolled in the loyalty program.

    3. Wines-of-the-Month Report

        The store manager can view items belonging to the Wines-of-the-Month category. It will
        show the effect on a wine’s sales of adding it to Wines of the Month.

    4. Customer Preference Report

        The store manager can view the customer preferences on wine type, origin or vineyard,
        and brand.

    5. Community Event Report

        The store manager can view the details of past and future community events.

22.1 Process Flow
Loyalty Effectiveness Report
The Loyalty Effectiveness Report compares the purchases before joining the loyalty program to
purchases after joining the loyalty program.

The following fields are displayed on the Loyalty Effectiveness Report:
       Name of the enrolled customer
       Date on which the customer account was opened
       Date on which the customer joined the loyalty program
       Total purchases made by the customer before joining the loyalty program, not including
        sales tax
       Average monthly purchases before joining the loyalty program
       Total purchases made by the customer after joining the loyalty program
       Average monthly purchases after joining the loyalty program

This report can be filtered on the following fields:
       Customer name
       Date on which the customer account was opened




                                                                                                  73
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       Date on which the customer enrolled in the loyalty program
       Loyalty program level

Cashier Sign Up Report
The Cashier Sign Up report shows the effectiveness of each cashier in enrolling customers in the
loyalty program.

The following fields are displayed in the Cashier Sign Up report:
       Name of the cashier
       Total number of the cashier’s customers who are not enrolled in the loyalty program
       Number of customers enrolled by the cashier
       Percentage of served customers signed up to the loyalty program by the cashier

This report can be filtered on the following fields:
       Cashier name
       Date range

Wines-of-the-Month Report
The Wines-of-the-Month report shows the items belonging to Wines-of-the-Month for all months.

The following fields are displayed on the Wines-of-month report:
       Month Name
       Item Category
       Item Description
       Retail Price
       Wine of the month price
       Quantity of the items sold during the particular month.


This report can be filtered on the following fields:
       Item Category
       Wine of the month

Customer Preference Report
The Customer Preference report shows the preferences on wine type, origin or vineyard, and
brand.

The following fields are displayed on the Customer Preference report:
       Customer Name
       Preference
       Membership Status

This report can be filtered on the following fields:
       Customer Name



                                                                                              74
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       Membership Status
       Preference

Community Events Report
The Community Events report shows past and future community events.

The following fields are displayed on the Community Events report:
       Community Event Name
       Event Description
       Customer Name
       Date of Event
       Number of participants / No. of Registered Customers.

This report can be filtered on the following fields:
       Community Event
       Date of Event

22.2 UI Features
       The reports can be sorted on any fields.
       The column position can be changed by simply dragging the column header.
       If the user double-clicks a field, the respective property dialog opens. For example,
        double-clicking Cashier Name opens the properties dialog for that cashier.
       The user can view the report by grouping on any field.

22.3 Technical Implementation
The report name should be prefixed by “Custom – ” .

Report templates are placed in the Microsoft Retail Management System\Store
Operations\Reports folder during the add-in installation.




                                                                                                75
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




23 Loyalty Program Receipt Template
The loyalty program receipt template adds loyalty program status to the default receipt template.

23.1 Process Flow
The receipt is printed after the transaction is tendered. If the customer received a loyalty discount
on the transaction, the amount saved is printed on the receipt. The receipt displays loyalty
program status and whether or not the customer is enrolled in the loyalty program. There are five
possible scenarios:

Customer not added to the transaction
If a customer has not been added to the transaction, “Enroll now in the loyalty program!” is printed
at the bottom of the receipt.

Customer not enrolled in the loyalty program
If the current customer is not enrolled in the loyalty program, “Enroll now in the loyalty program!”
is printed at the bottom of the receipt.

Customer is enrolled, but does not have a loyalty level
If the customer is enrolled in the loyalty program but has not achieved any level, the membership
level is shown as “No level” and the points required to reach the first level is printed on the
receipt.

Customer is enrolled and is in the first or intermediate level
If the customer is enrolled in the loyalty program and has not yet reached the top loyalty program
level, the membership level of the customer and the points required to reach the next level are
printed on the receipt.

Customer is enrolled and has reached the top level
If the customer has reached the top loyalty program level, the points required to reach the next
level is not printed on the receipt.

Apart from the above the details displayed in the receipt are:
   1. Discount percentage
   2. Number of Wines-of-month purchased
   3. Case discount applicable
   4. Number of cases purchased.
   5. Upcoming events
   6. Web site address.

23.2 UI Features
None

23.3 Technical Implementation
User Interface
The information to be printed on the receipt is configured in the XML file that contains the receipt
template.

Receipts
The LoyaltyReceipt.xml file should be placed in the Microsoft Retail Management System\Store
Operations\ReceiptTemplates folder. If you modify the receipt template, you must reload the
template in Store Operations Manager. To reload the receipt template, on the Database menu,




                                                                                                   76
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


point to Registers, click Receipt Formats, click Properties for the loyalty receipt, click Browse, and
then select the updated receipt.

Manager asks whether you want to update all transaction types that use this receipt template.
Click Yes. In the Properties window, make sure that the Show Membership Status, Show Line
Discounts, Show Total Discounts properties are set to True.

Database Interaction
Components in Visual Basic .NET are created to interact with the database. The session
variables are set in the PrintReceipt and Begin Tender hook. The values displayed in the receipt
template are populated from the session variables SessionClass.Variable(1) and
SessionClass.Variable(2).

For more information, see the documentation for the SessionClass.Variable property in the
Customization Guide.




                                                                                                   77
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




24 Hooks
Hooks are used to invoke the Visual Basic .NET components that implement the business logic
for the loyalty program. The following situations are examples of business logic invoked from
hooks:
       When an item that is currently one of the Wine of the Month is added to a transaction, the
        Wines of the Month sale price is compared with the RMS computed price and lowest of
        the two will be applied.
       When the transaction is tendered, case discount and loyalty discount is applied. The
        variables for receipt are also set.
       When the receipt is printed, the loyalty program level of the current customer is updated.
        The variables for receipt are also set.
    

24.1 Process Flow
Loyalty Program Level Calculation
Loyalty program level calculation is invoked from the PrintReceipt hook. The loyalty level is
computed only for enrolled customers. The function called by the hook adds the transaction
amount (excluding the sales tax) to the existing loyalty sales for the customer. Then the current
points are computed using the points per dollar value. The updated points are used to compute
the current loyalty level for the customer.

The session variables used in receipts are also updated. The following session variables are
updated:
       SessionClass.Variable(1): If the customer has enrolled for loyalty program, then the
        loyalty level name and the discount percentage, next level name and purchases required
        for next level.

Wines of the Month Discount Computation
Wines of the Month discount computation is invoked from the AddItem hook. When an item
which is wine of the month is added to a transaction, RMS computed price is compared with the
wine of the month sale price. If the wine of the month price is lesser than the RMS computed
price, then the price is set to the wine of the month sale price.

Case/Loyalty Discount Computation
When the transaction is tendered, the count of items belonging to case categories is computed.
The case discount applicable for the count is retrieved. Case discount and loyalty discount can be
configured as additive, in the Case discount configuration screen from the manager. There are
three scenarios possible.

       Case Discount Not Applicable, loyalty discount applicable: In this case, loyalty discount is
        applied on all items.
       Case Discount applicable, loyalty discount not applicable: In this case, case discount is
        applied to all items belonging to case categories.
       Both Discounts applicable, but not additive: In this case, if the item is belonging the case
        category, then greatest of the two discounts are applied. If the item does not belong to
        the case category, then only loyalty discount is applied.




                                                                                                    78
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


       Both Discounts applicable, additive: In this case, if the item belongs to the case category,
        then both loyalty and case discount are applied are applied. If the item does not belong to
        the case category, then only loyalty discount is applied.

The session variables used in receipts are also updated. The following session variables are
updated:
       SessionClass.Variable(2): Holds the number of wines of the month purchased, case
        discount applicable, number of cases purchased, upcoming events and web site address

24.2 UI Features
None

24.3 Technical Implementation
Database Interaction
Visual Basic .NET components are used to interact with the database. The components are
invoked directly from hooks. Hooks are configured during installation by writing to the registry; the
hooks do not need to be configured manually. The hooks are automatically removed from the
registry when the loyalty program is uninstalled.




                                                                                                  79
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




25 Error Handler
All exceptions thrown by the loyalty program are logged in the event viewer by the error hander
component.

25.1 Process Flow
The exceptions are logged into the event source “Loyalty” with the source name “LoyaltyApp”.
The following information is included in the log:
       Name of the file in which the error occurred
       Name of the user logged on when the error occurred
       Name of the computer on which the error occurred
       Description of the error
       Date on which the error occurred

The following example demonstrates how exceptions are logged to the event viewer.

' Set the log name.
Dim logName As String = "Loyalty"
' Set the user name.
Dim userName As String = Environ("UserName")

' Set the computer name.
Dim machineName As String = Environ("COMPUTERNAME")
Dim logSource As String = "LoyaltyApp"
Dim dateTime As String = Now().ToString()
If Not EventLog.SourceExists(logSource) Then
    EventLog.CreateEventSource(logSource, logName)
End If
objLog.Source = logSource
Dim entryMessage As String = "FileName : " + fileName + "" +
Microsoft.VisualBasic.Chr(10) + "" + Microsoft.VisualBasic.Chr(13) + ""
+ "UserName : " + userName + "" + Microsoft.VisualBasic.Chr(10) + "" +
Microsoft.VisualBasic.Chr(13) + "" + "Date/Time : " + dateTime + "" +
Microsoft.VisualBasic.Chr(10) + "" + Microsoft.VisualBasic.Chr(13) + ""
+ "Machine Name :" + machineName + "" + Microsoft.VisualBasic.Chr(10) +
"" + Microsoft.VisualBasic.Chr(13) + "" + "Error Description:" +
errDesc
'Write the Entry
objLog.WriteEntry(entryMessage,
System.Diagnostics.EventLogEntryType.Error)

25.2 UI Features
None

25.3 Technical Implementation
The error handler component is included in all projects. Exceptions are caught using a
Try…Catch block and are logged using the error handler component.



                                                                                                  80
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




26 Best Practices
26.1 Component Deployment
The components are deployed by adding them to the Global Assembly Cache Application folder
in the Setup and Deployment Project. The Register property should be set to vsdraCOM. For
more information about deploying components, see http://msdn.microsoft.com/library/
default.asp?url=/ library/en-us/dndotnet/html/callnetfrcom.asp.


26.2 Referencing in HTML
Create an object to the component as shown below:

Loyalty = new ActiveXObject("LoyaltyProgram.LoyaltyManager");

LoyaltyProgram is the name of the project and LoyaltyManager is the name of the class. The
object Loyalty can be used to access method in the component.


26.3 Refreshing the HTML Displays
The UI is refreshed automatically in the net display and HTML status bar by using the following
code. Add this code to a function that is invoked when the page is loaded.

JavaScript
// use a timer to run CheckCustomerLoad() periodically every second
TimerID = window.setInterval("CheckCustomerLoad()", 1000);

VBScript
TimerID = window.setInterval("displayVariables()", 1000)

26.4 Safe for Scripting
The scripts must be marked safe for scripting because the ActiveX controls are embedded in
scripts. The following example shows how to mark the scripts as safe.

' Set the key.
key =
Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("LoyaltyProgram.Retriev
eLoyalty\CLSID")

' Retrieve the key value.
classId = CType(key.GetValue(""), String)

keyAdd = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\" +
classId + "\Implemented Categories\{7DD95801-9882-11CF-9FA9-
00AA006C42C4}")

keyAdd = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\" +
classId + "\Implemented Categories\{7DD95802-9882-11CF-9FA9-
00AA006C42C4}")

' Close the registry key.
keyAdd.Close()



                                                                                                  81
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc


26.5 Other Best Practices
      If the HTML status bar or net display is not visible when the cashier logs on to the POS,
       refer to the “Customizing the POS screen” section in Store Operations Online Help.
      To reference a database other than the store database in the reports, prefix the table
       name with the name of the database and the name of the database owner.
      Complicated queries can be handled by inserting the results of the query into a temporary
       table in the loyalty program database and then using the fields of the temporary table. To
       avoid unexpected results, delete any other temporary tables before using this technique.
      Install the application for the Everyone group.
      Encrypt the connection string before storing it in the registry.
      Embed all HTML controls in tables.
      Close all connections to the database when you are finished using them. The Finally
       statement is a good place to close the connections.
      Prefix all field names in the reports with the table names.
      Catch all known exceptions.
      Always initialize a string variable. The default value of integer values is zero.
      Define all messages and constants in a resource file, and read the resource file to get the
       values at run time. This makes your application easier to localize.
      When executing SQL scripts to create a stored procedure, always have a Create
       Procedure statement as the first statement in the script.




                                                                                                82
af31f63b-b4bc-4587-842d-7c95eeb18aef.doc




27 References

         For more information about encrypting and decrypting data using the Rijndael algorithm,
          see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
          frlrfsystemsecuritycryptographyrsacryptoserviceproviderclassdecrypttopic.asp.
         For more information about encrypting and decrypting data using DPAPI, see
          http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html/
          secmod21.asp.
         For more information about hot keys, see ms-help://MS.MSDNQTR.2004APR.1033
          /vbcon/html/vbconcreatingkeyboardshortcuts.htm.
         For more information about progress bars, see ms-help://MS.MSDNQTR.2004APR.1033/
          vbcon/html/vbtsksettingvaluedisplayedbywindowsformsprogressbarcontrol.htm.
         For information about data types, see ms-help://MS.MSDNQTR.2004APR.1033
          /cpref/html/frlrfSystemDataSqlDbTypeClassTopic.htm.




Microsoft, Visual Basic, ActiveX, and Windows are either registered trademarks or trademarks of Microsoft Corporation in
the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

The example companies, products, organizations, domain names, e-mail addresses, logos, people, places, and events
depicted herein are fictitious. No association with any real company, product, organization, domain name, e-mail address,
logo, person, places, or events is intended or should be inferred.




                                                                                                                      83

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:18
posted:2/24/2012
language:Latin
pages:87