Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of interaction between FineReport single Line and Database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report