VisionCore How To
Home Search Support Forum Knowledge Base Print

Basic Usage of BRLCore

The sample illustrated on this document will start with creating BRLCore compliant tables and will walk you through using these tables for basic add, edit and delete functionalities on .Net form project using BRLCore component.

 

Create tables

Open/run the Data Dictionary Editor. This file resides on the installation path of VisionCore which is “C:\Comtech Solutions\VisionCore” by default.

 

For the details on how to use the Data Dictionary Editor tool, please refer to VisionCore ICE Manual and see section 1.2.1.2 entitled Using DataDictionary Editor

 

In this particular example, I have created two tables namely tblMyOrder and tblMyOrderDetails which is designed to have a header-detail and one-many relationship.

brl1

 

brl2

 

brl3

 

(Please enlarge document for clear view of the screen image)

 

Major consideration: Each table must have at least 1 primary key.  If you do not have a primary key for the table use cntID as both identity field and primary key field.

 

Create Project

Open Visual Studio and start a basic project that will use the created tables via BRLCore.

brl4

 

For easier access on Comtech components, specifically the controls, consider adding a toolbox then drag ComtechSolutions.Controls.dll from windows explorer to the toolbox.

brl5

 

Once the controls are available, begin designing the form. Using Comtech control is optional but for the sake of this walkthrough, I am using the Textbox that comes with VisionCore controls so as to have the automatic carryover of reference dependencies.

 

Once the form design is finished, verify that the following references are added:

brl6

 

If not then add those dlls to the references to be able to use BRLCore.

 

The following is a sample form design that will be used in this walkthrough:

brl7

 

Setting up Combobox

The important properties of Combobox that has to be configured are all under the Custom Properties collection of properties.

brl8

 

Setting the above properties of combobox will enable you to get data from tblARCustomer displaying  columns (i.e. strCustomerID and strCompanyName) and the returning value is the strCustomerID.

brl9

 

Adding BRLCore

To add the BRLCore add a new toolbox on the VisualStudio IDE and drag ComtechSolutions.VisionCore.BRLCore.dll.

brl10

 

Drag a MasterDetailTableControl to the form and configure the properties

brl11

 

Bullet PointTableName – denotes the table to where the binding will happen

Bullet PointPrimary Key, MarterPrimaryKey – these properties are being used to denote the primary key of the table and the foreign key that will be used by the child table.

Bullet PointKey – the collection name that will be used by the detail component.

 

Adding Child Table to BRLCore

Basically, the idea of a child Brl component to a header Brl is simply like the idea of a header detail table in a relational database.

 

To do this, click the ellipse button on the property of BRLCore object name “Detail”.

brl12

 

It will show you the next dialog box where you can add, modify or remove details.

brl13

 

When you add BRLCore detail, the same object is being added as the parent, only that it is subject as a detail table of the first BRL object. Same property settings will be available. However this time, instead of using tblMYOrder to the table name property, use tblMYOrderDetails instead.

brl14

brl15

 

Coding Time

First important thing that has to be noted when using BRLCore and other components low level components needs to be initialized and the security module’s login form does this job. So on the form’s load event handler, we will call the security Login form:

brl16

 

You may notice that we added the second line of code BRLOrder.Load(“”). That line of code initializes the BRL object and loads the necessary schema of the tables specified. This does not necessarily be done on the Detail object. Loading the header BRL automatically loads the detail based on the primary key supplied. In this case a blank string, simply to load the schema and initialize it.

 

To illustrate that the detail is also being initialized, we will add some codes to the Shown handler to assign datasource to our gridview and to bind the controls.

 

brl17

 

Add New

BRLCore simplifies the creation of new record. You do not need to bother yourself creating the connection to the database, adding SQL data adapter, command and things like that simply to handle data. To add new record simply use the following line of code:

brl18

 

BRLOrder.AddNew automatically creates new record. It asks for an optional parameter for the default value of the primary key.

 

The supplied parameter is VisionCore’s way of generating the starting number. In any case that the programmer has other primary key value generator, he can use it too.

 

The supplied primary key value becomes the default value of the foreign key of the detail BRL.

 

We can see its behavior on runtime as follows:

brl19

 

Saving

Saving is made easy. Outside data validation, verification and things like that, to save the data the programmer simply needs a line of code:

brl20

 

This will save even the changes done on the child BRL.

 

Let us enter some data, click save button then check the database.

brl21

 

Let us now check the database if the record was actually saved:

brl22

 

Query shows that the data was saved.

 

Loading specific record

Now that we have saved a record, let us try loading it from the find button.

Since we already know the primary key value of or record (OE-10028). Let us load it by simply calling the BRL.Load method, passing the primary key value.

brl23

 

brl24

 

Please ignore the additional columns displayed. These are extra columns being generated for concurrency purposes. The programmer is advised to hide these columns on runtime.

 

Delete

The following code will delete the current record.

brl25

 

The parameter indicates whether or not the BRL will delete the record directly on the database. True deletes it directly from the database while false deletes it on the current recordset which will await for a save command before committing the deletion.

 

Checking the database, you’ll get the following result.

brl26

 

The walkthrough given is simple, if programmers find some issues about binding and the like, please use CurrencyManager and use the form’s binding context.

 

BRLCore offers a lot of methods than what are explained above, but all in all the main purpose of this component is to make loading and saving of record easy. Some of the built-in methods/functions that are commonly used are as follows:

Bullet PointSetColumnDefault – set default value to columns that can be a non-primary column

Bullet PointHasChanges – property that denotes if there are any changes on the record sets.

Bullet PointRollBack – undo changes made on the record sets. This will not affect changes that were already saved.

Bullet PointBRL.RecordControl.CurrentRowView – this is the current loaded row view of the data.

Bullet PointOther classes:

brl27