Deep understanding of the PB Data window

Source: Internet
Author: User
Tags filter rollback

PowerBuilder (PB) is a strong development tool based on client/server architecture launched by PowerSoft Company (has been acquired by Sybase), and has been well received by developers since its inception. DataWindow is a patented technology in PB control, its data processing method is quite concise, data window can handle a variety of display formats, report printing, the same deal with complex nested reports freely.

The processing mechanism of a data window is first to design the fields in the data source table based on the desired display, to load the data from the database server to the client at run time, and then commit or rollback the changed data (Rollback). The processing mechanism greatly reduces the data transmission, reduces the burden of the network and improves the processing speed of the data. Make full use of the characteristics of the data window, you can achieve a multiplier effect, but if some problems do not pay attention to the unexpected error will occur.

Several functions

1. Accepttext ()

The function of the Accepttext () function is to transfer the data currently edited by the data window to a buffer in the data window. The program usually determines whether the current data is changed by closing the window and other circumstances. If you have changed the data, you should prompt the user to save it. This eliminates the fact that the user accidentally loses the change data. Generally use Modifiedcount and Deletedcount functions to determine whether the data changes.

PB in the Processing Data window, corresponding to open up four data buffers, respectively, for primary buffer, Deleted buffer, Filter buffer, Sortbuffer, which Deleted buffer storage was deleted records, Filter The buffer holds the filtered records, the sort buffer holds the sorted records, and the Primary buffer holds other records. The function modifiedcount the data from the primary and Filter buffers, and Deletedcount takes the data from deleted buffer to judge.

PB in the acceptance of user input set a floating edit box, user input or change the content does not directly into the primary Buffer, but in the user input after entering the next domain, PB first of its validity test, passed into the primary buffer. If you change only one data to close the window then the relevant data does not enter primary Buffer, the system Judge Modifiedcount () is 0, so do not prompt to save the data. With the Accepttext () function, you can turn the data in a floating edit box into a buffer, and then add Accepttext () to the corresponding program section to solve the problem.

2. findrequired ()

In practical applications, it is often necessary to limit the properties of some fields in a table, such as the account number in the Bank Account table cannot be null. It is a good programming practice to check whether the data that must be entered is assigned before submitting the data. The findrequired function resolves this problem by checking the data in the Data window to find the properties of the fields in the data window as required, but not the assigned fields, including the corresponding rows and columns.

To take advantage of this function, when you construct the Data window, be aware that the data column with the NOT NULL property in the table is set to required (by right-clicking on the corresponding field in the Data window or by double-clicking the left button, ejecting the column Object box, selecting the Edit page, and selecting the box before the required , press OK button). Insert the following program in the appropriate event:

Long ror=1//Row Count 1

Integer colnbr=0//column number 0

String colname//used to store column names

Mle_required. Text = ""//multi-line Edit control in window to store row, column number of found field

Do While row <> 0

colnbr++//Keep looking for the next column

IF dw_1.findrequired (Primary!,row, Colnbr,colname, FALSE) < 0 THEN EXIT

Return if the program goes wrong

IF Row <> 0 THEN

Mle_required. Text = mle_required. Text + String (row) + "~t" &+ colname + "~r~n"//Save detected rows, column numbers

End IF

When row returns to 0 it means no longer detected, jump out of the loop

LOOP

When the program is finished, the multiple-line edit box displays the error, and the user can easily change it by prompting.

The row, COLNBR parameter in the Findrequired function can be automatically incremented or reset, colname the character name used to hold the column.

Data highlighting and protection: in the program running, users want to display a clear distinction between the data, such as the student's score (the failing grade to be shown in red), some number

It must only be shown, cannot be modified by the user, and some data can be modified sometimes, sometimes not modified. The above can be summed up to two points:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.