Data Entry by authority

  • Last update:  2021-05-25
  • I. Overview

    1. Version

    Designer version
    10.0

    2. Problem description

    The customer's group is large and covers a wide range. For data security, when data entry, it is necessary to store the data entered by the user in different database tables according to the area where the user is located. The table structure of these tables is exactly the same. (That is, the field names and field types of the table are exactly the same).

    If different regions use different templates, it will increase the workload of development and post-maintenance. Then how can we implement it in a template and data entry in different tables according to the region?


    3. Solution

    When adding the built-in SQL in data entry attributes, when selecting the database and table, directly enter the =$ parameter in the place where the database and table name is selected.

    As shown below:

    1.png

    Add this parameter to the template and assign a value to the parameter (the value should be the database name or the table name), and when you click the submit button, pass the parameter value to store data into database.

    Note 1: The values of the parameters are different table names, then the fields bound to all these tables and the template must be exactly the same.

    Note 2: The database name refers to the data connection name established by FineReport.

    II. Example

    Take the "Employe" and "Employe_copy" of FRDemo built-in in Designer as an example, insert data into these two tables.


    1. Design template

    In the designer, click File>New General Report, and refer to the following figure to design the template:

    2.png

    The corresponding relationship between widget types and cells is shown in the following table:

      Cell Widget Type Data Dictionary  Cell Display
      A2  NumberNullNull
      B2  Drop-down box

    Actual value: Full_name of Employe 

    Display value: Full_name

    Actual value: Full_name of Employe 

    Display value: Full_name

      C2 DateNullNull
      D2  Drop-down box

    Actual value: Gender of Employe

    Display value: Gender

    Actual value: Gender of Employe

    Display value: Gender

      E2  Drop-down box

    Actual value: Job_position of Employe
    Display value: Job_position

    Null

    Note: Please refer to the data dictionary for the specific setting method of the drop-down box data dictionary and display.


    2. Add template parameters

    Click Template>Template Parameters in designer, add two parameters base and table, the default value is empty.

    Parameter base is used to pass the name of the database, and parameter table is used to pass the table name, as shown in the following figure:

    3.png


    3. Parameter setting

    1) Add parameter base and table to the "parameter pane". Both the base widget and the table widget use drop-down box, as shown in the following figure:

    4.png

    2) Modify the widget value of the Labelbase widget to DB: ,as shown in the following figure:

    5.png

    With the same steps, modify the widget value of the Labeltable widget to the Table:.

    3) The widget value of the base drop-down box is FRDemo, as shown in the following figure:

    6.png

    4) The widget value of the table drop-down box is Employe, and the type setting in the data dictionary is selected to customize. Enter the names of all data tables that need to be filled in to form the drop-down options of the drop-down box.

    As shown below:

    7.png


    4. Data entry attributes

    Note: Because the tables in the database participating in the dynamic data entry are consistent with the fields bound to the cells, you can just choose a group of database names and table names that exist in the database, mainly to obtain the required cell binding defined table fields.

    1) Exit the parameter pane, click Template>Data Entry Attributes, add built-in SQL, enter =$base after the database and =$table after the table, a parameter input box will pop up, enter FRDemo for the base parameter, click OK, and then click Smart Add Fields, a parameter input box will pop up, parameter base enters FRDemo, and parameter table enters Employe. As shown below:

    8.png

    2) Select the fields that need to be stored into the database, click Smart Add Cells, bind the total fields of the template with the table fields, and set the "EmployeeID" as the main key, as shown in the following figure:

    9.png


    5. Preview effect

    Note: This method supports the mobile terminal, take the PC effect as an example.

    Save the template and click Data Entry Preview.

    As shown in the figure below, since the database has only one value, there is no need to select it, that is, the base parameter is FRDemo.

    Note: Parameter base can also be changed, just assign a value to it.

    1) Select Employe in the table, click Query and input a record, and submit it for storage, you can see the newly inserted record in the Employe table, but not in the Employe_copy table. As shown below:

    10.png

    2) Select Employe_copy in the table, click Query and input a record, and submit it for storage, you can see the newly inserted record in the Employe_copy table, but not in the Employe table. As shown below:

    11.png

    III. Completed template

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\DataEntry\DataEntryApplication\DynamicForm.cpt

    Click to download: 

    DynamicForm.cpt


    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy