How to control the modification properties of the DataWindow column in the PB
In the preparation of the management information application system, there is generally a common problem, which is how to get the data columns in the table according to different situations, such as different operations with different users of the same dataWindow (such as the data entry personnel can change the data) And for query people generally cannot change data), the following will explain how to use PB how to control columns in DataWindow in DataWindow with a simple wage table.
The fundamental columns are as follows:
Code Name Working Time Basic Salary Floating Wage Sales Sales Intellectual Subsidy Other Wages CodenameWorkDatabasesAmovesa StationsAbtothersacharVarchardeciMaldecimalDecimalDecimalDeciaml
There are two ways in PB to control column properties, one is a static mode, and the other is dynamic. The so-called static mode is to implement by options on the attributes of the column. The so-called dynamic approach is to utilize programming. Now give an introduction:
First, static method
(1) Select a list of MOUSEs in DataWindow, select "Properties", and select a label, select the "Edit" tab, and make "Display Only" options to be more
(2) or select the "Expression" tab and fill in "1" in "Protect Express";
(3) or select the "Expression" tab, fill in the conditional expression in "Protect Express", if the person working hours cannot be modified, then write "IF (Date (Workdate), Today ()) <= 365, 1, 0) ";
(4) In DataWindow, the Tab ORDER value of a column is 0, and the column cannot be modified by the focus.
(5) Select the ROWS menu in the DataWindow Painter state, select Update Properties, pop up the Specify Update Properties dialog, and set the allow updates to empty.
Second, dynamic modification method
(1) Set the entire DataWindow to protected: Use the readOnly property of the DataWindow Object to set the entire DataWindow to a protection.
The syntax is: dw_1.object.dataWindow.readOnly = value or dw_1.modify ("dataWindow.readonly {= value}), where: value indicates whether DataWindow is a read-only state, it has two values : Yes and NO. YES means that DataWindow is read-only; NO, the default is No. For example: If you want to set the DataWindow to a protection, you can include the following code in the script of the corresponding event:
DW_1.Modify ("DataWindow.Readonly = YES) or for:
DW_1.Object.dataWindow.Readonly = YES
(2) Only protect some columns of DataWindow
Method 1: Using the list of Protect properties
The syntax is: dw_1.object.name.protect = INTEGER or DW_1.MODIFY ("ColumnName.Protect {= INTEGER}"). Parameter Description: Cloumnname: For the column name to be protected; Integer: The column is not protected when the value of the column is 0 or false; the column is protected when the value is 1 or True. For example, to set the column Name to the protection state, the corresponding code is: dw_1.object.name.protect = 1 or: dw_1.moidfy ("name.protect = 1")
Method 2: Using the TabSequence property of the column, the Taborder of the column can be placed as 0 as needed, thereby achieving the purpose of protection.
The syntax is: dw_1.object.name.tabsequence = number or dw_1.modify ("ColumnName.TabSequence {= Number}")
Parameter Description: ColumnName: The column name to be protected; Number: The taborder value of the column (0-32000).
For example, to set the column Name to a protection, the corresponding code is:
DW_1.Object.name.tabsequence = 0
Or: dw_1.modify ("name.tabsequence = 0")
Method 3: Use the DISPLAYOONLY attribute value in the modified column.
The syntax is: dw_1.object.columnname.edit.displayonly = value or dw_1.modify ("columnname.edit.displayOnly {= value}")
Parameter Description: ColumnName: The column name to be protected;
Value: Indicates whether the column is only displayed (DISPLAYONLY), it has two values: Yes and NO. YES means that the user is not allowed to enter data (only): NO is the opposite, the default value is NO.
For example, if you want to set the column Name to only display, you can include the following code in the script of the corresponding event:
Dw_1.object.name.edit.displayOnly = YES
Or: dw_1.modify ("name.edit.displayonly = yes")
Although the column is not modified when using this method, the column can be focused, and other methods described above cannot be.
Third, choose to protect some lines
The above method will work with all of DataWindow, but if you only protect some of the rows, you need to use the column protection (with the above method 2), but this is implemented when DataWindow is established. . The method is: In the DataWindow Drawboard (Painter), double-click the corresponding column, pop up the Column Object dialog box, select the Expressions page, write IF (conditional expression, 1, 0) in the box after Protect. Flexible use of conditional expressions can get a variety of protection.
(1) Only the newly inserted line is allowed
In a DataWindow, sometimes there is a need: existing data can only be browsed without modification, only the newly input data is allowed to modify, at which time the expression is: IF (isRownew (), 0, 1), Or IF (not isRownew (), 1, 0)
(2) Protection of a column should be carried out according to the data of other columns
For example, in employee salary management, only the intellectual subsidy (BT) is allowed when the working life is greater than 5 years, and the box of the BT's Protect is entered in the box: IF (Today (in ", 'YYYYMMDD' ), 1, 4)) - INTEGER (MID (Workdata, 1, 4)> 5, 0, 1)
(3) The row to be protected can only be determined when executed, and changing, for example, in employee salary management, it is assumed that the salary is modified by the salary is changed, and in general, it can only determine the condition when executed. A variable, which requires a parameter (such as flash) that retrieves data when establishing DataWindow, and then entered in the box after the modified column (user_name is a column in the DataWindow, representing the name of the input) :
IF (user_name = flag, 0, 1)
Pay attention to the actual type of parameters when practical.
(4) Add a marker column in the table
The above method basically requires a certain law to be protected, and when these lines are not regular, it can be specifically added to the corresponding table (rag), the value of 1 and 0, Then enter the expression of the FLAG in the box after other columns of Protect. If the line of the line is in the row, the column of the row is in the protection state. For the modification of the flag column value, you can modify or work flex in the program based on some situation.