$PBExportHeader$w_saletask_fx_finish_edit_del.srw
forward
global type w_saletask_fx_finish_edit_del from window
end type
type cb_3 from commandbutton within w_saletask_fx_finish_edit_del
end type
type cb_2 from commandbutton within w_saletask_fx_finish_edit_del
end type
type cb_1 from commandbutton within w_saletask_fx_finish_edit_del
end type
type dw_1 from u_dw_rbtnfilter within w_saletask_fx_finish_edit_del
end type
type ln_bar from line within w_saletask_fx_finish_edit_del
end type
type r_bar from rectangle within w_saletask_fx_finish_edit_del
end type
end forward

global type w_saletask_fx_finish_edit_del from window
integer width = 4302
integer height = 1816
boolean titlebar = true
string title = "删除完工数"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 134217739
string icon = "AppIcon!"
boolean center = true
cb_3 cb_3
cb_2 cb_2
cb_1 cb_1
dw_1 dw_1
ln_bar ln_bar
r_bar r_bar
end type
global w_saletask_fx_finish_edit_del w_saletask_fx_finish_edit_del

type variables
Long ins_taskid
String ins_taskcode
end variables

forward prototypes
public function integer wf_get_filedata (string arg_filedir, string arg_filemd5, string arg_filetype, ref string arg_msg)
public function integer wf_refresh (long arg_taskid)
end prototypes

public function integer wf_get_filedata (string arg_filedir, string arg_filemd5, string arg_filetype, ref string arg_msg);Long rslt = 1

oleobject parm
parm = FxAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('fileDir', arg_filedir)
parm.SetString('filename', arg_filemd5)
parm.SetString('extension', arg_filetype)
parm.SetString('md5', arg_filemd5)
FXAppCom.GetFileDataByMd5(parm, ref arg_msg)
IF NOT ISNULL(arg_msg) AND Len(arg_msg) > 0 THEN
	rslt = 0
	GOTO ext
END IF

ext:
RETURN rslt

end function

public function integer wf_refresh (long arg_taskid);int rslt = 1

if (IsNull(arg_taskid)) then return 0

string arg_msg = ''
oleobject list,request,response
request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("taskid",arg_taskid)
request.SetInt("printid",-1)
response = FXAppCom.DoExecute("GetFxSaletaskmxFinishmx", request)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取订单明细有误:' + arg_msg)
	goto ext
end if

list = response.GetArrOfPBDictionary('finishList')
// 订单明细
dw_1.Reset( )
dw_1.SetRedraw(false)
long i
any requiredate
oleobject item

IF ISNULL(list) THEN 
	return rslt
END IF

for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	dw_1.Object.printid[i] = item.GetInt('printid')
	dw_1.Object.mtrlcode[i] = item.GetString('mtrlcode')
	dw_1.Object.mtrlname[i] = item.GetString('mtrlname')
	dw_1.Object.mtrlmode[i] = item.GetString('mtrlmode')
	
	dw_1.Object.finishqty[i] = item.GetDouble('finishqty')
	dw_1.Object.finishtime[i] = item.GetDateTime('finishtime')
	
	dw_1.Object.status[i] = item.GetString('status')
	dw_1.Object.woodcode[i] = item.GetString('woodcode')
	dw_1.Object.pcode[i] = item.GetString('pcode')
	dw_1.Object.plancode[i] = item.GetString('plancode')
	
next
dw_1.AcceptText()
//dw_1.SetSort('mxid')
//dw_1.Sort()
dw_1.SetRedraw(true)


ext:
return rslt


end function

on w_saletask_fx_finish_edit_del.create
this.cb_3=create cb_3
this.cb_2=create cb_2
this.cb_1=create cb_1
this.dw_1=create dw_1
this.ln_bar=create ln_bar
this.r_bar=create r_bar
this.Control[]={this.cb_3,&
this.cb_2,&
this.cb_1,&
this.dw_1,&
this.ln_bar,&
this.r_bar}
end on

on w_saletask_fx_finish_edit_del.destroy
destroy(this.cb_3)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.dw_1)
destroy(this.ln_bar)
destroy(this.r_bar)
end on

event open;s_edit_index_tran s_tran //翻页功能窗口 传递参数使用
s_tran = Message.PowerObjectParm

ins_taskid = s_tran.b_long
ins_taskcode = s_tran.b_string


//Long i
//for i = 1 to dw_1.rowcount()
//	dw_1.object.ex_finishqty[i] = 0
//next

wf_refresh(ins_taskid)
end event

event resize;ln_bar.EndX = THIS.Width
r_bar.Width = THIS.Width
end event

type cb_3 from commandbutton within w_saletask_fx_finish_edit_del
integer width = 261
integer height = 116
integer taborder = 30
integer textsize = -11
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "删除"
end type

event clicked;long row
row = dw_1.getrow()

IF row > 0 then
	dw_1.deleterow(row)
end if
end event

type cb_2 from commandbutton within w_saletask_fx_finish_edit_del
integer x = 3991
integer y = 4
integer width = 261
integer height = 116
integer taborder = 20
integer textsize = -11
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "退出"
end type

event clicked;close(parent)
end event

type cb_1 from commandbutton within w_saletask_fx_finish_edit_del
integer x = 3717
integer y = 4
integer width = 261
integer height = 116
integer taborder = 10
integer textsize = -11
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "确定"
end type

event clicked;int rslt = 1
Long i

dw_1.accepttext()

string arg_msg = '',arg_msg_tmp
oleobject list,request,response,lo_mx,mxItem
request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("taskid",ins_taskid)
request.SetInt("typeid",1)

lo_mx = FXAppCom.NewPBArray()
FOR i = 1 To dw_1.rowcount()
	mxItem = FXAppCom.CreatePbDictionary()
	mxItem.SetInt('taskid',ins_taskid)
	mxItem.SetInt('printid',dw_1.object.printid[i])
	mxItem.SetString('taskcode',ins_taskcode)
	mxItem.SetDouble('finishqty',dw_1.object.finishqty[i])
	mxItem.SetDateTime('finishtime',dw_1.object.finishtime[i])
	lo_mx.AddObject(mxItem)
NEXT

request.SetObject("FinishmxList", lo_mx)

oleobject lo_rsp
lo_rsp = FXAppCom.DoExecute("SaveSaletaskmxFinishqtymx", request)
arg_msg_tmp = lo_rsp.GetString("ErrMsg")
 If arg_msg_tmp <> "" Then
	arg_msg = arg_msg_tmp
	rslt = 0
	goto ext
 END IF



ext:
IF rslt = 0 THEN
	messagebox("提示","保存失败")
	return
ELSEIF rslt = 1  THEN
	messagebox("提示","保存成功")
END IF

close(parent)

end event

type dw_1 from u_dw_rbtnfilter within w_saletask_fx_finish_edit_del
integer y = 140
integer width = 4270
integer height = 1584
integer taborder = 30
string dataobject = "dw_saletask_fx_finish_edit_del"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event rowfocuschanged;call super::rowfocuschanged;if IsNull(currentrow) then return
if (currentrow <= 0) then return

this.SelectRow(0, false)
this.SelectRow(currentrow, true)




end event

event clicked;call super::clicked;IF row <= 0 then return
this.SelectRow(0, false)
this.SelectRow(row, true)
end event

type ln_bar from line within w_saletask_fx_finish_edit_del
long linecolor = 268435456
integer linethickness = 4
integer beginy = 168
integer endx = 2002
integer endy = 168
end type

type r_bar from rectangle within w_saletask_fx_finish_edit_del
long linecolor = 16777215
integer linethickness = 4
long fillcolor = 1073741824
integer x = 2203
integer y = 40
integer width = 87
integer height = 52
end type

event constructor;THIS.FillColor = 14215660
THIS.LineColor = 14215660
THIS.X = -1
THIS.Y = -1
THIS.Height = ln_bar.BeginY - 5

end event

