$PBExportHeader$w_buytask_rqdate_rece_fx.srw
$PBExportComments$客户采购订单交期变更单接收界面
forward
global type w_buytask_rqdate_rece_fx from w_publ_base_style
end type
type dw_1 from u_dw_rbtnfilter within w_buytask_rqdate_rece_fx
end type
type cb_ok from uo_imflatbutton within w_buytask_rqdate_rece_fx
end type
type cbx_ch_all from checkbox within w_buytask_rqdate_rece_fx
end type
type st_1 from statictext within w_buytask_rqdate_rece_fx
end type
type st_comname from statictext within w_buytask_rqdate_rece_fx
end type
type cb_retrieve from uo_imflatbutton within w_buytask_rqdate_rece_fx
end type
end forward

global type w_buytask_rqdate_rece_fx from w_publ_base_style
integer width = 4686
integer height = 1812
string title = "采购订单交期变更"
boolean minbox = false
windowtype windowtype = response!
long backcolor = 16777215
boolean center = true
event ue_p_dealflag_t ( )
event ue_p_rqdate_re_t ( )
event ue_p_reason_re_t ( )
dw_1 dw_1
cb_ok cb_ok
cbx_ch_all cbx_ch_all
st_1 st_1
st_comname st_comname
cb_retrieve cb_retrieve
end type
global w_buytask_rqdate_rece_fx w_buytask_rqdate_rece_fx

type variables
s_open_packet s_tran
end variables

forward prototypes
public function integer wf_retrieve ()
public function integer wf_chk (ref string arg_msg)
end prototypes

event ue_p_dealflag_t();// 批设置处理方式
long curRow
curRow = dw_1.GetRow()
if (curRow <= 0) then return

dw_1.AcceptText()
dw_1.SetRedraw(false)
long dealflag, i
dealflag = dw_1.Object.dealflag[curRow]
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.editable[i] <> 1) then continue
	if (dw_1.Object.ch[i] <> 1) then continue
	
	dw_1.Object.dealflag[i] = dealflag
next
dw_1.AcceptText()
dw_1.SetRedraw(true)
end event

event ue_p_rqdate_re_t();// 批设置回复交期
long curRow
curRow = dw_1.GetRow()
if (curRow <= 0) then return

dw_1.AcceptText()
dw_1.SetRedraw(false)
long i
datetime rqdate_re
rqdate_re = dw_1.Object.rqdate_re[curRow]
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.editable[i] <> 1) then continue
	if (dw_1.Object.ch[i] <> 1) then continue
	
	dw_1.Object.rqdate_re[i] = rqdate_re
next
dw_1.AcceptText()
dw_1.SetRedraw(true)
end event

event ue_p_reason_re_t();// 批设置回复原因
long curRow
curRow = dw_1.GetRow()
if (curRow <= 0) then return

dw_1.AcceptText()
dw_1.SetRedraw(false)
long i
string reason_re
reason_re = dw_1.Object.reason_re[curRow]
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.editable[i] <> 1) then continue
	if (dw_1.Object.ch[i] <> 1) then continue
	
	dw_1.Object.reason_re[i] = reason_re
next
dw_1.AcceptText()
dw_1.SetRedraw(true)
end event

public function integer wf_retrieve ();int rslt = 1

dw_1.Reset()

string arg_msg
oleobject obj, parm, list, item
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
//parm.SetString('sendsccode', s_tran.sendsccode)
//parm.SetString('adduser', s_tran.adduser)
parm.SetString('sendcusid', s_tran.sendcusid)
parm.SetInt('receivereltype', s_tran.receivereltype)
parm.SetInt('receiverelid', s_tran.receiverelid)
obj = FXAppCom.GetBuytaskRqdate(parm, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取采购订单交期变更信息有误:' + arg_msg)
	goto ext
end if

//long complete
//complete = obj.GetInt('complete')
//if (complete = 1) then
//	cb_ok.Enabled = false
//end if

long i, row, tmp_dealflag
dw_1.SetRedraw(false)
list = obj.GetPBArray('list')
for i = 1 to list.Count
	row = dw_1.InsertRow(0)
	item = list.GetPBDictionary(i - 1)

//	dw_1.Object.ch[row] = item.GetString('ch')
//	dw_1.Object.ifmatch[row] = item.GetString('ifmatch')
	dw_1.Object.serialnum[row] = item.GetString('serialnum')
	dw_1.Object.AddUser[row] = item.GetString('AddUser')
	dw_1.Object.scid[row] = item.GetInt('scid')
	dw_1.Object.taskid[row] = item.GetInt('taskid')
	dw_1.Object.taskcode[row] = item.GetString('taskcode')
	dw_1.Object.printid[row] = item.GetInt('printid')
	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')
	dw_1.Object.qty[row] = item.GetDouble('qty')
	dw_1.Object.qty_consigned[row] = item.GetDouble('qty_consigned')
	dw_1.Object.unit[row] = item.GetString('unit')
	dw_1.Object.mxdscrp[row] = item.GetString('mxdscrp')
	dw_1.Object.plancode[row] = item.GetString('plancode')
	dw_1.Object.reason[row] = item.GetString('reason')
	dw_1.Object.reason_re[row] = item.GetString('reason_re')
	dw_1.Object.tid[row] = item.GetString('tid')
	dw_1.Object.Summary[row] = item.GetString('Summary')
	dw_1.Object.Postscript[row] = item.GetString('Postscript')
	dw_1.Object.Remark[row] = item.GetString('Remark')
	
	if (not IsNull(item.GetDateTime('rqdate_ori'))) then
		dw_1.Object.rqdate_ori[row] = item.GetDateTime('rqdate_ori')
	end if
	if (not IsNull(item.GetDateTime('rqdate_expect'))) then
		dw_1.Object.rqdate_expect[row] = item.GetDateTime('rqdate_expect')
	end if
	if (not IsNull(item.GetDateTime('rqdate_re'))) then
		dw_1.Object.rqdate_re[row] = item.GetDateTime('rqdate_re')
	else
		if (not IsNull(item.GetDateTime('rqdate_expect'))) then
			dw_1.Object.rqdate_re[row] = item.GetDateTime('rqdate_expect')
		end if
	end if
	if (not IsNull(item.GetDateTime('AddTime'))) then
		dw_1.Object.AddTime[row] = item.GetDateTime('AddTime')
	end if

	tmp_dealflag = item.GetInt('dealflag')
	dw_1.Object.dealflag[row] = tmp_dealflag
	if (tmp_dealflag = 0 or tmp_dealflag = 3) then // 0-未处理 3-暂不处理
		dw_1.Object.editable[row] = 1 // 未处理状态下，可编辑
		dw_1.Object.ch[row] = 1
	else
		dw_1.Object.editable[row] = 0
	end if
	
	if (not IsNull(item.GetInt('myprintid'))) then
		if (item.GetInt('myprintid') > 0) then
			dw_1.Object.ifmatch[row] = 1 // 匹配
		else
			dw_1.Object.ifmatch[row] = 0
			dw_1.Object.dealflag[row] = 2 // 不匹配的拒绝
//			dw_1.Object.editable[row] = 0 // 不匹配状态下，不可编辑
		end if
	else
		dw_1.Object.ifmatch[row] = 0
		dw_1.Object.dealflag[row] = 2 // 不匹配的拒绝
	end if
next
dw_1.AcceptText()
dw_1.SetRedraw(true)

ext:
return rslt
end function

public function integer wf_chk (ref string arg_msg);int rslt = 1

// 检查：匹配项，同意-日期一致
// 检查：不匹配项，不能选择同意
long i, dealflag, ifmatch
datetime rqdate_re, rqdate_expect
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.editable[i] = 0) then continue
	
	dealflag = dw_1.Object.dealflag[i]
	ifmatch = dw_1.Object.ifmatch[i]
	rqdate_re = dw_1.Object.rqdate_re[i]
	rqdate_expect = dw_1.Object.rqdate_expect[i]
	
	if (dealflag = 1) then // 匹配同意项
		if (ifmatch <> 1) then
			rslt = 0
			arg_msg += '第' + string(i) + '行,不匹配项不能选择"同意"的处理方式,默认选择"拒绝";~r~n'
		elseif (IsNull(rqdate_re)) then
			rslt = 0
			arg_msg += '第' + string(i) + '行,回复交期不能为空;~r~n'
		elseif (rqdate_re <> rqdate_expect) then
			rslt = 0
			arg_msg += '第' + string(i) + '行,(匹配同意项)回复交期与期望变更交期不一致;~r~n'
		end if
	end if
next

return rslt
end function

on w_buytask_rqdate_rece_fx.create
int iCurrent
call super::create
this.dw_1=create dw_1
this.cb_ok=create cb_ok
this.cbx_ch_all=create cbx_ch_all
this.st_1=create st_1
this.st_comname=create st_comname
this.cb_retrieve=create cb_retrieve
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.dw_1
this.Control[iCurrent+2]=this.cb_ok
this.Control[iCurrent+3]=this.cbx_ch_all
this.Control[iCurrent+4]=this.st_1
this.Control[iCurrent+5]=this.st_comname
this.Control[iCurrent+6]=this.cb_retrieve
end on

on w_buytask_rqdate_rece_fx.destroy
call super::destroy
destroy(this.dw_1)
destroy(this.cb_ok)
destroy(this.cbx_ch_all)
destroy(this.st_1)
destroy(this.st_comname)
destroy(this.cb_retrieve)
end on

event open;call super::open;s_tran = Message.PowerObjectParm
if IsNUll(s_tran) then
	MessageBox('提示', '打开方式有误')
	Close(this)
	return
end if
if (not IsValid(s_tran)) then
	MessageBox('提示', '打开方式无效')
	Close(this)
	return
end if

string arg_msg
if (f_find_fx_user_power(50, ref arg_msg) <> 1) then // 50-采购订单协商
	MessageBox('权限提示', arg_msg)
	Close(this)
	return
end if

//sle_comname.Text = s_tran.comname
//sle_adduser.Text = s_tran.adduser
//sle_addtime.Text = string(s_tran.addtime, 'yyyy-MM-dd hh:mm:ss')
st_comname.Text = s_tran.comname
//st_adduser.Text = s_tran.adduser

if (wf_retrieve( ) = 0) then
	Close(this)
end if
end event

event resize;call super::resize;dw_1.Width = this.workspacewidth( )
dw_1.Height = this.workspaceheight( ) - dw_1.Y

cb_exit.X = this.workspacewidth( ) - cb_exit.Width
end event

type cb_func from w_publ_base_style`cb_func within w_buytask_rqdate_rece_fx
boolean visible = false
integer x = 640
boolean enabled = false
string normalpicname = "setting.BMP"
integer picsize = 16
end type

type cb_exit from w_publ_base_style`cb_exit within w_buytask_rqdate_rece_fx
integer x = 2130
end type

type ln_bar from w_publ_base_style`ln_bar within w_buytask_rqdate_rece_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_buytask_rqdate_rece_fx
end type

type r_bar from w_publ_base_style`r_bar within w_buytask_rqdate_rece_fx
end type

type dw_1 from u_dw_rbtnfilter within w_buytask_rqdate_rece_fx
integer y = 284
integer width = 4448
integer height = 1284
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_tempbuytask_rqdate"
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 clicked;call super::clicked;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
end if
end event

event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
	this.SelectRow(0, false)
	this.SelectRow(currentrow, true)
	this.SetRow(currentrow)
end if
end event

event doubleclicked;call super::doubleclicked;string dwoname
dwoname = dwo.Name

row = this.GetRow()
if (dwoname = 'dealflag_t' or dwoname = 'rqdate_re_t' or dwoname = 'reason_re_t') then
	if (this.IsSelected(row)) then
		parent.PostEvent('ue_p_' + dwoname)
	else
		MessageBox('提示', '使用批设置功能，请选中一行作为批设置的取值')
	end if
else
	
end if
//if (row > 0) then
//	
//end if
end event

type cb_ok from uo_imflatbutton within w_buytask_rqdate_rece_fx
integer x = 155
integer width = 151
integer height = 164
integer taborder = 20
boolean bringtotop = true
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;dw_1.SetFilter('')
dw_1.Filter()
dw_1.AcceptText()

if (dw_1.RowCount() <= 0) then return

string arg_msg
if (wf_chk(ref arg_msg) <> 1) then
	OpenWithParm(w_message_err, arg_msg)
	return
end if

long findRow, ifSend = 0
string findStr, postscript
findStr = 'editable = 1 and (dealflag = 1 or dealflag = 2)' // 1-同意变更 2-拒绝
findRow = dw_1.Find(findStr, 1, dw_1.RowCount())
if (findRow > 0) then // 存在回复项
	ifSend = 1
	
	findStr = 'editable = 1 and dealflag = 1' // 1-同意变更
	findRow = dw_1.Find(findStr, 1, dw_1.RowCount())
	if (findRow > 0) then
		if (f_find_fx_user_power(51, ref arg_msg) <> 1) then // 51-采购订单交期变更确认
			MessageBox('权限提示', arg_msg)
			return
		end if
	end if
	
	findStr = 'editable = 1 and dealflag = 2' // 2-拒绝
	findRow = dw_1.Find(findStr, 1, dw_1.RowCount())
	if (findRow > 0) then
		if (f_find_fx_user_power(52, ref arg_msg) <> 1) then // 52-采购订单交期变更拒绝
			MessageBox('权限提示', arg_msg)
			return
		end if
	end if
	
	s_open_packet s_ret
	OpenWithParm(w_packet_msg_edit_fx, arg_msg)
	s_ret = Message.PowerObjectParm
	if (s_ret.returnflag = 0) then
		MessageBox('提示', '操作取消')
		return
	end if
	
	postscript = s_ret.postscript
	if IsNull(postscript) then
		postscript = ''
	end if
	if (Len(postscript) > 500) then
		MessageBox('提示', '留言板信息超长(500)，请进行删减')
		return
	end if
end if

long i
oleobject parm, ReqList, item
parm = FXAppCom.CreatePbDictionary()
ReqList = FXAppCom.NewPBArray()
for i = 1 to dw_1.RowCount()
	// 选取变更项：可编辑、1-同意/2-拒绝/3-暂不处理
	if (dw_1.Object.editable[i] = 0) then continue // 不可编辑
	if (dw_1.Object.dealflag[i] = 0) then continue // 0-未处理
	
	item = FXAppCom.CreatePbDictionary()
	item.SetString('serialnumstr', dw_1.Object.SerialNum[i])
	item.SetInt('scid', dw_1.Object.scid[i])
	item.SetInt('taskid', dw_1.Object.taskid[i])
	item.SetString('taskcode', dw_1.Object.taskcode[i])
	item.SetString('tid', dw_1.Object.tid[i])
	item.SetInt('printid', dw_1.Object.printid[i])
	item.SetInt('dealflag', dw_1.Object.dealflag[i])
	item.SetInt('ifmatch', dw_1.Object.ifmatch[i])
	item.SetDateTime('rqdate_re', dw_1.Object.rqdate_re[i])
	item.SetString('reason_re', dw_1.Object.reason_re[i])
	
	ReqList.AddObject(item)
next

parm.SetString('token', app_token_fx)
parm.SetString('sendcusid', s_tran.sendcusid)
parm.SetInt('receivereltype', s_tran.receivereltype)
parm.SetInt('receiverelid', s_tran.receiverelid)
parm.SetString('postscript', postscript)
parm.SetInt('ifsend', ifSend)
parm.SetObject('reqlist', ReqList)
FXAppCom.ReBuytaskRqdate(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '回复交期变更信息失败:' + arg_msg)
else
	MessageBox('提示', '操作成功')
	Close(parent)
end if





end event

type cbx_ch_all from checkbox within w_buytask_rqdate_rece_fx
integer x = 27
integer y = 200
integer width = 206
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 = 16777215
string text = "全选"
end type

event clicked;long ch
if (this.Checked) then
	ch = 1
else
	ch = 0
end if

long i
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.editable[i] = 1) then
		dw_1.Object.ch[i] = ch
	end if
next
end event

type st_1 from statictext within w_buytask_rqdate_rece_fx
integer x = 315
integer y = 204
integer width = 315
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 = 16777215
string text = "发送方企业:"
boolean focusrectangle = false
end type

type st_comname from statictext within w_buytask_rqdate_rece_fx
integer x = 617
integer y = 204
integer width = 795
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 = 16777215
string text = "____"
boolean focusrectangle = false
end type

type cb_retrieve from uo_imflatbutton within w_buytask_rqdate_rece_fx
integer width = 151
integer height = 164
integer taborder = 30
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()
end event

