Demo Application - Expense Recorder

Resources

Introduction

The Demo Expense project is an expenses record system. With this application you can record new expenses and send them to a server database.

This tutorial will show you how to use data binding to save records, create synchronisation rules and create expressions in a fully functional application.

Assumptions

This document assumes that the user knows how to create tables, forms and queries. For further help regarding these BrigthBuilder concepts, please refer to their chapters in the User Manual, or Tutorials exploring these features.

Application Definition

  1. Create a new project and name it DemoExpense.

  2. Create the following table with the specifications shown:

  3. Create a query called qAllExpenses that will return all expense records, with the following specifications:

  4. Create a query called qExpensesByDate that will return expense records which contains the pDate parameter, with the following specifications:

  5. Create a query called qExpensesTotalByDate that will return the sum of all expenses on a date, with the following specifications:

  6. Note: To do this, go to Output Fields, select ITEM_VALUE and click on Sum, and press the > button with the ITEM_VALUE highlighted. You will be prompted to enter name for this summation, and enter DAILY_TOTAL then press enter.

  7. Next we need to create a form to accept new expense entries. Create a form called Item with the following components:

  8. In the Item Form, change the tab order of comboItemList to 1, cbOther to 2, efOtherDesc to 3, efAmount to 4.

  9. Create a validation rule in Item Form to match the following:

    Note: Validation rules get checked right before saving a record.

  10. Create a new variable in Item Form to match the following:

  11. Create another form called Main with the following components:

    Note: the “Total” and “0.00” are two different labels. The “0.00” is called staticTotal.

  12. Change the tab order of btnPrev to 1, dtExpense to 2, btnNext to 3, btnSend to 4, and btnNewbutton to 5.

  13. Create a new Variable in the Main form called dtTemp of type Date/Time.

  14. To display expenses that occur on a specific day, assign the qExpensesByDate query to the List query of the lvExpenses in the Main Form. In the columns property for lvExpenses, only include ITEM_DESC and ITEM_VALUE, renaming their column names to “Item” and “Value” respectively. Set both their columns widths to 50.

  15. Expense records must be sent to the server. Create a new Sync Rule SyncSendExpenses with the following settings:

  16. In the Main form, create the following expressions:

  17. In the Data Binding tab of the Item form set the Form Query to qExpensesByDate.

  18. In the Item form create a new variable bCreateNew of type Boolean.

  19. In the Item Form create the following expressions:

  20. In the Data Binding tab of the Item form, set the following:

  21. Go to the Item Form and do the following:

  22. Go to the Main Form and assign the following expressions accordingly:

  23. Set Main to be the main form of the DemoExpense project.

Application Testing

Execute the project form BrightBuilder.

In the Travel Expense Form, select a desired date and click New.

Select an item or check the “Other” check box to enter details of the expense. Enter the amount of the expense. Click on the save icon at the bottom. Exit the child form. The record will appear in the listview once the Item screen is closed.

To send the local table records to the server click Send while configured to a BrightServer instance.