$PBExportHeader$w_saletask_fx_finish_edit.srw
forward
global type w_saletask_fx_finish_edit from window
end type
type cb_2 from commandbutton within w_saletask_fx_finish_edit
end type
type cb_1 from commandbutton within w_saletask_fx_finish_edit
end type
type st_1 from statictext within w_saletask_fx_finish_edit
end type
type dw_2 from u_dw_rbtnfilter within w_saletask_fx_finish_edit
end type
type dw_saletaskmx from u_dw_rbtnfilter within w_saletask_fx_finish_edit
end type
type ln_bar from line within w_saletask_fx_finish_edit
end type
type r_bar from rectangle within w_saletask_fx_finish_edit
end type
end forward

global type w_saletask_fx_finish_edit from window
integer width = 3918
integer height = 2400
boolean titlebar = true
string title = "录入完工数"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 134217739
string icon = "AppIcon!"
boolean center = true
cb_2 cb_2
cb_1 cb_1
st_1 st_1
dw_2 dw_2
dw_saletaskmx dw_saletaskmx
ln_bar ln_bar
r_bar r_bar
end type
global w_saletask_fx_finish_edit w_saletask_fx_finish_edit

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)
public function integer wf_remx (long arg_taskid, long arg_printid)
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)
response = FXAppCom.DoExecute("GetSaletaskmx", request)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取订单明细有误:' + arg_msg)
	goto ext
end if
list = response.GetArrOfPBDictionary('mxs')
// 订单明细
dw_saletaskmx.Reset( )
dw_saletaskmx.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_saletaskmx.Object.taskid[i] = item.GetInt('taskid')
	dw_saletaskmx.Object.printid[i] = item.GetInt('printid')
	dw_saletaskmx.Object.mxcode[i] = item.GetString('mxcode')
	dw_saletaskmx.Object.fxmtrlid[i] = item.GetInt('fxmtrlid')
	dw_saletaskmx.Object.mtrlid[i] = item.GetInt('mtrlid')
	dw_saletaskmx.Object.mtrlcode[i] = item.GetString('mtrlcode')
	dw_saletaskmx.Object.mtrlname[i] = item.GetString('mtrlname')
	dw_saletaskmx.Object.mtrlmode[i] = item.GetString('mtrlmode')
	dw_saletaskmx.Object.status[i] = item.GetString('status')
	dw_saletaskmx.Object.woodcode[i] = item.GetString('woodcode')
	dw_saletaskmx.Object.pcode[i] = item.GetString('pcode')
	dw_saletaskmx.Object.qty[i] = item.GetDouble('qty')
	dw_saletaskmx.Object.qty_wait[i] = item.GetDouble('qtyWait')
	dw_saletaskmx.Object.cus_receiveqty[i] = item.GetDouble('cus_receiveqty')
	dw_saletaskmx.Object.price[i] = item.GetDouble('price')
	dw_saletaskmx.Object.mxdscrp[i] = item.GetString('mxdscrp')
	dw_saletaskmx.Object.mxdscrp2[i] = item.GetString('mxdscrp2')
	dw_saletaskmx.Object.mtrlcuscode[i] = item.GetString('mtrlcuscode')
	dw_saletaskmx.Object.plancode[i] = item.GetString('plancode')
	dw_saletaskmx.Object.cus_mtrldef_senddays[i] = item.GetDouble('cus_mtrldef_senddays')
	dw_saletaskmx.SetItem(i, 'earliestsenddate', item.GetDateTime('earliestSendDate'))
	requiredate = item.GetDateTime('requiredate')
	if (not IsNull(requiredate)) then
		dw_saletaskmx.Object.requiredate[i] = requiredate
	end if
	dw_saletaskmx.Object.qty_ready[i] = item.GetDouble('qty_ready')
	dw_saletaskmx.Object.sptflagstr[i] = item.GetString('sptFlagStr')
	dw_saletaskmx.Object.date_confirm_flag[i] = item.GetInt('date_confirm_flag')
     
	dw_saletaskmx.Object.stopQty[i] = item.GetDouble('stopQty')
	dw_saletaskmx.Object.stopEmp[i] = item.GetString('stopEmp')
	IF NOT IsNull(item.GetDateTime('stopDate')) THEN
		dw_saletaskmx.Object.stopDate[i] =  item.GetDateTime('stopDate')
	END IF
	dw_saletaskmx.Object.stopReason[i] = item.GetString('stopReason')
	dw_saletaskmx.Object.gydscrp[i] = item.GetString('gydscrp')
	dw_saletaskmx.Object.order_mtrlname_str[i] = item.GetString('order_mtrlname_str')
	dw_saletaskmx.Object.saletask_mxid[i] = item.GetInt('saletask_mxid')
	dw_saletaskmx.Object.finishqty[i] = item.GetDouble('finishqty')
	dw_saletaskmx.Object.nofinishqty[i] = item.GetDouble('nofinishqty')
next
dw_saletaskmx.AcceptText()
dw_saletaskmx.SetSort('printid')
dw_saletaskmx.Sort()
dw_saletaskmx.SetRedraw(true)


ext:
return rslt


end function

public function integer wf_remx (long arg_taskid, long arg_printid);

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",arg_printid)
response = FXAppCom.DoExecute("GetFxSaletaskmxFinishmx", request)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取订单明细有误:' + arg_msg)
	goto ext
end if

list = response.GetArrOfPBDictionary('finishList')
// 订单明细
dw_2.Reset( )
dw_2.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_2.Object.taskid[i] = item.GetInt('taskid')
	dw_2.Object.printid[i] = item.GetInt('printid')
	dw_2.Object.mxid[i] = item.GetInt('mxid')
	dw_2.Object.taskcode[i] = item.GetString('taskcode')
	dw_2.Object.finishqty[i] = item.GetDouble('finishqty')
	dw_2.Object.finishtime[i] = item.GetDateTime('finishtime')
next
dw_2.AcceptText()
dw_2.SetSort('mxid')
dw_2.Sort()
dw_2.SetRedraw(true)


ext:
return rslt


end function

on w_saletask_fx_finish_edit.create
this.cb_2=create cb_2
this.cb_1=create cb_1
this.st_1=create st_1
this.dw_2=create dw_2
this.dw_saletaskmx=create dw_saletaskmx
this.ln_bar=create ln_bar
this.r_bar=create r_bar
this.Control[]={this.cb_2,&
this.cb_1,&
this.st_1,&
this.dw_2,&
this.dw_saletaskmx,&
this.ln_bar,&
this.r_bar}
end on

on w_saletask_fx_finish_edit.destroy
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.st_1)
destroy(this.dw_2)
destroy(this.dw_saletaskmx)
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)

Long li_printid,li_taskid
IF dw_saletaskmx.rowcount() > 0 then
	
	li_taskid = dw_saletaskmx.object.taskid[1]
	li_printid = dw_saletaskmx.object.printid[1]
	
	wf_remx(li_taskid,li_printid)
		
END IF

end event

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

type cb_2 from commandbutton within w_saletask_fx_finish_edit
integer x = 274
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
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_saletaskmx.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",0)

lo_mx = FXAppCom.NewPBArray()
FOR i = 1 To dw_saletaskmx.rowcount()
	IF dw_saletaskmx.object.ex_finishqty[i] <= 0 THEN CONTINUE
	
	mxItem = FXAppCom.CreatePbDictionary()
	mxItem.SetInt('taskid',ins_taskid)
	mxItem.SetInt('printid',dw_saletaskmx.object.printid[i])
	mxItem.SetString('taskcode',ins_taskcode)
	mxItem.SetDouble('finishqty',dw_saletaskmx.object.ex_finishqty[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("提示","保存失败"+arg_msg)
	return
ELSEIF rslt = 1  THEN
	messagebox("提示","保存成功")
END IF

close(parent)

end event

type st_1 from statictext within w_saletask_fx_finish_edit
integer x = 5
integer y = 1192
integer width = 402
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "完工明细："
boolean focusrectangle = false
end type

type dw_2 from u_dw_rbtnfilter within w_saletask_fx_finish_edit
integer x = 5
integer y = 1264
integer width = 1518
integer height = 1016
integer taborder = 40
string dataobject = "dw_saletask_fx_finishmx_edit"
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

type dw_saletaskmx from u_dw_rbtnfilter within w_saletask_fx_finish_edit
integer y = 148
integer width = 3895
integer height = 1024
integer taborder = 30
string dataobject = "dw_saletask_fx_finish_edit"
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)
this.Setrow(currentrow)



end event

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

Long li_taskid
Long li_printid



li_taskid = This.object.taskid[row]
li_printid = This.object.printid[row]

wf_remx(li_taskid,li_printid)


end event

type ln_bar from line within w_saletask_fx_finish_edit
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
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

