$PBExportHeader$w_v2_dw_filter_rsp.srw
forward
global type w_v2_dw_filter_rsp from w_publ_base
end type
type uo_1 from uo_v2_dw_filter within w_v2_dw_filter_rsp
end type
type pb_1 from uo_v2_button within w_v2_dw_filter_rsp
end type
type pb_2 from uo_v2_button within w_v2_dw_filter_rsp
end type
type pb_3 from uo_v2_button within w_v2_dw_filter_rsp
end type
type pb_4 from uo_v2_button within w_v2_dw_filter_rsp
end type
type mle_1 from multilineedit within w_v2_dw_filter_rsp
end type
type shl_1 from uo_v2_sthl within w_v2_dw_filter_rsp
end type
type shl_2 from uo_v2_sthl within w_v2_dw_filter_rsp
end type
type gb_3 from groupbox within w_v2_dw_filter_rsp
end type
end forward

global type w_v2_dw_filter_rsp from w_publ_base
integer width = 1376
integer height = 1776
string title = ""
boolean minbox = false
windowtype windowtype = response!
event windowposchanging pbm_windowposchanging
event ue_report_style ( )
event ue_save_style ( )
uo_1 uo_1
pb_1 pb_1
pb_2 pb_2
pb_3 pb_3
pb_4 pb_4
mle_1 mle_1
shl_1 shl_1
shl_2 shl_2
gb_3 gb_3
end type
global w_v2_dw_filter_rsp w_v2_dw_filter_rsp

type variables
datawindow dw_1 // 当前操作DW
string ins_colname // 当前操作列
long ins_row // 当前操作行，0-没有操作行

private:
uo_string lo_str
end variables

forward prototypes
public function integer wf_movetocenter ()
end prototypes

event windowposchanging;// DONE: 点击窗口外自动关闭窗口
//IF runtimeLog THEN sys_trace(classname()+" - [windowposchanging]hwndafter:"+string(hwndafter)+", xpos:"+string(xpos)+", ypos:"+string(ypos)+", newwidth:"+string(newwidth)+", newheight:"+string(newheight)+", flags:"+string(flags)+"")
//
//if flags = 19 AND xpos = 0 AND ypos = 0 AND newwidth = 0 AND newheight = 0 then
//	close(this)
//end if
end event

event ue_report_style();string ls_parms

ls_parms = string(Message.LongParm, "address")

long ll_empid
string ls_stylename
long ll_pos

ll_pos = pos(ls_parms, ':')
ls_stylename = mid(ls_parms, ll_pos + 1)
ll_empid = long(left(ls_parms, ll_pos - 1))

string ls_dwname
ls_dwname = dw_1.DataObject

string dwnSyntax_filter
string dwnSyntax_sort
string dwnSyntax_layout_column_visible
string dwnSyntax_layout_column_width
string dwnSyntax_layout_column_x

SELECT
dwnSyntax_filter,
dwnSyntax_sort,
dwnSyntax_layout_column_visible,
dwnSyntax_layout_column_width,
dwnSyntax_layout_column_x
INTO
:dwnSyntax_filter,
:dwnSyntax_sort,
:dwnSyntax_layout_column_visible,
:dwnSyntax_layout_column_width,
:dwnSyntax_layout_column_x
FROM u_user_report_style with(nolock)
WHERE empid = :ll_empid
AND dwname = :ls_dwname
AND stylename = :ls_stylename;
if sqlca.sqlcode <> 0 then return


// DONE: 应用查询方案

dw_1.SetRedraw(FALSE)
dw_1.Modify(dwnSyntax_layout_column_visible)
dw_1.Modify(dwnSyntax_layout_column_width)
dw_1.Modify(dwnSyntax_layout_column_x)

dw_1.SetFilter(dwnSyntax_filter)
dw_1.SetRedraw (FALSE)
dw_1.Filter()

dw_1.SetSort(dwnSyntax_sort)
dw_1.SetRedraw (FALSE)
dw_1.Sort()
dw_1.SetRedraw(TRUE)

CLOSE(this)

end event

event ue_save_style();// DONE: 保存查询方案
u_dw_rbtnfilter ldw // 同dw_1，如果类型兼容就有值
try 
	ldw = dw_1
catch ( Throwable ex )
	/*statementBlock*/
end try
IF NOT IsValid(ldw) THEN RETURN

IF MessageBox('询问','是否确定要保存当前报表查询方案?',question!,yesno!) = 2 THEN RETURN


ldw.uf_getnewlayout()

s_user_report_style s_style

s_style.edittype = 0
s_style.Sort = ldw.curDW_sortstr
s_style.Filter = ldw.curDW_filterstr
s_style.Visible = ldw.ins_mdfstr_column_visible
s_style.Width = ldw.ins_mdfstr_column_width
s_style.column_x = ldw.ins_mdfstr_column_x
s_style.dwname = ldw.dataobject
s_style.empid = sys_empid

OpenWithParm(w_report_style_edit,s_style)
end event

public function integer wf_movetocenter ();// DONE: 跟随鼠标

//wf_movetocenter
environment   exerun_env 
GetEnvironment(exerun_env ) 

//long ll_res
//s_get_taskheight  strc_rect 
//ll_res = SystemParametersInfoA(48,0,strc_rect,0) //获取屏幕四个坐标
//
//任务栏高度
long ll_taskbarheight
ll_taskbarheight = 62 //PixelsToUnits(exerun_env.screenheight - strc_rect.bottom,YPixelsToUnits!)

long ll_screenwidth, ll_screenheight
ll_screenwidth = PixelsToUnits(exerun_env.screenwidth, XPixelsToUnits!)
ll_screenheight = PixelsToUnits(exerun_env.screenheight - ll_taskbarheight, YPixelsToUnits!)
 
 long ll_x, ll_y
 
// if if_maxheight then
//	this.height = ll_screenheight
//end if
 
//if if_follow_cursor then
	ll_x = this.X + PointerX()
	if ll_x + this.width > ll_screenwidth then ll_x = ll_screenwidth - this.width
	if ll_x < 0 then ll_x = 0
	
	ll_y = this.y + PointerY()
	if ll_y + this.height > ll_screenheight then ll_y = ll_screenheight - this.height
	if ll_y < 0 then ll_y = 0
	IF runtimeLog THEN sys_trace(classname()+" - Move(cursor)")
	this.Move(ll_x, ll_y)
//else
//	IF runtimeLog THEN sys_trace(classname()+" - Move(center)")
//	this.Move ( (ll_screenwidth - this.Width)/2,&
//		(ll_screenheight - this.Height) / 2) //
//	//this.Move ( (exerun_env.screenwidth*4.62 - this.Width)/2, (exerun_env.screenheight*3.87 - this.Height)/2)	
//end if

return 0
end function

on w_v2_dw_filter_rsp.create
int iCurrent
call super::create
this.uo_1=create uo_1
this.pb_1=create pb_1
this.pb_2=create pb_2
this.pb_3=create pb_3
this.pb_4=create pb_4
this.mle_1=create mle_1
this.shl_1=create shl_1
this.shl_2=create shl_2
this.gb_3=create gb_3
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.uo_1
this.Control[iCurrent+2]=this.pb_1
this.Control[iCurrent+3]=this.pb_2
this.Control[iCurrent+4]=this.pb_3
this.Control[iCurrent+5]=this.pb_4
this.Control[iCurrent+6]=this.mle_1
this.Control[iCurrent+7]=this.shl_1
this.Control[iCurrent+8]=this.shl_2
this.Control[iCurrent+9]=this.gb_3
end on

on w_v2_dw_filter_rsp.destroy
call super::destroy
destroy(this.uo_1)
destroy(this.pb_1)
destroy(this.pb_2)
destroy(this.pb_3)
destroy(this.pb_4)
destroy(this.mle_1)
destroy(this.shl_1)
destroy(this.shl_2)
destroy(this.gb_3)
end on

event open;call super::open;s_v2_dw_parms ls_parms
ls_parms = Message.PowerObjectParm

lo_str = Create uo_string

dw_1 = ls_parms.arg_dw
ins_colname = ls_parms.arg_colname
ins_row = ls_parms.arg_row

uo_1.uof_set_dw_col(dw_1, ins_colname, ins_row)

String ls_colname
ls_colname = dw_1.Describe(ins_colname+"_t.text")
IF ls_colname = "!" Or ls_colname = "?" THEN
	ls_colname = ins_colname
END IF

This.Title = ls_colname

//String ls_sortname
//ls_sortname = lo_str.uof_dw_getsortname(dw_1)
//IF ls_sortname <> '' THEN
//	gb_2.Text = "补充排序("+ls_sortname+"...)"
//ELSE
//	gb_2.Text = "补充排序"
//END IF

// TODO: 获取字段提示信息及帮助
String ls_msgid
ls_msgid = dw_1.Describe(ins_colname+"_t.Tooltip.Title")

IF ls_msgid = '' OR ls_msgid = '!' OR ls_msgid = '?' THEN
	gb_3.Visible = False
	shl_1.Visible = False
	shl_2.Visible = False
	RETURN
END IF

gb_3.Text = gb_3.Text + "["+ls_msgid+"]"

s_kms_msg s_rslt
String ls_doccode = ''
s_rslt = kms_GetKMS_MSG(ls_msgid,"","","","","")
mle_1.Text = s_rslt.msg
ls_doccode = s_rslt.doccode1
IF ls_doccode = '' THEN
	ls_doccode = s_rslt.doccode2
END IF

IF ls_doccode = '' THEN
	shl_1.Visible = False
	shl_2.Visible = False
	RETURN
END IF

string ls_token
ls_token = kms_gettoken()

string ls_url
ls_url = sys_kms_root + "/knowledge/view/docview?code=" + ls_doccode
IF ls_token <> "" THEN
	ls_url += "&token="+ls_token
END IF

shl_1.URL = ls_url

//IF f_power_ind(6431,sys_msg_pow) AND ls_token <> "" THEN
//	shl_2.URL = sys_kms_root + "/knowledge/management/docedit?code=" + ls_doccode+"&token="+ls_token
//ELSE
	shl_2.Visible = False
//END IF


end event

event close;call super::close;destroy lo_str
end event

event other;call super::other;IF runtimeLog THEN sys_trace(classname()+" - other("+string(wparam)+", "+string(lparam)+") Msg:"+f_getwm(Message.number))
end event

type cb_func from w_publ_base`cb_func within w_v2_dw_filter_rsp
boolean visible = false
integer taborder = 30
end type

type cb_exit from w_publ_base`cb_exit within w_v2_dw_filter_rsp
boolean visible = false
end type

type uo_1 from uo_v2_dw_filter within w_v2_dw_filter_rsp
integer x = 23
integer y = 172
integer taborder = 20
boolean bringtotop = true
end type

on uo_1.destroy
call uo_v2_dw_filter::destroy
end on

event ue_close;call super::ue_close;close(parent)
end event

type pb_1 from uo_v2_button within w_v2_dw_filter_rsp
integer x = 18
integer y = 8
integer width = 283
integer height = 152
integer taborder = 50
boolean bringtotop = true
string text = ""
string picturename = "graphics\asc.png"
end type

event clicked;call super::clicked;string ls_sort
ls_sort = ins_colname + " A"

dw_1.SetSort(ls_sort)
dw_1.Sort()

u_dw_rbtnfilter ldw // 同dw_1，如果类型兼容就有值
try 
	ldw = dw_1
catch ( Throwable ex )
	/*statementBlock*/
end try
IF IsValid(ldw) THEN ldw.curdw_sortstr = ls_sort


close(parent)
end event

type pb_2 from uo_v2_button within w_v2_dw_filter_rsp
integer x = 302
integer y = 8
integer width = 283
integer height = 152
integer taborder = 70
boolean bringtotop = true
string text = ""
boolean originalsize = false
string picturename = "graphics\desc.png"
end type

event clicked;call super::clicked;string ls_sort
ls_sort = ins_colname + " D"

dw_1.SetSort(ls_sort)
dw_1.Sort()

u_dw_rbtnfilter ldw // 同dw_1，如果类型兼容就有值
try 
	ldw = dw_1
catch ( Throwable ex )
	/*statementBlock*/
end try
IF IsValid(ldw) THEN ldw.curdw_sortstr = ls_sort

close(parent)
end event

type pb_3 from uo_v2_button within w_v2_dw_filter_rsp
integer x = 585
integer y = 8
integer width = 283
integer height = 152
integer taborder = 80
boolean bringtotop = true
string text = "补充升序"
long backcolor = 134217750
end type

event clicked;call super::clicked;string ls_sort
ls_sort = ins_colname + " A"

lo_str.uof_dw_append_sort(dw_1, ref ls_sort)
dw_1.Sort()

u_dw_rbtnfilter ldw // 同dw_1，如果类型兼容就有值
try 
	ldw = dw_1
catch ( Throwable ex )
	/*statementBlock*/
end try
IF IsValid(ldw) THEN ldw.curdw_sortstr = ls_sort

close(parent)
end event

type pb_4 from uo_v2_button within w_v2_dw_filter_rsp
integer x = 869
integer y = 8
integer width = 283
integer height = 152
integer taborder = 90
boolean bringtotop = true
string text = "补充降序"
long backcolor = 134217750
end type

event clicked;call super::clicked;string ls_sort
ls_sort = ins_colname + " D"

lo_str.uof_dw_append_sort(dw_1, ref ls_sort)
dw_1.Sort()

u_dw_rbtnfilter ldw // 同dw_1，如果类型兼容就有值
try 
	ldw = dw_1
catch ( Throwable ex )
	/*statementBlock*/
end try
IF IsValid(ldw) THEN ldw.curdw_sortstr = ls_sort

close(parent)
end event

type mle_1 from multilineedit within w_v2_dw_filter_rsp
integer x = 41
integer y = 1444
integer width = 1042
integer height = 220
integer taborder = 110
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
boolean border = false
boolean autovscroll = true
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type shl_1 from uo_v2_sthl within w_v2_dw_filter_rsp
integer x = 1207
integer y = 1484
integer width = 123
integer height = 56
boolean bringtotop = true
string text = "帮助"
end type

type shl_2 from uo_v2_sthl within w_v2_dw_filter_rsp
integer x = 1097
integer y = 1560
integer width = 233
integer height = 56
boolean bringtotop = true
string text = "编辑帮助"
end type

type gb_3 from groupbox within w_v2_dw_filter_rsp
integer x = 23
integer y = 1384
integer width = 1330
integer height = 300
integer taborder = 100
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "提示"
end type

