1. Description of the problem
When we make a report, we often encounter the need to add action on one line, directly interacting with the database, and executing the stored procedure. We can add a sail soft "insert" button in each line to implement the Insert action, and in the control event to increase the interaction with the database, but when the event is too much when the sail soft can not be stably interactive, there will be data loss or database connection errors and other issues. Therefore, this document describes a single-line data and database interaction method
2. Realization of Ideas
In the design of the sail soft report, through the template---report property implementation and database interaction is the conventional means, and process stability is not prone to error. Therefore, the use of the button event to write the JS event, call the completion of the property, and use the conditions to limit the inbound data to achieve a single-line reporting.
3. Example
We assume that the product stock is in-hand, and then apply for the order to subtract the ordered quantity from the inventory, and after each row of data into the database, you can see the change of inventory quantity
3.1 Open a report
3.2 Edit JS statement record order product name
Right-click Product Name--Control Settings--event editor--new event--edit end. Write the JS statement, Contentpane.setcellvalue ("G1", Null,this.getvalue ()); A new record is added to the G1 cell.
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104337913?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px None;color:rgb (54,46,43); font-family: ' Times New Roman '; line-height:26px;/>
3.3 Call fill function, set conditions
Template--reporting properties--built-in sql--> commit type Select Smart Commit, corresponding to the fields and cell one by one that will be submitted in the submission.
Filter by verifying that the data you added is up-to-date. Note that cell G1 must be set as a text control
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104402601?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px none;margin-left:auto;margin-right:auto; "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104420742?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px none;margin-left:auto;margin-right:auto; "/>
3.4 Edit Add button, invoke Fill event
Adds a button control to the second-to-last cell and sets the icon and type of the control. Note that all cells are set to the downward direction of the extension, and the cell insert row policy with the SQL statement is the original value, and the corresponding expansion cell for the button is B3.
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104402601?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px none;margin-left:auto;margin-right:auto; "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104420742?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px none;margin-left:auto;margin-right:auto; "/>
Edit the button for events, click-to-write the JS statement: _g (). Writereport (); Call fill function.
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104508758?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "style=" border:0px None;color:rgb (54,46,43); font-family: ' Times New Roman '; line-height:26px;/>
3.5 Save and preview
Save the template, click Reporting Preview , the effect is as follows
650 "this.width=650;" src= "http://img.blog.csdn.net/ 20170426104607052?watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/ I0jbqkfcma==/dissolve/70/gravity/center "style=" border:0px none; "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20170426104627912?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvbmf5dw4xmjm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "title=" Click to view the original size picture "width=" "height=" 334 "style=" border:0px none; "/>
You can see the inventory changes (here is the demo database, cannot add new fields, the reader in the actual use of the database can be added a field, specifically to store the original inventory, in order to make the page beautiful, you can hide the H column
Finereport method of interaction between single line and database