$PBExportHeader$w_sortrow.srw
$PBExportComments$排序窗口
forward
global type w_sortrow from w_publ_base
end type
type cb_del from uo_imflatbutton within w_sortrow
end type
type cb_add from uo_imflatbutton within w_sortrow
end type
type cb_1 from uo_imflatbutton within w_sortrow
end type
type dw_criteria from u_dw within w_sortrow
end type
end forward

global type w_sortrow from w_publ_base
integer x = 617
integer y = 364
integer width = 1385
integer height = 716
string title = "排序"
boolean minbox = false
windowtype windowtype = response!
cb_del cb_del
cb_add cb_add
cb_1 cb_1
dw_criteria dw_criteria
end type
global w_sortrow w_sortrow

type variables
Long i_lRow
String i_aszTypes[]
DataWindow i_dwToActOn
end variables

on w_sortrow.create
int iCurrent
call super::create
this.cb_del=create cb_del
this.cb_add=create cb_add
this.cb_1=create cb_1
this.dw_criteria=create dw_criteria
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_del
this.Control[iCurrent+2]=this.cb_add
this.Control[iCurrent+3]=this.cb_1
this.Control[iCurrent+4]=this.dw_criteria
end on

on w_sortrow.destroy
call super::destroy
destroy(this.cb_del)
destroy(this.cb_add)
destroy(this.cb_1)
destroy(this.dw_criteria)
end on

event open;call super::open;Integer nColumnCount, nColumnIndex
String  szColumn
Long lRow
DataWindowChild dwcColumns
string des_1,des_2

i_dwToActOn = Message.PowerObjectParm
i_lRow = 0

nColumnCount = Integer( i_dwToActOn.Object.DataWindow.Column.Count)

dw_criteria.GetChild( "column_number", dwcColumns)

i_aszTypes[ nColumnCount] = ""

For nColumnIndex = 1 To nColumnCount
	des_1= i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".Name") 
	des_2= i_dwtoacton.describe(des_1+ "_t.Text")
	szColumn = f_strip( i_dwToActOn.Describe( i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".Name") + "_t.Text"))
	If szColumn <> "!" Then
		lRow = dwcColumns.InsertRow( 0)
		dwcColumns.SetItem( lRow, "column_name", szColumn)
		dwcColumns.SetItem( lRow, "column_number", nColumnIndex)
		i_aszTypes[ nColumnIndex] = i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".ColType")
	End If
Next

dw_criteria.TriggerEvent( "NewRow")
end event

type cb_func from w_publ_base`cb_func within w_sortrow
boolean visible = false
integer y = 488
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_sortrow
integer x = 791
integer y = 488
integer width = 325
string text = "取消"
end type

type cb_del from uo_imflatbutton within w_sortrow
integer x = 1001
integer y = 136
integer width = 325
integer height = 96
integer taborder = 41
string text = "删除行"
end type

event clicked;call super::clicked;dw_criteria.TriggerEvent( "DELETERow")
end event

type cb_add from uo_imflatbutton within w_sortrow
integer x = 1001
integer y = 16
integer width = 325
integer height = 96
integer taborder = 41
string text = "增加行"
end type

event clicked;call super::clicked;dw_criteria.TriggerEvent( "NewRow")
end event

type cb_1 from uo_imflatbutton within w_sortrow
integer x = 311
integer y = 488
integer width = 325
integer height = 96
integer taborder = 41
boolean default = true
end type

event clicked;call super::clicked;Long lNoOfCriteria, lRow, lColumnNo,lLen
Integer nPos
String szFind,szColumn,szOperator 
STRING szExpression=''
lNoOfCriteria = dw_criteria.RowCount()

For lRow = 1 To lNoOfCriteria
	lColumnNo = dw_criteria.GetItemNumber( lRow, "column_number")
   szColumn = i_dwToActOn.Describe( "#" + String( lColumnNo) + ".Name")//dbName  //FILTER 与SELECT 区别
	If IsNull( dw_criteria.GetItemNumber( lrow, "column_number")) Then
	   exit
   End If
   szOperator = ( dw_criteria.GetItemString( lRow, "operators"))
	szExpression = szExpression + szColumn +' '+ szOperator + ',' 
Next

SZFIND=trim(szExpression)
if right(SZFIND,1)=',' THEN
	SZFIND=LEFT(SZFIND,LEN(SZFIND) - 1)
END IF
//
//MESSAGEBOX('',SZFIND)
//
Closewithreturn(parent,szfind)
end event

type dw_criteria from u_dw within w_sortrow
integer x = 18
integer y = 12
integer width = 951
integer height = 448
integer taborder = 20
boolean bringtotop = true
string dataobject = "d_sort"
boolean vscrollbar = true
boolean border = false
end type

