$PBExportHeader$w_fx_sctask_sel.srw
forward
global type w_fx_sctask_sel from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_fx_sctask_sel
end type
type cb_select from uo_imflatbutton within w_fx_sctask_sel
end type
type dw_fx_sctask from u_dw_rbtnfilter within w_fx_sctask_sel
end type
type cbx_all from checkbox within w_fx_sctask_sel
end type
end forward

global type w_fx_sctask_sel from w_publ_base_style
integer x = 2002
integer y = 500
integer width = 3511
integer height = 2428
string title = "派工单选择"
boolean minbox = false
windowtype windowtype = response!
string icon = "AppIcon!"
boolean if_ue_retr = true
boolean if_ue_filter = true
boolean if_ue_sort = true
boolean if_ue_sentdataout = true
cb_refresh cb_refresh
cb_select cb_select
dw_fx_sctask dw_fx_sctask
cbx_all cbx_all
end type
global w_fx_sctask_sel w_fx_sctask_sel

type variables
Long ins_cuscomid
end variables

forward prototypes
public subroutine wf_retrieve_mx ()
end prototypes

public subroutine wf_retrieve_mx ();String arg_msg
Long i,row
oleobject request,response,mxs,Item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('cuscomid',ins_cuscomid)

response = FXAppCom.DoExecute('GetFxScTaskSel', request)
arg_msg = response.GetString('ErrMsg')

If (arg_msg <> '') THEN
	MessageBox('提示', '获取待完工派工单列表失败，原因：' + arg_msg)
	RETURN
END IF

dw_fx_sctask.Reset()
dw_fx_sctask.SetRedraw(False)

mxs = response.GetArrOfPBDictionary('FxScTasks')
DateTime ld_now,requiredate
ld_now = DateTime(Today(),Now())
FOR i = 1 To mxs.Count
	Item = mxs.GetItem(i - 1)
	
	row = dw_fx_sctask.InsertRow(0)
	
	dw_fx_sctask.SetItem(row, 'fxtaskid', Item.GetInt('fxtaskid'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_fxtaskcode', Item.GetInt('fxtaskcode'))
	dw_fx_sctask.SetItem(row, 'fx_company_cusname', Item.GetString('cusname'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_erptaskcode', Item.GetString('erptaskcode'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_billtype', Item.GetInt('billtype'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_procode', Item.GetInt('procode'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_proname', Item.GetInt('proname'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_qty', Item.GetDouble('qty'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_fqty', Item.GetDouble('fqty'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_backqty', Item.GetDouble('backqty'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_backreason', Item.GetString('backreason'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_backemp', Item.GetString('backemp'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_backdate', Item.GetDatetime('fxtaskid'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_taskdate', Item.GetDatetime('taskdate'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_rqdate', Item.GetDatetime('rqdate'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_dscrp', Item.GetString('dscrp'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_status', Item.GetString('status'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_mtrlcode', Item.GetString('mtrlcode'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_mtrlname', Item.GetString('mtrlname'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_mtrlmode', Item.GetString('mtrlmode'))
	dw_fx_sctask.SetItem(row, 'fx_sc_task_unit', Item.GetString('unit'))
	dw_fx_sctask.SetItem(row, 'billtypestr', Item.GetString('billtypestr'))
	dw_fx_sctask.SetItem(row, 'statusstr', Item.GetString('statusstr'))
	dw_fx_sctask.SetItem(row, 'unfqty', Item.GetDouble('unfqty'))
	dw_fx_sctask.SetItem(row, 'ch', 0)
	
	
NEXT

dw_fx_sctask.SetRedraw(True)

end subroutine

on w_fx_sctask_sel.create
int iCurrent
call super::create
this.cb_refresh=create cb_refresh
this.cb_select=create cb_select
this.dw_fx_sctask=create dw_fx_sctask
this.cbx_all=create cbx_all
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_refresh
this.Control[iCurrent+2]=this.cb_select
this.Control[iCurrent+3]=this.dw_fx_sctask
this.Control[iCurrent+4]=this.cbx_all
end on

on w_fx_sctask_sel.destroy
call super::destroy
destroy(this.cb_refresh)
destroy(this.cb_select)
destroy(this.dw_fx_sctask)
destroy(this.cbx_all)
end on

event resize;call super::resize;r_bar.height = this.height
dw_fx_sctask.width = this.workspacewidth()
dw_fx_sctask.height = this.workspaceheight() - dw_fx_sctask.y
end event

event open;call super::open;ins_cuscomid = Message.DoubleParm
wf_movetocenter()

wf_retrieve_mx()
end event

type cb_func from w_publ_base_style`cb_func within w_fx_sctask_sel
boolean visible = false
end type

type cb_exit from w_publ_base_style`cb_exit within w_fx_sctask_sel
integer x = 315
end type

type ln_bar from w_publ_base_style`ln_bar within w_fx_sctask_sel
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_fx_sctask_sel
end type

type r_bar from w_publ_base_style`r_bar within w_fx_sctask_sel
end type

type cb_refresh from uo_imflatbutton within w_fx_sctask_sel
integer width = 151
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "刷新"
string normalpicname = "refresh.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;wf_retrieve_mx()
end event

type cb_select from uo_imflatbutton within w_fx_sctask_sel
integer x = 151
integer y = 4
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "选定"
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;datastore ds
ds = create datastore
ds.DataObject = 'dw_fx_sctask_sel'

//返回选择数据
long i,row

ds.Reset()

for i = 1 to dw_fx_sctask.RowCount()
	row = 0
	if dw_fx_sctask.Object.ch[i] = 1 then
		row++
		dw_fx_sctask.RowsCopy(i, i, Primary!, ds, row, Primary!)
	end if
next


CloseWithReturn(PARENT, ds)
end event

type dw_fx_sctask from u_dw_rbtnfilter within w_fx_sctask_sel
integer y = 188
integer width = 3515
integer height = 2140
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_fx_sctask_sel"
boolean hscrollbar = true
boolean vscrollbar = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event clicked;call super::clicked;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if
end event

type cbx_all from checkbox within w_fx_sctask_sel
integer x = 517
integer y = 48
integer width = 251
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 67108864
string text = "全选"
end type

event clicked;long ll_i, ll_checked
IF cbx_all.Checked THEN
	ll_checked = 1
ELSE
	ll_checked = 0
END IF

FOR ll_i = 1 TO dw_fx_sctask.RowCount()
	dw_fx_sctask.Object.ch[ll_i] = ll_checked
NEXT
	
end event

