1. wroot_dw_query屬性:
X = 9 Y = 1132 Width = 2912 Height = 712
Visible = true Enabled = true TitleBar = true Title = "定位查詢"
ControlMenu = true Border = true WindowType = response! WindowState = normal!
BackColor = 79741120
2. 窗口實例變量:
Boolean ib_changed
Long MaxEditRow = 1
String sWhere, oldsql, orisql, is_title, is_section = 'WhereClause'
DataWindow dw_result,dw_detail
pfc_n_cst_string inv_string
string sSyntax
注釋:a.pfc_n_cst_string 為PFC用戶對象。
3. 窗口事件代碼:
3.1 close 事件:
功能:將用戶本次所輸入的查詢條件記錄到文件sIniFile的WhereClause1...n小節中去以備下次啟動時置初始查詢條件。
3.2 open 事件:
功能:設置初始值,具體請看代碼中的注釋。
integer i, row, li_where_row = 10
string tmp
str_result_column lstr_1
//結構str_result_column的成員adw_result指查詢結果所產生作用的dw
// 成員adw_column指在本窗口查詢條件所要顯示的dw
lstr_1 = Message.PowerObjectParm
dw_result = lstr_1.adw_result
dw_detail = lstr_1.adw_column
if isnull(dw_result) or not isvalid(dw_result) then return
if isnull(lstr_1.adw_column) or not isvalid(lstr_1.adw_column) then return
window act_w
act_w=MainWindow.getactivesheet()
x = act_w.x + 8
y = act_w.y + act_w.height - height+258
width = act_w.width
cb_exec.x=width - cb_exec.width -80
cb_exit.x=width - cb_exec.width -80
dw_where.x=10
dw_where.Width = width - 2 * dw_where.X - cb_exec.width -100
//-----s
dw_column.visible = False
wf_setcolumn(lstr_1.adw_column, dw_column)
//orisql = dw_result.Object.DataWindow.Table.Select //原始語法,close中用.
orisql = dw_result.GetSqlSelect() //上句對CrossTab無效
oldsql = lower(orisql)
For i = 1 to li_where_row
dw_where.InsertRow(0)
Next
dw_where.setrowfocusindicator(Hand!)
dw_where.ScrollToRow(0)
dw_where.SetColumn("column1")
cb_exec.SetFocus()
datawindowchild dwc
dw_where.GetChild("column1",dwc)
dwc.SetTransObject(sqlca)
dwc.Reset()
For i = 1 to dw_column.RowCount()
tmp = dw_column.GetItemString(i,1)
row = dwc.InsertRow(0)
dwc.SetItem(row,1,tmp)
Next
//將用戶上次所輸入的查詢條件從文件sIniFile的WhereClause1...n小節中取出來,
//本次啟動時置為初始查詢條件.
window w_parent
if dw_result.GetParent().typeof() = window! then
w_parent = dw_result.GetParent()
is_title = w_parent.title
else
is_title = dw_result.DataObject
end if
ib_changed = True
row = 0
tmp = ''
is_title = gnv_app.is_regkey + '\' + is_title + '\' + scname
For i = 1 to li_where_row
RegistryGet(is_title, is_section + String(i), RegString!, tmp)
//tmp = ProfileString(sinifile,is_title,"WhereClause" + string(i),"")
if tmp <> "" and (Not IsNull(tmp)) then
//SetProfileString(sinifile,is_title,"WhereClause" + string(i),"")
RegistrySet(is_title, is_section + String(i), RegString!, '')
row ++
dw_where.object.data[row,1] = inv_string.of_gettoken(tmp, ",")
dw_where.object.data[row,2] = inv_string.of_gettoken(tmp, ",")
dw_where.object.data[row,3] = inv_string.of_gettoken(tmp, ",")
dw_where.object.data[row,4] = inv_string.of_gettoken(tmp, ",")
dw_where.object.data[row,5] = inv_string.of_gettoken(tmp, ",")
dw_where.object.data[row,6] = inv_string.of_gettoken(tmp, ",")
end if
Next
MaxEditRow = row // MaxEditRow 為dw_where中當前已編輯過的最大行的行號.實例變量.
If MaxEditRow = 0 Then MaxEditRow = 1