1. MOSTRANDO PASTA ONDE VAMOS COPIAR O ARQUIVO PRODUTO
C:\WINDEV 25\Tutorial\WD\Exercises\WD My First Database
2. MOSTRANDO ONDE NO WINDEV, SE OLHA A PASTA DO EXE
3. COLAR O ARQUIVO PRODUTO PARA PASTA EXE
4. LEVAR O ARQUIVO PRODUTO PARA DENTRO DA ANALISE
A different method will be used to create the "PaymentMode" data file, which contains the payment characteristics: importing a CSV file.
Remark
A CSV file is a text file that uses a specific format. This file contains data on each line. The data is separated by a separation character (a comma, a semi-colon or a tabulation).
From the CSV file containing the data, WINDEV will create:
the description of data file in the analysis,
the HFSQL data file with the data found in the CSV file.
To import a CSV file into the analysis:
In the ribbon, on the "Analysis" pane, in the "Creation" group, expand "Import" and select "Import file/table descriptions".
Tip
To import a CSV file (or any other file) into the analysis, you also have the ability to Drag and Drop the CSV file (from the Windows explorer) to the data model editor. This will be presented in the next paragraph.
The file import wizard starts.
Go to the next step.
Select the format of files to import. In this case, select "Text file".
Go to the next step of the wizard.
Specify the path of file to import: "\Tutorial\WD\Exercises\WD My First Database\PaymentMode.csv" in the WINDEV setup directory.
Go to the next step of the wizard.
Specify the following import parameters:
The records are delimited by: "<Carriage Return/Line Feed>".
The columns are delimited by: "<Semicolon>".
The strings are delimited by: "<None>".
Decimal separator: "<Automatic: dot or comma>"
Don't forget to check "The first row contains the names of columns".
Go to the next step.
The structure of data file that will be created is displayed.
Keep the default options. Go to the next step of the wizard.
The content of CSV file will be automatically converted to HFSQL format. The wizard proposes to create the HFSQL file in the project directory.
Keep the proposed options and go to the next step.
Validate the wizard. WINDEV creates the data file.
Let's study the description of the imported data file:
Select the "PaymentMode" data file.
In the popup menu (right mouse click), select "Description of data file".
Change the data file caption in the window that opens up: delete "(Imported)".
Click the icon to display the description of the data file items.
This data file contains no automatic identifier and no unique key. We are going to switch the "Code" item to unique key:
Position the selection bar on the code item if necessary.
In the right section of screen, click "Unique key".
We get the following data:
Validate the item description window and the data file description window.
CRIANDO A TABELA PEDIDO
CRIANDO OS CAMPOS NECESSARIOS DO PEDIDO
CRIANDO DATA DO PEDIDO
CRIANDO STATUS DO PEDIDO
PENDENTE FINALIZADO CANCELADO
CRIANDO CAMPOS DE TOTAIS
Creating a data file: creating the data file and items
To create a data file from the window for creating a new element:
Click "Data" then "Data file".
Remark
You also have the ability to create a data file from the data model editor: in the ribbon, on the "Analysis" pane, in the "Creation" group, click "New file".
The data file creation wizard starts.
In the wizard, select "Create a new data file description".
Go to the next step of the wizard.
We are going to create the "Orders" data file. Type its name ("Orders") in the wizard. This name will be used:
to handle the data file by programming. The variable associated with the data file will be "Orders".
to build the name of associated physical data file ("Orders.fic" file). The caption and description of elements represented by the file records are automatically displayed.
Remark
In the wizard, the control "A record represents" is used to get an understandable caption during the description of links between data files. A caption is automatically proposed from the data file name.
In our case, type "An order".
In "Automatic identifier", keep "8-byte automatic identifier". If an automatic identifier is defined on the data file, it means that the data file includes a unique key, automatically managed by WINDEV.
Remark
To create the identifier (an identifier is a unique key), you have the ability to create a numeric item whose type is "Automatic identifier".
This identifier is automatically managed by WINDEV. Whenever a record is added to the data file, WINDEV automatically assigns a value to the data file identifier. This value is unique.
Go to the next step and select the type of database associated with the data file. We are going to work on HFSQL Classic data files. Go to the next step.
Click "Done" to validate. The data file is automatically created in the analysis. The description window of items and indexes opens up.
We are going to create the items of the "Orders" data file. In the data file description window, you will notice that an item was automatically created: "OrdersID". This item corresponds to the automatic file identifier. This item consists of the letters "ID" and the name of the data file.
We are going to create the other items of this data file.
First, we are going to create the "Date" item. This item will contain the order date.
In the item description window, double-click in the "Name" column of first empty row. This column automatically becomes editable. Type "Date".
Click the "Caption" column. The item name is automatically displayed. We are going to modify the item caption by clicking on it: type "Order date". In the "Type" column, the "Text" type is automatically selected. Expand the list and select the "Date" type.
This item will be a key item (index) in our data file: the keys are used to accelerate the accesses to data and the sorts.
In the case of an SQL database, the engine makes the best use of indexes.
For a sequential browse of a data file, all you have to do is specify the browse index (which means the key).
Remark
The concept of key is part of the item characteristics. When creating an item, you have the ability to specify whether it is:
not key,
unique key: the value of this key will be unique in the entire data file (i.e. in all the data file records).
key with duplicates: the value of this key can be found several times in the data file.
The key definition is performed as follows: re-select the row of the "Date" item to activate the description controls on the right-hand side of the window. Then, simply specify the type of key used. In our case, the date is a key with duplicates.
You must also define the search direction of the key. The search direction is used to define the default sort for this item. In our case, when a browse is performed on this key, the default sort order will be "ascending".
We are now going to create the "Status" item that is used to find out the order status.
Position the cursor on a new table row. Enter:
the name: Status
the caption: Order status
the type: Radio Button, List Box, Combo Box. In the window that appears, you can select the type of control created by default for this item. It will be a radio button in this case. Validate the window.
In the lower section of the screen, click the link to display the parameters of the control linked to the selected item.
The information typed in the new window that is displayed will be automatically used when creating windows linked to the data file. You will find here the control type and the caption. We are going to type the following options in the "Content" tab:
Click the "Content" tab.
Click the "+" button to add the first option.
The option 1 corresponds to Pending. Type "Pending" in the edit control found on the right.
Click the "+" button to add the second option.
Type "Validated" instead of "Option 2".
Click the "+" button again.
Type "Canceled" instead of "Option 3".
Validate the description window of the control linked to the item.
Similarly:
Position the cursor on a new table row and create the item "TotalBT". This item is a "Currency" item.
Position the cursor on a new table row and create the item "TotalIOT". This item is a "Currency" item.
That's it, the description of "Orders" data file is complete. Validate the description window of items.
The "Orders" data file appears in the data model editor. It is possible to enlarge the displayed data file. Simply click the data file, select the black handle at the bottom of the data file and move the mouse down.