A typical example is provided with QDV7 to illustrate how to interface a contextual database.
You'll find the example in \SDK\Custom_Articles folder, below installation folder.
The example is made up of:
▪an SQL Server database which is the contextual database. It contains rebates, currencies and prices according to a context made of Country and Type of Business
▪a QDV7 database named Ackerman.qdb which is the calling database
▪a program named Custom_Articles.dll which interfaces both databases
▪the program source code intended to be compiled using Microsoft Visual Studio 2010 or later
Setting up Contextual Database
The SQL Server contextual database should look like this:
To install it, just restore the archive provided in the \SDK>Custom_Articles folder and named Contextual_Prices_Db.bak. This archive was created using SQL Server Management Studio on SQL Server 2008 R2.
In order to run this sample, you must create a user named sample_user on your server. Name and password are hard-coded in the program. So you must use SQL Server authentication and give:
▪login: sample_user
▪password: sample_password
Give this user enough rights on the database (owner is perfect).
Installing QDV Database
In the \SDK>Custom_Articles folder, you'll find a file named Ackerman.qdb. Copy it to any location and set a numeric path to this location using Data>Paths Manager.
Open the database under QDV7, set edit mode and check that QDV7 will query an external program when the database is called. Select Behavior>Query Data from Foreign Program; then the gear wheel shows in a colored square (this flag is already set in sample database).
← |
Quit QDV and copy Custom_Articles.dll (located in \SDK>Custom_Articles folder) to the program folder (usually \Program Files>QDV 7) in replacement of the Custom_Articles.dll installed by setup program which does nothing but returning data passed to the function.
To tell the setup program that you don't want it to replace your own Custom_Articles.dll each time the setup upgrades QDV7, create a file named KeepCustomArticles.inf and place it in the installation directory. The file content doesn't matter. This applies also to your own Custom_Function.dll.
For both dll's, the compatibility of a QDV7 release is preserved across their versions. You may have to recompile the dll's (a warning pops up).
Testing
Under QDV7 open the sample estimate Multi-Langages_Sample_With_Documents.qdv. This estimate contains 2 global variables used to set the context: GLV_Country and GLV_Business.
The content of these variables can be changed in the overhead workbook>Sheet of Sales.
Options for contextual prices (see \SDK):
Country |
UNITED KINGDOM |
V |
|
|
|
|
|
Context |
LARGE_BUSINESS |
V |
Open Ackerman.qdb under QDV7 and import some articles, in this context they should appear in GBP. Prices, rebates and currencies coming from the contextual database.
Change context to USA / Small Business for example. You should get this:
Select lines imported in UK context, and update them using Data>Update Rows.
Then, lines are adapted to the USA context.