PB Development Notes (1)

Source: Internet
Author: User
Tags rowcount line editor

// Use the code to change the data window object
String error_syntaxfromSQL, error_create
String new_ SQL, new_syntax
New_ SQL = 'select emp_data.emp_id, emp_data.emp_name from emp_data '&
+ 'Where emp_data.emp_salary> 100'
New_syntax = SQLCA. SyntaxFromSQL (new_ SQL, 'style (Type = Form) ', error_syntaxfromSQL)
IF Len (error_syntaxfromSQL)> 0 THEN // Display errors
Mle_sfs.Text = error_syntaxfromSQL
ELSE // Generate new DataWindow
Dw_new.Create (new_syntax, error_create)
IF Len (error_create)> 0 THEN
Mle_create.Text = error_create
END IF
END IF
Dw_new.SetTransObject (SQLCA)
Dw_new.Retrieve ()

// How to open a dynamic window:
Window newarray [3]
String win [3]
Int I
Win [1] = "w_employee"
Win [2] = "w_customer"
Win [3] = "w_sales"
For I = 1 to 3
Open (newarray [I], win [I])
Next

// Display a dialog box that is consistent with the Windows operating system style. First, declare the following external functions:
Function int ShellAboutA (ulong al_hWnd, string as_szApp, string as_szOtherStuff, ulong hIcon) library "shell32"
ShellAboutA (handle (parent), "about... # ferry man Studio", "Welcome to ferry man Studio", 0)

// How to switch the COLUMN display style between EDIT, DDDW, and DDLB:
(1) switch to DDDW:
Dw_1.Modify ("#1. dddw. Name = 'dddw _ jg '")
Dw_1.Modify ("#1. dddw. DisplayColumn = 'name _ jg '")
Dw_1.Modify ("#1. dddw. DataColumn = 'id _ jg '")
(2) switch to DDLB:
Dw_1.Modify ("#1. ddlb. case = 'any '")
Dw_1.Object. #1. Values = "red ~ T1/white ~ T2"
(3) switch to EDIT:
Dw_1.Modify ("#1. edit. case = 'any '")
Dw_1.Modify ("#1. edit. AutoSelect = 'Yes '")
(4) obtain the current style:
Dw_1.Describe ("#1. Edit. Style ")
(5) If not, perform the following operations:
Dw_1.Modify ("#1. dddw. Name =;

// Select the records to print in dw_1
Long ll_pos
DataStore lds_ds
Lds_ds = create dataStore
Lds_ds.dataObject = dw_1.dataObject
For ll_pos = 1 to dw_1.rowCount ()
If dw_1.isselected (ll_pos) then
Dw_1.rowscopy (ll_pos, ll_pos, primary !, Lds_ds, lds_ds.rowcount () + 1, primary !)
End if
Next
Lds_ds.print ()

// You can click the button to terminate the loop.
Integer n
// Sb_interrupt is the shared variable
Sb_interrupt = false
For n = 1 to 3000
Yield ()
If sb_interrupt then // The value of sb_interrupt is changed to true in the clicked event of the "cancel" button.
MessageBox ("I quit", "you are really bad! ")
Sb_interrupt = false
Exit
Else // other processing, the current n value is displayed in the single line editor
Sle_1.text = string (n)
End if
Next

// SQL statement call Specification
INTEGER li_customer_id = 1
STRING ls_city_code = '20140901'
Prepare sqlsa from "DELETE bb_customer_info_t WHERE city_code =? AND customer_id =? ";
Execute sqlsa using: ls_city_code,: li_customer_id;

// Use the modify function to modify multiple tables at the same time
1. Create a data window d_grid_dep_emp. Its Select statement is
SELECT department. dept_id,
Department. dept_name,
Employee. emp_id,
Employee. emp_fname,
Employee. emp_lname
FROM department, employee
WHERE employee. dept_id = department. dept_id
2. Set the attribute of the data window d_grid_dep_emp, change the taborder of the column to a non-0 value, and click Rows --> Update
Properties, set this data window Allow Updates, Table to Update to department, Updateable Columns
Department. dept_id, department. dept_name.
3. Compile a script for the clicked event of the update data window button in the window:
Long ll_rtn
// Modify the Department table (the Department table is set as updatable in step 1)
Ll_rtn = dw_1.update (true, false)
If ll_rtn = 1 then
// Close the modification to the Department table
Dw_1.Modify ("department_dept_name.Update = 'No '")
Dw_1.modify ("department_dept_id.update = 'No '")
Dw_1.modify ("department_dept_id.key = 'No '")
// Set the employee table to a new modifiable table
Dw_1.modify ("datawindow. Table. updatetable = 'Employee '")
Dw_1.modify ("employee_emp_id.update = 'Yes '")
Dw_1.modify ("maid '")
Dw_1.modify ("maid '")
Dw_1.modify ("employee_emp_id.key = 'Yes '")
// Modify the Employee table
Ll_rtn = dw_1.Update ()
IF ll_rtn = 1 THEN
Commit using sqlca;
Dw_1.retrieve ()
Messagebox ('prompt information', 'Update successful! ')
ELSE
Rollback using sqlca;
MessageBox ('prompt information', 'Update failed! ')
END IF
// Reset the modification flag
Dw_1.Modify ("department_dept_name.Update = 'Yes '")
Dw_1.Modify ("department_dept_id.Update = 'Yes '")
Dw_1.Modify ("department_dept_id.Key = 'Yes '")
Dw_1.Modify ("DataWindow. Table. UpdateTable = 'department '")
Dw_1.Modify ("employee_emp_id.Update = 'No '")
Dw_1.modify ("maid '")
Dw_1.modify ("maid '")
Dw_1.modify ("employee_emp_id.key = 'No '")
Else
Rollback using sqlca;
MessageBox ('prompt information', 'Update failed! ')
End if
// You can use the preceding functions as a function and call them when necessary.

// Click the edit box to select the content
Code written in the getfocus event: This. selecttext (1, Len (this. Text )). Save and run, but we cannot get what we want
Effect. We came up with an alternative method: create a custom event ue_clicked in the single row editing box with pbm_bnclicked as the event ID,
The code is: This. selecttext (1, Len (this. Text )),
The code for the getfocus event is changed to: This. Post event ue_clicked (). Save and run. The effect is displayed!

// How to obtain the number of Chinese characters in a string
For I = 1 to Len (aString)
Ls_ch = Mid (aString, I, 1)
If Asc (ls_ch)> = 128 then // It is a Chinese character
Li_num ++
I = I + 1
End if
Next
// Finally, li_num is the number of Chinese Characters

// DW supports double-click titles for sorting
String ls_old_sort, ls_column, ls_name, ls_criteria
Char lc_sort
IF Right (dwo. Name, 2) = '_ t' THEN // obtain whether the column Name is
Ls_column = LEFT (dwo. Name, LEN (String (dwo. Name)-2)
Ls_old_sort = this. Describe ("Datawindow. Table. sort ")
IF ls_column = LEFT (ls_old_sort, LEN (ls_old_sort)-2) THEN
Lc_sort = RIGHT (ls_old_sort, 1)
IF lc_sort = 'A' THEN
Lc_sort = 'D'
ELSE
Lc_sort = 'A'
End if
This. setsort (ls_column + "" + lc_sort)
Else
Ls_criteria = ls_column + ""
This. setsort (ls_criteria)
End if
This. Sort ()
END IF

// DW supports multiple selections by pressing Ctrl or Shift
Int il_last_row // il_last_row is the instance variable and records the row that was last clicked.
Int li_current_row // The current row to be clicked
Int li_row // intermediate variable
// Return if not selected
If row = 0 then
Return
Else
Li_current_row = row
End if
If keydown (keyshift !) Then // press SHIFT
If il_last_row = 0 then
This. selectRow (row, true)
Il_last_row = li_current_row
Else
This. selectRow (0, false)
If li_current_row> il_last_row then
For li_row = il_last_row to li_current_row
This. selectrow (li_row, true)
End
Else
For li_row = il_last_row to li_current_row step-1
This. selectrow (li_row, true)
End
End if
End if
Else // SHIFT key not pressed
Il_last_row = li_current_row
If keydown (keycontrol !) Then // press CTRL
If this. isSelected (li_current_row) then
This. selectrow (li_current_row, false)
Else
This. selectrow (li_current_row, true)
End if
Else // press the key without CTRL or SHIFT
This. selectrow (0, false)
This. selectrow (li_current_row, true)
End if
End if

// Modify the DW query Condition Statement
String ls_select, ls_filter
Ls_select = dw_1.getSqlSelect ()
Ls_select = mid (ls_select, 1, pos (upper (ls_select), 'from') + 30)
Ls_filter = "WHERE service_kind =" + vi_service_kind + "order by FEE_ID ASC"
Ls_select = ls_select + ls_filter
Dw_1.Reset ()
Dw_1.SetTransObject (SQLCA)
Dw_1.SetSQLSelect (ls_select)
Dw_1.Retrieve ()

// CloseQuery event in the data window: prompts to save data
Dw_1.AcceptText ()
IF dw_1.ModifiedCount () + dw_1.DeletedCount ()> 0 THEN
Choose case MessageBox ("Operation prompt", "data has changed. Are you sure you want to save it? ", Question !, YesNoCancel !, 1)
CASE 1
Cb_save.TriggerEvent (clicked !)
CASE 2
Return 0 // close the window without any operation
CASE 3
Return 1 // do not run Close Event to maintain the original situation
END CHOOSE
END IF

// Prompt: select the record to delete
If dw_2.GetSelectedRow (0) = 0 then
MessageBox ("prompt message", "select the record to delete! ")
Return
End if

// Sort by a Field
IF dwo. name = "fee_id_t" THEN
This. setSort ("fee_id ")
This. sort ()
Elseif dwo. name = "fee_position_t" then
This. setsort ("fee_position a, fee_id ")
This. sort ()
END IF

// Control the number of lines displayed on each page in DATAWINDOW
1. Add a computing field in Datawindow named ceil_page, which must be placed in the Detail segment,
Enter ceiling (getrow ()/25) 25 in Expression to print 25 rows per page. It can also be a parameter.
2. Group, select Rows/Create Group, and select ceil_page.
Group by ceil_page and select New Page On Group Break ).
3. Set this calculation field to hidden (in the expression page on the property page, enter 0 in the visible attribute ).
4. fill blank rows:
Write the following code in the window open event:
Long li_count, li_ I
Li_count = dw_1.retrieve ()
If mod (li_count, 25) <> 0 then
For li_ I = 1 to 25-mod (li_count, 25)
Dw_1.insertrow (0)
Next
End if

// How to automatically fold data in the data window
1) Open the DataWindow object in DataWindow Painter.
2) double-click the column on which you want to set Automatic folding and open the attribute window for this column.
3) Select the Position tag and select the Autosize Height multiple selection box.
4) Select the Edit Tag, and do not select the Auto Horz Scroll multi-select box.
5) Click OK to save the changes.
6) Click "Detail Band" (that is, the gray long Band with Detail), right-click the Band, and select the Properties... menu item.
7) Select the Autosize Height multiple selection box.
8) Click OK to save the changes.
9) Save the DataWindow.
Note: If a Chinese character is connected together (no punctuation or space is separated in the middle), the system considers it a word and does not fold it automatically,
The same is true for English ...... If there are Chinese characters in the DW window, a space must be added in the middle to fold the line. Otherwise, no setting can be performed. For example, you
If you want to fold at 20th bits, first judge whether the 20th bits are Chinese characters. If not, add a space after the 20th bits.
19th digits with spaces. You can use its ASCII code to determine whether it is a Chinese character or not to determine whether it is greater than 127.

// Color the data of a row based on conditions
Case (CJ when is> = 90 then RGB (0,255, 0, 0) when is <60 then RGB (255, 0) else RGB )))

// Petabytes of data can be connected to multiple databases at the same time, such as sqlserver2000 and oracle8.
String ls_startupfile
Ls_startupfile = 'hisini. ini'
Sqlca. DBMS = profilestring (ls_startupfile, "Database", "DBMS ","")
Sqlca. Database = profilestring (ls_startupfile, "Database", "Database ","")
Sqlca. userid = profilestring (ls_startupfile, "Database", "userid ","")
Sqlca. dbpass = profilestring (ls_startupfile, "Database", "dbpass ","")
Sqlca. logid = profilestring (ls_startupfile, "Database", "logid ","")
Sqlca. logpass = profilestring (ls_startupfile, "Database", "logpassword ","")
Sqlca. servername = profilestring (ls_startupfile, "Database", "servername ","")
Sqlca. dbparm = ProfileString (ls_startupfile, "database", "dbparm ","")
Remote_trans = CREATE transaction
Remote_trans.DBMS = ProfileString (ls_startupfile, "Database_remote", "dbms ","")
Remote_trans.database = ProfileString (ls_startupfile, "Database_remote", "database ","")
Remote_trans.userid = ProfileString (ls_startupfile, "database_remote", "userid ","")
Remote_trans.dbpass = ProfileString (ls_startupfile, "database_remote", "dbpass ","")
Remote_trans.logid = ProfileString (ls_startupfile, "database_remote", "logid ","")
Remote_trans.logpass = ProfileString (ls_startupfile, "database_remote", "LogPassWord ","")
Remote_trans.servername = ProfileString (ls_startupfile, "database_remote", "servername ","")
Remote_trans.dbparm = ProfileString (ls_startupfile, "database_remote", "dbparm ","")
// Hisini. ini
[Database]
DBMS = MSS Microsoft SQL Server 6.x
Database = his
Userid =
Databasepassword =
Servername =.
Logid = sa
Lock =
Prompt = 0
Computer = '11'
OCX = 0
Use0 = 'hospitalization Management'
Cfprint = '1'
[Database_remote]
DBMS = "o84 oracle8/8i (8. X.4 + )"
Servername = "oracle8"
Logid = "dba"
Database = ZX
Userid =
Databasepassword =
Lock =
Prompt = 0
Computer = '11'
OCX = 0
Cfprint = '1'

// Pb6.5 connect Oracle8i and 9i
Sqlca. DBMS = "o84 oracle8/8i (8. X.4 + )"
Sqlca. logpass = "test"
Sqlca. servername = "myora"
Sqlca. logid = "test"
Sqlca. autocommit = false
Sqlca. dbparm = "tablecriteria = ', test, ''table'', ''view '''"

// Add a record to the Retrieved Data row
Datawindowchild DWC
Dw_service.getchild ('svcid', DWC)
DWC. settransobject (sqlca)
DWC. Retrieve ()
DWC. insertrow (1)
DWC. setitem (1, 'svcid', '00 ')
DWC. setitem (1, 'svcname', 'undistinguished ')
Dw_service.settransobject (sqlca)
Dw_service.retrieve ()

// Press enter in the data window to implement the tab function (in the enter event in the data window)
Send (handle (this), long ))
Return 1

// Send usage: Send (handle, message #, lowword, long)
// This statement scrolls the window w_emp up one page:
Send (handle (w_emp), 277, 2, 0)
// Both of the following statements click the commandbutton cb_ OK:
Send (handle (parent), 273, 0, handle (cb_ OK ))
Cb_ OK .triggerevent (clicked !)
// Minimizes the datawindow:
Send (handle (dw_1), 274,614 72, 0)
// Maximizes the datawindow:
Send (handle (dw_1), 274,614 88, 0)
// Returns the datawindow to its normal, defined size:
Send (handle (dw_1), 274,617 28, 0)

// Reset the search statement in the data window
Ls_accept_city = gs_citycode
Ld_beg_date = datetime (date (em_assign_beg_date.text), time ('00: 00: 00 '))
Ld_end_date = datetime (date (em_assign_end_date.text), time ('23: 59: 59 '))
Ls_where = "where B. assign_date >=: id_begin_date &
And B. assign_date <=: id_end_date &
And a. register_number = B. register_number &
AND a. accept_city =: is_accept_city &
AND a. action = 6 AND current_action = 1 AND status IN (1,-1 )"
Ls_ SQL = dw_wp.Describe ("DataWindow. Table. Select ")
If pos (ls_ SQL, 'where') <> 0 then
Ls_ SQL = mid (ls_ SQL, 1, pos (ls_ SQL, 'where')-1)
End if
Ls_ SQL = 'datawindow. Table. Select = "'+ ls_ SQL + ls_where + '"'
Ls_err_info = dw_wp.modify (ls_ SQL)
If ls_err_info <> "then
Messagebox ('prompt info', 'query exception, please check '+ ls_err_info)
Return
End if
Af_connect ()
Dw_wp.settransobject (sqlca)
Dw_wp.retrieve (ld_beg_date, ld_end_date, ls_accept_city)
Af_disconnect ()

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.