$PBExportHeader$w_saletaskmx_order.srw
forward
global type w_saletaskmx_order from w_publ_easyq
end type
type ddlb_status from dropdownlistbox within w_saletaskmx_order
end type
type st_1 from statictext within w_saletaskmx_order
end type
type cb_toppage from uo_imflatbutton within w_saletaskmx_order
end type
type cb_page_ch from uo_imflatbutton within w_saletaskmx_order
end type
type em_pagesize from editmask within w_saletaskmx_order
end type
type ddlb_1 from dropdownlistbox within w_saletaskmx_order
end type
type st_2 from statictext within w_saletaskmx_order
end type
type cbx_1 from checkbox within w_saletaskmx_order
end type
type cb_4 from commandbutton within w_saletaskmx_order
end type
type cb_5 from commandbutton within w_saletaskmx_order
end type
type cb_stop from uo_imflatbutton within w_saletaskmx_order
end type
type cb_6 from uo_imflatbutton within w_saletaskmx_order
end type
type cb_7 from uo_imflatbutton within w_saletaskmx_order
end type
end forward

global type w_saletaskmx_order from w_publ_easyq
string title = "采购订单明细汇总表"
event ue_page_next ( )
event ue_page_before ( )
ddlb_status ddlb_status
st_1 st_1
cb_toppage cb_toppage
cb_page_ch cb_page_ch
em_pagesize em_pagesize
ddlb_1 ddlb_1
st_2 st_2
cbx_1 cbx_1
cb_4 cb_4
cb_5 cb_5
cb_stop cb_stop
cb_6 cb_6
cb_7 cb_7
end type
global w_saletaskmx_order w_saletaskmx_order

type variables
long ins_cur_pageNum = 1 // 用于记录当前页码
long ins_totalPages = 1 // 用于记录总页数
int ins_sptflag = -1
int ins_status = -1
end variables

forward prototypes
public function integer wf_retrieve ()
end prototypes

event ue_page_next();ins_cur_pageNum ++
wf_retrieve()
end event

event ue_page_before();if ins_cur_pageNum > 1 THEN 
	ins_cur_pageNum --
	wf_retrieve()
END IF
end event

public function integer wf_retrieve ();int rslt = 1

string arg_msg
oleobject request,response
request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetString("dateBegin",em_1.Text)
request.SetString("dateEnd",em_2.Text)
request.SetInt("status",ins_status)
request.SetInt("sptflag",ins_sptflag)
request.SetInt("pageindex",ins_cur_pageNum)
request.SetInt("pagesize",long(em_pagesize.Text))
response = FXAppCom.DoExecute("GetSaletaskmxOrderList", request)
arg_msg = response.GetString("ErrMsg")

if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

dw_1.Reset()

dw_1.SetRedraw(false)
long i, row
oleobject list, item
any taskdate, moddate, cusmoddate, cusrequiredate_pmc, requiredate, promisedate
list = response.GetArrOfPBDictionary('saletaskmxList')

IF isnull(list) THEN
	RETURN rslt
END IF

for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	row = dw_1.InsertRow(0)

	dw_1.Object.fx_saletask_tid[row] = item.GetString("tid")
//	taskdate = item.GetDateTime('taskdate')
//	if (not IsNull(taskdate)) then
//		dw_1.Object.fx_saletask_taskdate[row] = taskdate
//	end if
//	dw_1.Object.fx_saletask_taskstatus[row] = item.GetInt("taskstatus")
	dw_1.Object.taskid[row] = item.GetInt("taskid")
//	dw_1.Object.printid[row] = item.GetInt("printid")
//	dw_1.Object.fx_saletaskmx_sptflag[row] = item.GetInt("sptflag")
//	dw_1.Object.fx_saletaskmx_cusflag[row] = item.GetInt("cusflag")
//	dw_1.Object.fx_saletaskmx_modemp[row] = item.GetString("modemp")
//	moddate = item.GetDateTime('moddate')
//	IF NOT IsNull(moddate) THEN
//		dw_1.Object.fx_saletaskmx_moddate[row] = moddate
//	END IF
//	dw_1.Object.fx_saletaskmx_modinfo[row] = item.GetString("modinfo")
//	dw_1.Object.fx_saletaskmx_cusmodemp[row] = item.GetString("cusmodemp")
//	cusmoddate = item.GetDateTime('cusmoddate')
//	IF NOT IsNull(cusmoddate) THEN
//		dw_1.Object.fx_saletaskmx_cusmoddate[row] = cusmoddate
//	END IF
//	dw_1.Object.fx_saletaskmx_cusmodinfo[row] = item.GetString("cusmodinfo")
//	dw_1.Object.mxcode[row] = item.GetString("mxcode")
//	dw_1.Object.fxmtrlid[row] = item.GetInt("fxmtrlid")
//	dw_1.Object.mtrlid[row] = item.GetInt("mtrlid")
	dw_1.Object.mtrlcode[row] = item.GetString("mtrlcode")
	dw_1.Object.mtrlname[row] = item.GetString("mtrlname")
	dw_1.Object.mtrlmode[row] = item.GetString("mtrlmode")
//	dw_1.Object.status[row] = item.GetString("status")
//	dw_1.Object.woodcode[row] = item.GetString("woodcode")
//	dw_1.Object.pcode[row] = item.GetString("pcode")
//	cusrequiredate_pmc = item.GetDateTime('cusrequiredate_pmc')
//	IF NOT IsNull(cusrequiredate_pmc) THEN
//		dw_1.Object.fx_saletaskmx_cusrequiredate_pmc[row] = cusrequiredate_pmc
//	END IF
	requiredate = item.GetDateTime('requiredate')
	IF NOT IsNull(requiredate) THEN
		dw_1.Object.requiredate[row] = requiredate
	END IF
//	promisedate = item.GetDateTime('promisedate')
//	IF NOT IsNull(promisedate) THEN
//		dw_1.Object.fx_saletaskmx_promisedate[row] = promisedate
//		dw_1.Object.promisedate_ori[row] = promisedate
//	END IF	
	dw_1.Object.qty[row] = item.GetDouble("qty")
//	dw_1.Object.acceptQty[row] = item.GetDouble("acceptQty")
//	dw_1.Object.qty_wait[row] = item.GetDouble("qty_wait")
	dw_1.Object.qty_todo[row] = item.GetDouble("qty_todo")
//	dw_1.Object.fx_saletaskmx_sptflagstr[row] = item.GetString('sptFlagStr')
//	dw_1.Object.fx_saletaskmx_custflagstr[row] = item.GetString('custFlagStr')
	dw_1.Object.fx_saletask_taskcode[row] = item.GetString('taskcode')
	dw_1.Object.fx_saletaskmx_mtrlcuscode[row] = item.GetString('mtrlcuscode')
	dw_1.Object.date_confirm_flag[row] = item.GetInt("date_confirm_flag")
	
//	dw_1.Object.fx_saletaskmx_stopQty[row] = item.GetDouble('stopQty')
//	dw_1.Object.fx_saletaskmx_stopEmp[row] = item.GetString('stopEmp')
//	IF NOT IsNull(item.GetDateTime('stopDate')) THEN
//		dw_1.Object.fx_saletaskmx_stopDate[row] =  item.GetDateTime('stopDate')
//	END IF
//	dw_1.Object.fx_saletaskmx_stopReason[row] = item.GetString('stopReason')
	dw_1.Object.fx_saletaskmx_gydscrp[row] = item.GetString('gydscrp')
	dw_1.Object.comname[row] = item.GetString('comname')
	dw_1.Object.unit[row] = item.GetString('unit')
	dw_1.Object.fx_saletaskmx_mxdscrp[row] = item.GetString('mxdscrp')
	dw_1.Object.fx_saletaskmx_mxdscrp2[row] = item.GetString('mxdscrp2')
next
dw_1.SetRedraw(true)

ext:
if (rslt = 1) then
	if (dw_1.RowCount() > 0) then
		dw_1.SelectRow(0, false)
		dw_1.SelectRow(1, true)
		dw_1.SetRow(1)
	end if
else
	MessageBox('提示', arg_msg)
end if

return rslt
end function

on w_saletaskmx_order.create
int iCurrent
call super::create
this.ddlb_status=create ddlb_status
this.st_1=create st_1
this.cb_toppage=create cb_toppage
this.cb_page_ch=create cb_page_ch
this.em_pagesize=create em_pagesize
this.ddlb_1=create ddlb_1
this.st_2=create st_2
this.cbx_1=create cbx_1
this.cb_4=create cb_4
this.cb_5=create cb_5
this.cb_stop=create cb_stop
this.cb_6=create cb_6
this.cb_7=create cb_7
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.ddlb_status
this.Control[iCurrent+2]=this.st_1
this.Control[iCurrent+3]=this.cb_toppage
this.Control[iCurrent+4]=this.cb_page_ch
this.Control[iCurrent+5]=this.em_pagesize
this.Control[iCurrent+6]=this.ddlb_1
this.Control[iCurrent+7]=this.st_2
this.Control[iCurrent+8]=this.cbx_1
this.Control[iCurrent+9]=this.cb_4
this.Control[iCurrent+10]=this.cb_5
this.Control[iCurrent+11]=this.cb_stop
this.Control[iCurrent+12]=this.cb_6
this.Control[iCurrent+13]=this.cb_7
end on

on w_saletaskmx_order.destroy
call super::destroy
destroy(this.ddlb_status)
destroy(this.st_1)
destroy(this.cb_toppage)
destroy(this.cb_page_ch)
destroy(this.em_pagesize)
destroy(this.ddlb_1)
destroy(this.st_2)
destroy(this.cbx_1)
destroy(this.cb_4)
destroy(this.cb_5)
destroy(this.cb_stop)
destroy(this.cb_6)
destroy(this.cb_7)
end on

event open;call super::open;em_1.Text =  String(Today(),'YYYY-MM')+'-01'
em_2.Text = String(Today(),'YYYY-MM-DD')
wf_retrieve()
end event

type cb_func from w_publ_easyq`cb_func within w_saletaskmx_order
boolean visible = false
integer x = 146
end type

type cb_exit from w_publ_easyq`cb_exit within w_saletaskmx_order
integer x = 617
end type

type cb_2 from w_publ_easyq`cb_2 within w_saletaskmx_order
boolean visible = false
end type

type cb_psetup from w_publ_easyq`cb_psetup within w_saletaskmx_order
boolean visible = false
end type

type cb_1 from w_publ_easyq`cb_1 within w_saletaskmx_order
end type

event cb_1::clicked;call super::clicked;wf_retrieve()
end event

type st_3 from w_publ_easyq`st_3 within w_saletaskmx_order
integer x = 722
integer height = 72
end type

type st_4 from w_publ_easyq`st_4 within w_saletaskmx_order
integer x = 1431
integer y = 212
end type

type em_1 from w_publ_easyq`em_1 within w_saletaskmx_order
integer x = 923
integer y = 196
end type

event em_1::destructor;call super::destructor;f_SetProfileString (sys_empid,dw_1.DataObject, "em_1", em_1.Text)
end event

type em_2 from w_publ_easyq`em_2 within w_saletaskmx_order
integer x = 1536
integer y = 196
end type

event em_2::modified;call super::modified;f_SetProfileString (sys_empid,dw_1.DataObject, "em_2", em_2.Text)
end event

type ddlb_yl from w_publ_easyq`ddlb_yl within w_saletaskmx_order
boolean visible = false
end type

type cbx_yl from w_publ_easyq`cbx_yl within w_saletaskmx_order
boolean visible = false
end type

type dw_1 from w_publ_easyq`dw_1 within w_saletaskmx_order
integer y = 300
integer height = 1928
string dataobject = "dw_fx_saletaskmx_order"
end type

event dw_1::clicked;call super::clicked;If row > 0 Then
	This.SelectRow(0,False)
	This.SelectRow(row,True)
	This.SetRow(row)
	
	//采购延后待读状态取消 俊20190417
//	string ls_sptflagstr 
//	ls_sptflagstr = dw_1.Object.fx_saletaskmx_sptflagstr[row]
//	
//	IF ls_sptflagstr = '采购延后待读' THEN
//		
//		string arg_msg
//		oleobject request,response, list, item
//		list = FXAppCom.NewPBArray()
//
//		item = FXAppCom.CreatePbDictionary()
//		item.SetString("tid",dw_1.Object.fx_saletask_tid[row])
//		item.SetInt("taskid",dw_1.Object.taskid[row])
//		item.SetInt("printid",dw_1.Object.printid[row])
//		item.SetDateTime("promisedate",dw_1.Object.requiredate[row]);
//		list.AddObject(item)
//		
//		request = FXAppCom.CreatePbDictionary()
//		request.SetString("token",app_token_fx)
//		request.SetInt("changetype",1)
//		request.SetObject("saletaskmxList",list)
//		response = FXAppCom.DoExecute("SaveSaletaskmxDateSpt", request)
//		arg_msg = response.GetString("ErrMsg")
//		
//		IF (arg_msg <> '') THEN
//			MessageBox('提示', '更新协同状态失败，原因：' + arg_msg)
//			RETURN
//		END IF
//		cb_1.post event clicked()
//	END IF
	
End If

end event

type sle_mtrl from w_publ_easyq`sle_mtrl within w_saletaskmx_order
end type

type sle_cust from w_publ_easyq`sle_cust within w_saletaskmx_order
end type

type st_mtrl from w_publ_easyq`st_mtrl within w_saletaskmx_order
end type

type st_cust from w_publ_easyq`st_cust within w_saletaskmx_order
end type

type cbx_loginretr from w_publ_easyq`cbx_loginretr within w_saletaskmx_order
end type

type pb_em1 from w_publ_easyq`pb_em1 within w_saletaskmx_order
integer x = 1339
integer y = 196
end type

type pb_em2 from w_publ_easyq`pb_em2 within w_saletaskmx_order
integer x = 1947
integer y = 196
end type

type pb_2 from w_publ_easyq`pb_2 within w_saletaskmx_order
integer x = 2057
integer y = 196
end type

type cb_help from w_publ_easyq`cb_help within w_saletaskmx_order
boolean visible = false
end type

type cb_copyself from w_publ_easyq`cb_copyself within w_saletaskmx_order
boolean visible = false
end type

type gb_1 from w_publ_easyq`gb_1 within w_saletaskmx_order
end type

type ln_bar from w_publ_easyq`ln_bar within w_saletaskmx_order
end type

type ln_bar2 from w_publ_easyq`ln_bar2 within w_saletaskmx_order
end type

type r_bar from w_publ_easyq`r_bar within w_saletaskmx_order
end type

type ln_1 from w_publ_easyq`ln_1 within w_saletaskmx_order
end type

type ln_2 from w_publ_easyq`ln_2 within w_saletaskmx_order
end type

type ln_3 from w_publ_easyq`ln_3 within w_saletaskmx_order
end type

type ln_4 from w_publ_easyq`ln_4 within w_saletaskmx_order
end type

type ddlb_status from dropdownlistbox within w_saletaskmx_order
integer x = 270
integer y = 196
integer width = 416
integer height = 496
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"全部","待接收[12]","已终止[13]","已拒绝[14]","待回复[15]","在进行[6]","完成[7]"}
borderstyle borderstyle = stylelowered!
end type

event constructor;selectItem(1);
postEvent('SelectionChanged');
end event

event selectionchanged;CHOOSE CASE Index
	CASE 1
		ins_status = -1
	CASE 2
		ins_status = 12
	CASE 3
		ins_status = 13
	CASE 4
		ins_status = 14
	CASE 5
		ins_status =15
	CASE 6
		ins_status = 6
	CASE 7
		ins_status = 7
END CHOOSE

cb_1.PostEvent(Clicked!)

end event

type st_1 from statictext within w_saletaskmx_order
integer x = 23
integer y = 212
integer width = 247
integer height = 48
boolean bringtotop = true
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 cb_toppage from uo_imflatbutton within w_saletaskmx_order
integer x = 1545
integer width = 151
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "首页"
boolean border = false
end type

event clicked;call super::clicked;ins_cur_pageNum = 1
wf_retrieve( )
end event

type cb_page_ch from uo_imflatbutton within w_saletaskmx_order
integer x = 1696
integer width = 82
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "▼"
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;m_Dfc_Control_PopupMenu dmPopupMenu
string menustr

menustr="Text=下页~tEvent=ue_page_next"
menustr = menustr + "|" + "Text=上页~tEvent=ue_page_before"
	
if len(trim(menustr))<>0 then
	dmPopupMenu = Create m_Dfc_Control_PopupMenu
	dmPopupMenu.mf_BuildMenu(This, menustr)
	dmPopupMenu.mf_PopMenu()
	Destroy dmPopupMenu
end if
end event

type em_pagesize from editmask within w_saletaskmx_order
integer x = 1234
integer y = 44
integer width = 306
integer height = 84
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "10000"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "#####0"
boolean spin = true
double increment = 1
string minmax = "1~~"
end type

type ddlb_1 from dropdownlistbox within w_saletaskmx_order
boolean visible = false
integer x = 960
integer y = 196
integer width = 416
integer height = 496
integer taborder = 90
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"全部","无","待回复","待查阅","已回复","已查阅"}
borderstyle borderstyle = stylelowered!
end type

event constructor;selectItem(1);
postEvent('SelectionChanged');
end event

event selectionchanged;CHOOSE CASE Index
	CASE 1
		ins_sptflag = -1
	CASE 2
		ins_sptflag = 0
	CASE 3
		ins_sptflag = 1
	CASE 4
		ins_sptflag = 2
	CASE 5
		ins_sptflag = 3
	CASE 6
		ins_sptflag = 4
	CASE ELSE
		ins_sptflag = -1
END CHOOSE
end event

type st_2 from statictext within w_saletaskmx_order
boolean visible = false
integer x = 713
integer y = 212
integer width = 247
integer height = 48
boolean bringtotop = true
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 cbx_1 from checkbox within w_saletaskmx_order
integer x = 2194
integer y = 212
integer width = 201
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "全选"
boolean lefttext = true
end type

event clicked;IF dw_1.RowCount() <= 0 THEN RETURN
Int ch
IF checked THEN 
	ch = 1
ELSE
	ch = 0
END IF
Long row
FOR row = 1 TO dw_1.RowCount()
	dw_1.Object.ch[row] = ch
NEXT
end event

type cb_4 from commandbutton within w_saletaskmx_order
boolean visible = false
integer x = 718
integer y = 308
integer width = 389
integer height = 84
integer taborder = 130
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "拒绝修改交期"
end type

event clicked;IF dw_1.RowCount() <= 0 THEN RETURN
int rslt = 1

dw_1.AcceptText()
string arg_msg,ls_sptflagstr
oleobject request,response, list, item
list = FXAppCom.NewPBArray()
Long row
DateTime promisedate
FOR row = 1 TO dw_1.RowCount()
	IF dw_1.Object.ch[row] <> 1 THEN CONTINUE
//	IF dw_1.Object.fx_saletaskmx_sptflag[row] <> 1 AND dw_1.Object.fx_saletaskmx_sptflag[row] <> 2 THEN CONTINUE
	
	ls_sptflagstr = Trim(dw_1.Object.fx_saletaskmx_sptflagstr[row]) 
	
	IF ls_sptflagstr <>  '采购提前待回复' AND ls_sptflagstr <> '采购延后待回复' THEN
		arg_msg = "第"+String(row)+"行协同状态为【" + ls_sptflagstr + "】, 不能操作！"
			rslt = 0
		GOTO ext
	END IF

	item = FXAppCom.CreatePbDictionary()
	item.SetString("tid",dw_1.Object.fx_saletask_tid[row])
	item.SetInt("taskid",dw_1.Object.taskid[row])
	item.SetInt("printid",dw_1.Object.printid[row])
	promisedate = dw_1.Object.promisedate_ori[row]
	// 已阅，不修改回复时间
	IF IsNull(promisedate) THEN
		arg_msg = "第"+String(row)+"行原回复时间为空，无法确认"
		rslt = 0
		GOTO ext
	END IF
	item.SetDateTime("promisedate",promisedate);
	list.AddObject(item)
NEXT
IF list.Count = 0 THEN
	arg_msg = "未选中记录"
	rslt = 0
	GOTO ext
END IF
IF MessageBox('询问', '是否拒绝当前要求交期？', Question!, YesNo!, 1) <> 1 THEN RETURN

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("changetype",1)
request.SetObject("saletaskmxList",list)
response = FXAppCom.DoExecute("SaveSaletaskmxDateSpt", request)
arg_msg = response.GetString("ErrMsg")

if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ext:
if (rslt = 1) then
	MessageBox('提示', '修改成功')
	wf_retrieve()
else
	MessageBox('提示', arg_msg)
end if

return rslt
end event

type cb_5 from commandbutton within w_saletaskmx_order
string tag = "IF list.Count = 0 THEN"
boolean visible = false
integer x = 1120
integer y = 308
integer width = 302
integer height = 84
integer taborder = 130
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "变更交期"
end type

event clicked;IF dw_1.RowCount() <= 0 THEN RETURN
int rslt = 1

dw_1.AcceptText()
string arg_msg,ls_sptflagstr
oleobject request,response, list, item
list = FXAppCom.NewPBArray()
Long row
Int ch
DateTime promisedate
FOR row = 1 TO dw_1.RowCount()
	ch = dw_1.Object.ch[row]
	IF dw_1.Object.ch[row] <> 1 THEN CONTINUE
	
	ls_sptflagstr = Trim(dw_1.Object.fx_saletaskmx_sptflagstr[row]) 
	
	IF ls_sptflagstr <>  '同意' AND ls_sptflagstr <>  '采购提前待回复' AND ls_sptflagstr <>  '采购延后待回复' AND &
	   ls_sptflagstr <>  '延后待采购回复' AND ls_sptflagstr <>  '提前待采购回复'   THEN
		arg_msg = "第"+String(row)+"行协同状态为【" + ls_sptflagstr + "】, 不能操作！"
			rslt = 0
		GOTO ext
	END IF
	
	item = FXAppCom.CreatePbDictionary()
	item.SetString("tid",dw_1.Object.fx_saletask_tid[row])
	item.SetInt("taskid",dw_1.Object.taskid[row])
	item.SetInt("printid",dw_1.Object.printid[row])
	promisedate = dw_1.Object.fx_saletaskmx_promisedate[row]
	IF IsNull(promisedate) OR promisedate < DateTime(Date('2000-01-01'),Time("00:00:00")) THEN
		arg_msg = "第"+String(row)+"行回复时间为空，无法确认"
		rslt = 0
		GOTO ext
	END IF
	
	IF promisedate < DateTime(today(),Time("00:00:00")) THEN
		arg_msg = "第"+String(row)+"行回复时间不能早于当前时间，无法确认"
		rslt = 0
		GOTO ext
	END IF
	item.SetDateTime("promisedate",promisedate);
	list.AddObject(item)
NEXT
IF list.Count = 0 THEN
	arg_msg = "未选中记录"
	rslt = 0
	GOTO ext
END IF
IF MessageBox('询问', '是否修改当前勾选的要求交期？', Question!, YesNo!, 1) <> 1 THEN RETURN

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("changetype",1)
request.SetObject("saletaskmxList",list)
response = FXAppCom.DoExecute("SaveSaletaskmxDateSpt", request)
arg_msg = response.GetString("ErrMsg")

if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ext:
if (rslt = 1) then
	MessageBox('提示', '修改成功')
	wf_retrieve()
else
	MessageBox('提示', arg_msg)
end if

return rslt
end event

type cb_stop from uo_imflatbutton within w_saletaskmx_order
boolean visible = false
integer x = 370
integer width = 329
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "批申请终止"
string normalpicname = "delete.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;IF dw_1.RowCount() <= 0 THEN RETURN
int rslt = 1

dw_1.AcceptText()
string arg_msg,ls_sptflagstr
oleobject request,response, list, item
list = FXAppCom.NewPBArray()
Long row
DateTime promisedate
FOR row = 1 TO dw_1.RowCount()
	IF dw_1.Object.ch[row] <> 1 THEN CONTINUE
	
	ls_sptflagstr = Trim(dw_1.Object.fx_saletaskmx_sptflagstr[row]) 
	IF ls_sptflagstr = '同意待采购读' OR ls_sptflagstr = '已发货' THEN
		arg_msg = "订单号："  + string(dw_1.Object.fx_saletask_tid[row]) + "序："  + string(dw_1.Object.printid[row]) + " 协同状态【" + ls_sptflagstr + "】,不能终止"
		rslt = 0
		GOTO ext
	END IF
	
	item = FXAppCom.CreatePbDictionary()
	item.SetString("tid",dw_1.Object.fx_saletask_tid[row])
	item.SetInt("taskid",dw_1.Object.taskid[row])
	item.SetInt("printid",dw_1.Object.printid[row])
	
	IF ls_sptflagstr = '采购撤审待读' THEN
		item.SetString('sptFlagStr',ls_sptflagstr)
	ELSE
		item.SetString('sptFlagStr','终止')
	END IF
	
	
	list.AddObject(item)
NEXT
IF list.Count = 0 THEN
	arg_msg = "未选中明细记录"
	rslt = 0
	GOTO ext
END IF
IF MessageBox('询问', '是否批终止所选订单明细', Question!, YesNo!, 1) <> 1 THEN RETURN

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetObject("Saletaskmxes",list)
response = FXAppCom.DoExecute("UpdateSptFlagStr", request)
arg_msg = response.GetString("ErrMsg")

if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ext:
if (rslt = 1) then
	MessageBox('提示', '批终止成功')
	wf_retrieve()
else
	MessageBox('提示', arg_msg)
end if


end event

type cb_6 from uo_imflatbutton within w_saletaskmx_order
integer x = 338
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "数据发送"
string normalpicname = "excel.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;OpenWithParm(w_sentdataout,DW_1)
end event

type cb_7 from uo_imflatbutton within w_saletaskmx_order
integer x = 151
integer width = 187
integer height = 164
integer taborder = 90
boolean bringtotop = true
string text = "打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row

IF dw_1.RowCount() <= 0 THEN RETURN

datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_print_saletask_fx_mx_data'

long mx_row, i

for i = 1 to dw_1.rowcount()
	IF dw_1.Object.ch[i] = 0 THEN CONTINUE
	
	mx_row = ds_report.InsertRow(0)
	ds_report.Object.fx_company_comname[mx_row] = dw_1.Object.comname[i]
	ds_report.Object.fx_saletask_taskcode[mx_row] = dw_1.Object.fx_saletask_taskcode[i]
	ds_report.Object.cus_mtrlcode[mx_row] = dw_1.Object.mtrlcode[i]
	ds_report.Object.cus_mtrlname[mx_row] = dw_1.Object.mtrlname[i]
	ds_report.Object.cus_mtrlmode[mx_row] = dw_1.Object.mtrlmode[i]
	ds_report.Object.fx_mtrldef_unit[mx_row] = Trim(dw_1.Object.unit[i])	
	ds_report.Object.fx_saletaskmx_qty[mx_row] = dw_1.Object.qty[i]
	ds_report.Object.fx_saletaskmx_requiredate[mx_row] = dw_1.Object.requiredate[i]
     ds_report.Object.fx_saletaskmx_gydscrp[mx_row] = dw_1.Object.fx_saletaskmx_gydscrp[i]
	 IF dw_1.Object.fx_saletaskmx_mtrlcuscode[i] = '' THEN
		ds_report.Object.fx_saletaskmx_mtrlcuscode[mx_row] = dw_1.Object.fx_saletaskmx_mxdscrp[i]
	 ELSE
		ds_report.Object.fx_saletaskmx_mtrlcuscode[mx_row] = dw_1.Object.fx_saletaskmx_mtrlcuscode[i]
	END IF
next

IF ds_report.RowCount() <= 0 THEN
	MessageBox('提示', '请先勾选要打印的单据明细!')
	RETURN
END IF

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_saletask_fx_mx'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='订单明细'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)





end event

