Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of interaction between FineReport single Line and Database

Shulou Source: shulou.com Published: 2022-06-01 15:23:16 09月26日 Update

1. problem description

When we fill in a report, we often encounter the need to add actions in a row, directly interact the row data with the database, and execute the stored procedure. We can insert the action by adding the "Insert" button in each row of the sail soft, and increase the interaction with the database in the control event, but when there are too many events, the sail soft cannot stably realize the interaction, and there will be problems such as data loss or database connection error. Therefore, this document describes a way to interact with single-row data and databases

2. realization idea

In the design idea of sail soft report, it is the conventional means to realize the interaction with database through template--> report filling attributes, and the process is stable and not easy to make mistakes. Therefore, JS event is written in button event, filling attribute is called, and filling condition is used to restrict receipt data to realize single-line filling.

3. example

We assume that the product inventory is the existing quantity, and then after applying for an order, subtract the ordered quantity from the inventory quantity. After each row of data enters the database, you can see the change in inventory quantity.

3.1 Opening Reports

3.2 Edit Js statement record ordering product name

Right-click Product Name--> Control Settings--> Event Edit--> New Event--> Edit End. Write js statement, contentPane.setCellValue("G1",null,this.getValue());. A new record will be added in cell G1.

3.3 Call filling function and set filling conditions

Template--> Report Filling Properties--> Built-in SQL--> Submission Type Select Intelligent Submission, and the fields and cells to be submitted correspond to each other in the submission content.

Filter by verifying that the added data is up-to-date. Note that cell G1 must be set as a text control

3.4 Edit Add button to call fill event

Add a button control in the penultimate cell, and set the icon and type of the control. Note that all cells should be set to the downward expansion direction, with sql statements inserted into the cell row strategy is the original value, the button corresponding to the expansion cell is B3.

To edit the event on the button, click--> Write Js statement: _g().writeReport(); invoke the reporting function.

3.5 Save and preview

Save template, click fill preview, the effect is as follows

You can see that the inventory has changed (here is the demo database, and no new field can be added. Readers can add a field in the database to store the original inventory. For the sake of page beauty, column H can be hidden.

Tags: Data database event unit button inventory inventory report control statement row product field property template process function action idea time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei MariaDB Redmi Shulou Tech Info