$PBExportHeader$w_publ_input_datetime.srw
forward
global type w_publ_input_datetime from w_publ_base
end type
type cbx_else from checkbox within w_publ_input_datetime
end type
type ddlb_op from dropdownlistbox within w_publ_input_datetime
end type
type sle_nr from editmask within w_publ_input_datetime
end type
type cbx_timeinuse from checkbox within w_publ_input_datetime
end type
type sle_time from editmask within w_publ_input_datetime
end type
type cb_add from uo_imflatbutton within w_publ_input_datetime
end type
type cb_repl from uo_imflatbutton within w_publ_input_datetime
end type
type sle_nr_end from editmask within w_publ_input_datetime
end type
type sle_time_end from editmask within w_publ_input_datetime
end type
type st_1 from statictext within w_publ_input_datetime
end type
type st_2 from statictext within w_publ_input_datetime
end type
type cbx_area from checkbox within w_publ_input_datetime
end type
type gb_1 from groupbox within w_publ_input_datetime
end type
type cbx_timeinuse_end from checkbox within w_publ_input_datetime
end type
type ddlb_date from dropdownlistbox within w_publ_input_datetime
end type
type gb_2 from groupbox within w_publ_input_datetime
end type
end forward

global type w_publ_input_datetime from w_publ_base
integer x = 407
integer y = 224
integer width = 1865
integer height = 520
string title = "请填入补充内容"
boolean minbox = false
windowtype windowtype = response!
cbx_else cbx_else
ddlb_op ddlb_op
sle_nr sle_nr
cbx_timeinuse cbx_timeinuse
sle_time sle_time
cb_add cb_add
cb_repl cb_repl
sle_nr_end sle_nr_end
sle_time_end sle_time_end
st_1 st_1
st_2 st_2
cbx_area cbx_area
gb_1 gb_1
cbx_timeinuse_end cbx_timeinuse_end
ddlb_date ddlb_date
gb_2 gb_2
end type
global w_publ_input_datetime w_publ_input_datetime

type variables

string cur_filter_expr
 //当前FILTER表达式

string cur_filter_expr_INCHA 
//当前FILTER表达式中文表示
s_esq_tran ls_esq_tran
//返回结构

INT SHORTHEIGHT=336,LONGHEIGHT=1000
end variables

forward prototypes
public function integer days_in_month (integer month, integer year)
end prototypes

public function integer days_in_month (integer month, integer year);//Most cases are straight forward in that there are a fixed number of 
//days in 11 of the 12 months.  February is, of course, the problem.
//In a leap year February has 29 days, otherwise 28.

Integer		li_DaysInMonth, li_Days[12] = {31,28,31,30,31,30,31,31,30,31,30,31}

// Get the number of days per month for a non leap year.
li_DaysInMonth = li_Days[Month]

// Check for a leap year.
If Month = 2 Then
	// If the year is a leap year, change the number of days.
	// Leap Year Calculation:
	//	Year divisible by 4, but not by 100, unless it is also divisible by 400
	If ( (Mod(Year,4) = 0 And Mod(Year,100) <> 0) Or (Mod(Year,400) = 0) ) Then
		li_DaysInMonth = 29
	End If
End If

//Return the number of days in the relevant month
Return li_DaysInMonth
end function

on w_publ_input_datetime.create
int iCurrent
call super::create
this.cbx_else=create cbx_else
this.ddlb_op=create ddlb_op
this.sle_nr=create sle_nr
this.cbx_timeinuse=create cbx_timeinuse
this.sle_time=create sle_time
this.cb_add=create cb_add
this.cb_repl=create cb_repl
this.sle_nr_end=create sle_nr_end
this.sle_time_end=create sle_time_end
this.st_1=create st_1
this.st_2=create st_2
this.cbx_area=create cbx_area
this.gb_1=create gb_1
this.cbx_timeinuse_end=create cbx_timeinuse_end
this.ddlb_date=create ddlb_date
this.gb_2=create gb_2
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cbx_else
this.Control[iCurrent+2]=this.ddlb_op
this.Control[iCurrent+3]=this.sle_nr
this.Control[iCurrent+4]=this.cbx_timeinuse
this.Control[iCurrent+5]=this.sle_time
this.Control[iCurrent+6]=this.cb_add
this.Control[iCurrent+7]=this.cb_repl
this.Control[iCurrent+8]=this.sle_nr_end
this.Control[iCurrent+9]=this.sle_time_end
this.Control[iCurrent+10]=this.st_1
this.Control[iCurrent+11]=this.st_2
this.Control[iCurrent+12]=this.cbx_area
this.Control[iCurrent+13]=this.gb_1
this.Control[iCurrent+14]=this.cbx_timeinuse_end
this.Control[iCurrent+15]=this.ddlb_date
this.Control[iCurrent+16]=this.gb_2
end on

on w_publ_input_datetime.destroy
call super::destroy
destroy(this.cbx_else)
destroy(this.ddlb_op)
destroy(this.sle_nr)
destroy(this.cbx_timeinuse)
destroy(this.sle_time)
destroy(this.cb_add)
destroy(this.cb_repl)
destroy(this.sle_nr_end)
destroy(this.sle_time_end)
destroy(this.st_1)
destroy(this.st_2)
destroy(this.cbx_area)
destroy(this.gb_1)
destroy(this.cbx_timeinuse_end)
destroy(this.ddlb_date)
destroy(this.gb_2)
end on

event open;call super::open;string ls_datetime

ls_esq_tran=Message.PowerObjectParm	
this.title='查询项目: '+ls_esq_tran.title 
ls_datetime=string(ls_esq_tran.dt_data) 

sle_nr.text=left(ls_datetime,10)
//sle_time.text=string(time(''))
cur_filter_expr=ls_esq_tran.cur_filter_expr
cur_filter_expr_INCHA=ls_esq_tran.cur_filter_expr_INCHA
//THIS.HEIGHT=SHORTHEIGHT

sle_nr_end.text=left(ls_datetime,10)

environment   exerun_env
GetEnvironment(exerun_env ) 

this.x=ls_esq_tran.x - 200
this.y=ls_esq_tran.y - 130
if this.x < 0 then this.x=0
if this.y < 0 then this.y=0
if this.x > PixelsToUnits(exerun_env.screenwidth, XPixelsToUnits!) - this.Width then this.x = PixelsToUnits(exerun_env.screenwidth, XPixelsToUnits!) - this.Width
if this.y > PixelsToUnits(exerun_env.screenheight, yPixelsToUnits!) - this.HeighT then this.y = PixelsToUnits(exerun_env.screenheight, yPixelsToUnits!) - this.HeighT

ls_esq_tran.return_flag=0

sle_nr.text=left(ls_datetime,10)
this.Height = 460



end event

event rbuttondown;cb_exit.postevent(clicked!)
end event

event close;CloseWithReturn(THIS,ls_esq_tran)
end event

type cb_func from w_publ_base`cb_func within w_publ_input_datetime
boolean visible = false
integer x = 1449
integer y = 192
integer taborder = 40
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_publ_input_datetime
integer x = 1170
integer y = 192
integer width = 325
integer taborder = 30
string text = "取消"
end type

type cbx_else from checkbox within w_publ_input_datetime
integer x = 1518
integer y = 16
integer width = 206
integer height = 76
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
long backcolor = 134217739
string text = "除外"
end type

type ddlb_op from dropdownlistbox within w_publ_input_datetime
integer x = 37
integer y = 48
integer width = 178
integer height = 440
integer taborder = 50
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "="
boolean sorted = false
boolean hscrollbar = true
string item[] = {">",">=","<","<=","="}
borderstyle borderstyle = stylelowered!
end type

type sle_nr from editmask within w_publ_input_datetime
integer x = 219
integer y = 44
integer width = 407
integer height = 88
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
alignment alignment = center!
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datetimemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

event rbuttondown;s_calender_arg s_calender
s_calender.PointerX = THIS.PointerX()
s_calender.PointerY = THIS.PointerY()
s_calender.X = THIS.X
s_calender.Y = THIS.Y


OpenWithParm(w_calendar,s_calender)
THIS.Text = String(id_date_selected)


end event

type cbx_timeinuse from checkbox within w_publ_input_datetime
integer x = 649
integer y = 52
integer width = 411
integer height = 76
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 255
long backcolor = 134217739
string text = "使用时间查询"
end type

event clicked;if cbx_timeinuse.checked then 
	sle_time.enabled=true
   ls_esq_tran.b_timeinuse=1
else
	sle_time.enabled=false
	ls_esq_tran.b_timeinuse=0
end if
end event

type sle_time from editmask within w_publ_input_datetime
integer x = 1129
integer y = 44
integer width = 347
integer height = 88
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean enabled = false
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = timemask!
string mask = "hh:mm:ss"
boolean spin = true
end type

type cb_add from uo_imflatbutton within w_publ_input_datetime
integer x = 699
integer y = 192
integer width = 325
integer height = 96
integer taborder = 60
boolean bringtotop = true
string text = "增加条件"
end type

event clicked;call super::clicked;String ls_date
String ls_time
String ls_date_end
String ls_time_end

ls_date = sle_nr.Text
ls_time = sle_time.Text
IF cbx_timeinuse.Checked THEN
	ls_esq_tran.dt_data = DateTime(Date(ls_date),Time(ls_time))
ELSE
	ls_esq_tran.dt_data = DateTime(Date(ls_date),Time(0))
END IF
ls_esq_tran.comp_op = ddlb_op.Text
ls_esq_tran.else_boolean = cbx_else.Checked
ls_esq_tran.return_flag = 1

ls_date_end = sle_nr_end.Text
ls_time_end = sle_time_end.Text
IF cbx_timeinuse_end.Checked THEN
	ls_esq_tran.dt_date_end = DateTime(Date(ls_date_end),Time(ls_time_end))
ELSE
	ls_esq_tran.dt_date_end = DateTime(Date(ls_date_end),Time(0))
END IF

ls_esq_tran.if_area = cbx_area.Checked


Close(PARENT)

end event

type cb_repl from uo_imflatbutton within w_publ_input_datetime
integer x = 229
integer y = 192
integer width = 325
integer taborder = 20
boolean bringtotop = true
string text = "重新查询"
boolean default = true
end type

event clicked;call super::clicked;String ls_date
String ls_time
String ls_date_end
String ls_time_end

ls_date = sle_nr.Text
ls_time = sle_time.Text
IF cbx_timeinuse.Checked THEN
	ls_esq_tran.dt_data = DateTime(Date(ls_date),Time(ls_time))
ELSE
	ls_esq_tran.dt_data = DateTime(Date(ls_date),Time(0))
END IF
ls_esq_tran.comp_op = ddlb_op.Text
ls_esq_tran.else_boolean = cbx_else.Checked
ls_esq_tran.return_flag = 2

ls_date_end = sle_nr_end.Text
ls_time_end = sle_time_end.Text
IF cbx_timeinuse_end.Checked THEN
	ls_esq_tran.dt_date_end = DateTime(Date(ls_date_end),Time(ls_time_end))
ELSE
	ls_esq_tran.dt_date_end = DateTime(Date(ls_date_end),Time(0))
END IF

ls_esq_tran.if_area = cbx_area.Checked

Close(PARENT)

end event

type sle_nr_end from editmask within w_publ_input_datetime
boolean visible = false
integer x = 219
integer y = 192
integer width = 407
integer height = 88
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
alignment alignment = center!
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datetimemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

event rbuttondown;s_calender_arg s_calender
s_calender.PointerX = THIS.PointerX()
s_calender.PointerY = THIS.PointerY()
s_calender.X = THIS.X
s_calender.Y = THIS.Y


OpenWithParm(w_calendar,s_calender)
THIS.Text = String(id_date_selected)


end event

type sle_time_end from editmask within w_publ_input_datetime
boolean visible = false
integer x = 1129
integer y = 192
integer width = 347
integer height = 88
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean enabled = false
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = timemask!
string mask = "hh:mm:ss"
boolean spin = true
end type

type st_1 from statictext within w_publ_input_datetime
boolean visible = false
integer x = 110
integer y = 212
integer width = 91
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
string text = "到"
alignment alignment = center!
boolean focusrectangle = false
end type

type st_2 from statictext within w_publ_input_datetime
boolean visible = false
integer x = 110
integer y = 60
integer width = 91
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
string text = "从"
alignment alignment = center!
boolean focusrectangle = false
end type

type cbx_area from checkbox within w_publ_input_datetime
integer x = 1518
integer y = 96
integer width = 402
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
long backcolor = 134217739
string text = "范围选择"
end type

event clicked;IF THIS.Checked THEN
	PARENT.Height = 570
	cb_repl.Y = 332
	cb_add.Y = 332
	cb_exit.Y = 332
	st_2.Visible = TRUE
	st_1.Visible = TRUE
	gb_2.Visible = TRUE
	sle_nr_end.Visible = TRUE
	cbx_timeinuse_end.Visible = TRUE
	
	sle_time_end.Visible = TRUE
	ddlb_op.Visible = FALSE
	
	ddlb_date.Visible = TRUE
ELSE
	PARENT.Height = 460
	cb_repl.Y = 192
	cb_add.Y = 192
	cb_exit.Y = 192
	st_2.Visible = FALSE
	st_1.Visible = FALSE
	gb_2.Visible = FALSE
	sle_nr_end.Visible = FALSE
	cbx_timeinuse_end.Visible = FALSE
	
	sle_time_end.Visible = FALSE
	ddlb_op.Visible = TRUE
	
	ddlb_date.Visible = FALSE
END IF


end event

type gb_1 from groupbox within w_publ_input_datetime
integer x = 800
integer y = 4
integer width = 695
integer height = 148
integer taborder = 70
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
end type

type cbx_timeinuse_end from checkbox within w_publ_input_datetime
boolean visible = false
integer x = 645
integer y = 196
integer width = 411
integer height = 76
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 255
long backcolor = 134217739
string text = "使用时间查询"
end type

event clicked;if this.checked then 
	sle_time_end.enabled=true
   ls_esq_tran.b_timeinuse_end=1
else
	sle_time_end.enabled=false
	ls_esq_tran.b_timeinuse_end=0
end if
end event

type ddlb_date from dropdownlistbox within w_publ_input_datetime
boolean visible = false
integer x = 1509
integer y = 172
integer width = 338
integer height = 300
integer taborder = 50
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "自设"
boolean sorted = false
string item[] = {"自设","本日","本周","本月"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;IF THIS.Text = "本日" THEN
	sle_nr.text = string(today(),"yyyy-mm-dd")
	sle_nr_end.text = string(today(),"yyyy-mm-dd")
ELSEIF THIS.Text = "本周" THEN
	int li_DayNum
	li_DayNum =  DayNumber(today())
	sle_nr.text = string(RelativeDate ( today(), 1 - li_DayNum ),"yyyy-mm-dd")
	sle_nr_end.text = string(RelativeDate ( today(), 7 - li_DayNum ),"yyyy-mm-dd")
ELSEIF THIS.Text = "本月" THEN
	int li_Month, li_Year, li_Days
	li_Month = Month(today())
	li_Year = Year(today())
	li_Days = days_in_month(li_Month, li_Year)
	sle_nr.text = string(Date(li_Year, li_Month, 1),"yyyy-mm-dd")
	sle_nr_end.text = string(Date(li_Year, li_Month, li_Days),"yyyy-mm-dd")
END IF

end event

type gb_2 from groupbox within w_publ_input_datetime
boolean visible = false
integer x = 800
integer y = 148
integer width = 695
integer height = 148
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
end type

