$PBExportHeader$w_spt_price_change_fx.srw
$PBExportComments$(采购)供应商询价单-协同系统
forward
global type w_spt_price_change_fx from w_publ_base_style
end type
type cb_retrieve from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_new from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_edit from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_del from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_audit from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_caudit from uo_imflatbutton within w_spt_price_change_fx
end type
type em_pagesize from editmask within w_spt_price_change_fx
end type
type cb_toppage from uo_imflatbutton within w_spt_price_change_fx
end type
type cb_page_ch from uo_imflatbutton within w_spt_price_change_fx
end type
type st_4 from statictext within w_spt_price_change_fx
end type
type sle_likestr from u_sleedit within w_spt_price_change_fx
end type
type dw_sptprice_change from datawindow within w_spt_price_change_fx
end type
type st_2 from statictext within w_spt_price_change_fx
end type
type em_datea from editmask within w_spt_price_change_fx
end type
type st_3 from statictext within w_spt_price_change_fx
end type
type em_datez from editmask within w_spt_price_change_fx
end type
type dw_sptprice_change_list from u_dw_rbtnfilter within w_spt_price_change_fx
end type
type cb_mx from uo_imflatbutton within w_spt_price_change_fx
end type
type p_ljfieb from picture within w_spt_price_change_fx
end type
type dw_sptprice_changemx from u_dw_rbtnfilter within w_spt_price_change_fx
end type
end forward

global type w_spt_price_change_fx from w_publ_base_style
integer width = 4384
integer height = 2236
string title = "销售报价单"
boolean maxbox = true
boolean resizable = true
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
event ue_addmx ( )
event ue_delmx ( )
event ue_page_next ( )
event ue_page_before ( )
event ue_page_end ( )
event ue_send_ljfieb ( )
cb_retrieve cb_retrieve
cb_new cb_new
cb_edit cb_edit
cb_del cb_del
cb_audit cb_audit
cb_caudit cb_caudit
em_pagesize em_pagesize
cb_toppage cb_toppage
cb_page_ch cb_page_ch
st_4 st_4
sle_likestr sle_likestr
dw_sptprice_change dw_sptprice_change
st_2 st_2
em_datea em_datea
st_3 st_3
em_datez em_datez
dw_sptprice_change_list dw_sptprice_change_list
cb_mx cb_mx
p_ljfieb p_ljfieb
dw_sptprice_changemx dw_sptprice_changemx
end type
global w_spt_price_change_fx w_spt_price_change_fx

type variables
long ins_cur_pageNum = 1 // 用于记录当前页码
long ins_totalPages = 1 // 用于记录总页数

boolean ins_edit_mode = false // 编辑模式

uo_fx_pz uo_pz // 协同配置UO
end variables

forward prototypes
public subroutine wf_retrieve_list ()
public function integer wf_retrieve_mx (readonly long arg_billid)
public subroutine wf_face ()
public subroutine wf_taborder ()
public function integer wf_chk_before_save (ref string arg_msg)
public function integer wf_save ()
public subroutine wf_new ()
public subroutine wf_retrieve_pz ()
end prototypes

event ue_addmx();//
if (not ins_edit_mode) then return

long row
row = dw_sptprice_change.GetRow()
if (row <= 0) then return

long sptcomid
sptcomid = dw_sptprice_change.Object.sptcomid[row]
if (sptcomid <= 0) then
	MessageBox('提示', '请先选择供应商')
	return
end if

s_fx_mtrldef s_tran
OpenWithParm(w_mtrl_ch_by_sptcomid_fx, sptcomid)
s_tran = Message.PowerObjectParm

if not IsValid(s_tran) then return
if IsNull(s_tran) then return
if (not s_tran.ifselect) then return

long i
for i = 1 to UpperBound(s_tran.fxmtrlid)
	row = dw_sptprice_changemx.InsertRow(0)
	
	dw_sptprice_changemx.Object.billid[row] = 0
	dw_sptprice_changemx.Object.printid[row] = 0
	dw_sptprice_changemx.Object.mtrlid[row] = s_tran.fxmtrlid[i]
	dw_sptprice_changemx.Object.mtrlid_erp[row] = s_tran.mtrlid[i]
	dw_sptprice_changemx.Object.price[row] = 0
	dw_sptprice_changemx.Object.dscrp[row] = ''
	dw_sptprice_changemx.Object.enprice[row] = 0
	dw_sptprice_changemx.Object.rebate[row] = 1
	dw_sptprice_changemx.Object.qty_min[row] = 0
	dw_sptprice_changemx.Object.qty_max[row] = 0
	dw_sptprice_changemx.Object.unit[row] = s_tran.unit[i]
	dw_sptprice_changemx.Object.jgdscrp[row] = ''
	dw_sptprice_changemx.Object.status[row] = ''
	dw_sptprice_changemx.Object.woodcode[row] = ''
	dw_sptprice_changemx.Object.pcode[row] = ''
	dw_sptprice_changemx.Object.requiredate[row] = DateTime(RelativeDate(Today(), 1), Time('00:00:00'))
	dw_sptprice_changemx.Object.buydays[row] = 0
//	dw_sptprice_changemx.Object.replydate[row] = s_tran.replydate[i]
	dw_sptprice_changemx.Object.mtrlcode[row] = s_tran.mtrlcode[i]
	dw_sptprice_changemx.Object.mtrlname[row] = s_tran.mtrlname[i]
	dw_sptprice_changemx.Object.mtrlmode[row] = s_tran.mtrlmode[i]
	dw_sptprice_changemx.Object.mtrlsectype[row] = s_tran.mtrlsectype[i]
	dw_sptprice_changemx.Object.zxmtrlmode[row] = s_tran.zxmtrlmode[i]
	dw_sptprice_changemx.Object.usermtrlmode[row] = s_tran.usermtrlmode[i]
	dw_sptprice_changemx.Object.statusflag[row] = s_tran.statusflag[i]
	dw_sptprice_changemx.Object.statustype[row] = s_tran.statustype[i]
	dw_sptprice_changemx.Object.woodcodeflag[row] = s_tran.woodcodeflag[i]
	dw_sptprice_changemx.Object.woodcodetype[row] = s_tran.woodcodetype[i]
	dw_sptprice_changemx.Object.pcodeflag[row] = s_tran.pcodeflag[i]
	dw_sptprice_changemx.Object.pcodetype[row] = s_tran.pcodetype[i]
	dw_sptprice_changemx.Object.configcodetype[row] = s_tran.configcodetype[i]
next




end event

event ue_delmx();//
if (not ins_edit_mode) then return

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

long row
row = dw_sptprice_changemx.GetRow()
if (row <= 0) then return
if (not dw_sptprice_changemx.IsSelected(row)) then return

dw_sptprice_changemx.DeleteRow(row)

if (row > dw_sptprice_changemx.RowCount()) then
	row = dw_sptprice_changemx.RowCount()
end if

dw_sptprice_changemx.SelectRow(0, false)
dw_sptprice_changemx.SelectRow(row, true)
dw_sptprice_changemx.SetRow(row)
end event

event ue_page_next();//
if (ins_cur_pageNum = ins_totalPages) then
	MessageBox('提示', '已经是最后一页')
	return
end if

ins_cur_pageNum ++
wf_retrieve_list( )
end event

event ue_page_before();//
if (ins_cur_pageNum = 1) then
	MessageBox('提示', '已经是第一页')
	return
end if

ins_cur_pageNum --
wf_retrieve_list( )
end event

event ue_page_end();//
if (ins_cur_pageNum = ins_totalPages) then return

ins_cur_pageNum = ins_totalPages
wf_retrieve_list( )
end event

event ue_send_ljfieb();long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

long flag
flag = dw_sptprice_change_list.Object.flag[row]
if (flag > 0) then
	MessageBox('提示', '该询价单已经审核,无法发送')
	return
end if

string arg_msg
OpenWithParm(w_packet_msg_edit_fx, arg_msg)
s_open_packet s_ret
s_ret = Message.PowerObjectParm
if (s_ret.returnflag = 0) then
	MessageBox('提示', '操作取消')
	return
end if

string postscript
postscript = s_ret.postscript
if IsNull(postscript) then
	postscript = ''
end if
if (Len(postscript) > 500) then
	MessageBox('提示', '留言板信息超长(500)，请进行删减')
	return
end if

long billid
billid = dw_sptprice_change_list.Object.billid[row]

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('billid', billid)
parm.SetString('postscript', postscript)
FXAppCom.SendSptPrice(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '发送失败:' + arg_msg)
	return
end if

MessageBox('提示', '成功添加至发送队列')


end event

public subroutine wf_retrieve_list ();// 获取询价单列表

if (ins_edit_mode) then return

int rslt = 1

string arg_msg
long pageSize
pageSize = Integer(em_pagesize.Text)
if (pageSize <= 0) then
	rslt = 0
	arg_msg = '每页显示行数必须大于0'
	em_pagesize.SetFocus( )
	em_pagesize.SelectText(1, Len(em_pagesize.Text))
	goto ext
end if

long pageNum
pageNum = ins_cur_pageNum

datetime dateA, dateZ
dateA = DateTime(Date(em_dateA.Text), Time(0))
dateZ = DateTime(Date(em_dateZ.Text), Time('23:59:59'))

string likeStr
likeStr = Trim(sle_likestr.Text)

oleobject obj
obj = FXAppCom.GetSptPriceChange(app_token_fx, pageSize, pageNum, 2, string(dateA), string(dateZ), likestr, ref arg_msg)

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

dw_sptprice_change.Reset()
dw_sptprice_change_list.Reset()
dw_sptprice_changemx.Reset()

dw_sptprice_change_list.SetRedraw(false)
long i, row
ins_totalPages = obj.GetInt('totalPages')
oleobject list, item
list = obj.GetArrOfPBDictionary('sptpricechanges')
for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	dw_sptprice_change_list.Object.billid[i] = item.GetInt('billid')
	dw_sptprice_change_list.Object.billcode[i] = item.GetString('billcode')
	if not IsNull(item.GetDateTime('billdate')) then
		dw_sptprice_change_list.Object.billdate[i] = item.GetDateTime('billdate')
	end if
	dw_sptprice_change_list.Object.cuscomid[i] = item.GetInt('cuscomid')
	dw_sptprice_change_list.Object.sptcomid[i] = item.GetInt('sptcomid')
	dw_sptprice_change_list.Object.dscrp[i] = item.GetString('dscrp')
	dw_sptprice_change_list.Object.flag[i] = item.GetInt('flag')
	dw_sptprice_change_list.Object.auditemp[i] = item.GetString('auditemp')
	// 1899-12-30 00:00:00
	if not IsNull(item.GetDateTime('auditdate')) then
		dw_sptprice_change_list.Object.auditdate[i] = item.GetDateTime('auditdate')
	end if
	if not IsNull(item.GetDateTime('opdate')) then
		dw_sptprice_change_list.Object.opdate[i] = item.GetDateTime('opdate')
	end if
	dw_sptprice_change_list.Object.opemp[i] = item.GetString('opemp')
	if not IsNull(item.GetDateTime('moddate')) then
		dw_sptprice_change_list.Object.moddate[i] = item.GetDateTime('moddate')
	end if
	dw_sptprice_change_list.Object.modemp[i] = item.GetString('modemp')
	dw_sptprice_change_list.Object.inrep[i] = item.GetString('inrep')
	dw_sptprice_change_list.Object.billtype[i] = item.GetInt('billtype')
	dw_sptprice_change_list.Object.senduser[i] = item.GetString('senduser')
	if not IsNull(item.GetDateTime('sendtime')) then
		dw_sptprice_change_list.Object.sendtime[i] = item.GetDateTime('sendtime')
	end if
	dw_sptprice_change_list.Object.sendcnt[i] = item.GetInt('sendcnt')
	dw_sptprice_change_list.Object.sptname[i] = item.GetString('sptname')
next
dw_sptprice_change_list.SetRedraw(true)

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

end subroutine

public function integer wf_retrieve_mx (readonly long arg_billid);int rslt = 1

if (ins_edit_mode) then return 0

if IsNull(arg_billid) then return 0

dw_sptprice_changemx.Reset()

string arg_msg = ''
oleobject list, item
list = FXAppCom.GetSptPriceChangemx(app_token_fx, arg_billid, ref arg_msg)

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

dw_sptprice_changemx.SetRedraw(false)
long i
for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	dw_sptprice_changemx.Object.billid[i] = item.GetInt('billid')
	dw_sptprice_changemx.Object.printid[i] = item.GetInt('printid')
	dw_sptprice_changemx.Object.mtrlid[i] = item.GetInt('mtrlid')
	dw_sptprice_changemx.Object.mtrlid_erp[i] = item.GetInt('mtrlid_erp')
	dw_sptprice_changemx.Object.price[i] = item.GetDouble('price')
	dw_sptprice_changemx.Object.dscrp[i] = item.GetString('dscrp')
	dw_sptprice_changemx.Object.enprice[i] = item.GetDouble('enprice')
	dw_sptprice_changemx.Object.rebate[i] = item.GetDouble('rebate')
	dw_sptprice_changemx.Object.qty_min[i] = item.GetDouble('qty_min')
	dw_sptprice_changemx.Object.qty_max[i] = item.GetDouble('qty_max')
	dw_sptprice_changemx.Object.unit[i] = item.GetString('unit')
	dw_sptprice_changemx.Object.jgdscrp[i] = item.GetString('jgdscrp')
	dw_sptprice_changemx.Object.status[i] = item.GetString('status')
	dw_sptprice_changemx.Object.woodcode[i] = item.GetString('woodcode')
	dw_sptprice_changemx.Object.pcode[i] = item.GetString('pcode')
	if not IsNull(item.GetDateTime('requiredate')) then
		dw_sptprice_changemx.Object.requiredate[i] = item.GetDateTime('requiredate')
	end if
	if not IsNull(item.GetDateTime('replydate')) then
		dw_sptprice_changemx.Object.replydate[i] = item.GetDateTime('replydate')
	end if
	dw_sptprice_changemx.Object.mtrlcode[i] = item.GetString('mtrlcode')
	dw_sptprice_changemx.Object.mtrlname[i] = item.GetString('mtrlname')
	dw_sptprice_changemx.Object.mtrlmode[i] = item.GetString('mtrlmode')
	dw_sptprice_changemx.Object.mtrlsectype[i] = item.GetString('mtrlsectype')
	dw_sptprice_changemx.Object.zxmtrlmode[i] = item.GetString('zxmtrlmode')
	dw_sptprice_changemx.Object.usermtrlmode[i] = item.GetString('usermtrlmode')
	dw_sptprice_changemx.Object.statusflag[i] = item.GetInt('statusflag')
	dw_sptprice_changemx.Object.statustype[i] = item.GetInt('statustype')
	dw_sptprice_changemx.Object.woodcodeflag[i] = item.GetInt('woodcodeflag')
	dw_sptprice_changemx.Object.woodcodetype[i] = item.GetInt('woodcodetype')
	dw_sptprice_changemx.Object.pcodeflag[i] = item.GetInt('pcodeflag')
	dw_sptprice_changemx.Object.pcodetype[i] = item.GetInt('pcodetype')
	dw_sptprice_changemx.Object.configcodetype[i] = item.GetInt('configcodetype')
	dw_sptprice_changemx.Object.buydays[i] = item.GetDouble('buydays')
next
dw_sptprice_changemx.SetRedraw(true)

ext:
if (rslt = 0) then
	MessageBox('提示', arg_msg)
end if
return rslt


end function

public subroutine wf_face ();string arg_msg
if (ins_edit_mode) then // 编辑状态
	cb_retrieve.Enabled = false
	cb_del.Enabled = false
	cb_audit.Enabled = false
	cb_caudit.Enabled = false
	cb_mx.Enabled = true
	cb_exit.Enabled = false
	em_pagesize.Enabled = false
	cb_toppage.Enabled = false
	cb_page_ch.Enabled = false
	em_datea.Enabled = false
	em_datez.Enabled = false
	sle_likestr.Enabled = false
	
	cb_new.Text = "保存"
	cb_new.normalpicname = "Save.bmp"
	
	cb_edit.Text = "放弃"
	cb_edit.normalpicname = "Undo.bmp"
else
	cb_retrieve.Enabled = true
	if (f_find_fx_user_power(43, ref arg_msg) = 1) then // 43-供应商询价单删除
		cb_del.Enabled = true
	end if
	if (f_find_fx_user_power(44, ref arg_msg) = 1) then // 44-供应商询价单审核
		cb_audit.Enabled = true
	end if
	if (f_find_fx_user_power(45, ref arg_msg) = 1) then // 45-供应商询价单撤审
		cb_caudit.Enabled = true
	end if
	cb_mx.Enabled = false
	cb_exit.Enabled = true
	em_pagesize.Enabled = true
	cb_toppage.Enabled = true
	cb_page_ch.Enabled = true
	em_datea.Enabled = true
	em_datez.Enabled = true
	sle_likestr.Enabled = true
	
	cb_new.Text = "新建"
	cb_new.normalpicname = "new.bmp"
	
	cb_edit.Text = "修改"
	cb_edit.normalpicname = "open.bmp"
end if

cb_new.of_init_draw()
cb_edit.of_init_draw()

cb_new.of_paint()
cb_edit.of_paint()

cb_new.TriggerEvent('ue_textchange')
cb_edit.TriggerEvent('ue_textchange')
end subroutine

public subroutine wf_taborder ();//
if (ins_edit_mode) then
	dw_sptprice_change.SetTabOrder('inrep', 10)
	dw_sptprice_change.SetTabOrder('dscrp', 20)
	
	dw_sptprice_changemx.SetTabOrder('enprice', 10)
	dw_sptprice_changemx.SetTabOrder('rebate', 20)
	dw_sptprice_changemx.SetTabOrder('unit', 30)
	dw_sptprice_changemx.SetTabOrder('qty_min', 40)
	dw_sptprice_changemx.SetTabOrder('qty_max', 50)
	dw_sptprice_changemx.SetTabOrder('jgdscrp', 60)
	dw_sptprice_changemx.SetTabOrder('status', 70)
	dw_sptprice_changemx.SetTabOrder('woodcode', 80)
	dw_sptprice_changemx.SetTabOrder('pcode', 90)
	dw_sptprice_changemx.SetTabOrder('dscrp', 100)
	dw_sptprice_changemx.SetTabOrder('buydays', 110)
	dw_sptprice_changemx.SetTabOrder('requiredate', 120)
else
	dw_sptprice_change.SetTabOrder('inrep', 0)
	dw_sptprice_change.SetTabOrder('dscrp', 0)
	
	dw_sptprice_changemx.SetTabOrder('enprice', 0)
	dw_sptprice_changemx.SetTabOrder('rebate', 0)
	dw_sptprice_changemx.SetTabOrder('unit', 0)
	dw_sptprice_changemx.SetTabOrder('qty_min', 0)
	dw_sptprice_changemx.SetTabOrder('qty_max', 0)
	dw_sptprice_changemx.SetTabOrder('jgdscrp', 0)
	dw_sptprice_changemx.SetTabOrder('status', 0)
	dw_sptprice_changemx.SetTabOrder('woodcode', 0)
	dw_sptprice_changemx.SetTabOrder('pcode', 0)
	dw_sptprice_changemx.SetTabOrder('dscrp', 0)
	dw_sptprice_changemx.SetTabOrder('buydays', 0)
	dw_sptprice_changemx.SetTabOrder('requiredate', 0)
end if
end subroutine

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

dw_sptprice_change.AcceptText()
dw_sptprice_changemx.AcceptText()

string msg_sum, temp

long row
row = dw_sptprice_change.GetRow()

if Trim(dw_sptprice_change.Object.inrep[row]) = '' then
	rslt = 0
	msg_sum += '请填写经手人~r~n'
end if

long sptcomid
sptcomid = dw_sptprice_change.Object.sptcomid[row]
if (sptcomid <= 0) then
	rslt = 0
	msg_sum += '请选择供应商~r~n'
end if

long i, j

long mtrlid_i
decimal qty_min_i, qty_max_i
string jgdscrp_i, status_i, woodcode_i, pcode_i

long mtrlid_j
decimal qty_min_j, qty_max_j
string jgdscrp_j, status_j, woodcode_j, pcode_j

if (dw_sptprice_changemx.RowCount() <= 0) then
	rslt = 0
	msg_sum += '没有明细内容~r~n'
else
	for i = 1 to dw_sptprice_changemx.RowCount()
		temp = ''
		
		if (Trim(dw_sptprice_changemx.Object.unit[i]) = '') then
			rslt = 0
			temp += '单位有误;'
		end if
		
		// ...
		
		if (temp <> '') then
			msg_sum += '第' + string(i) + '行明细:' + temp + '~r~n'
		end if
	next
	
	// 去重检查
	for i = 1 to dw_sptprice_changemx.RowCount() - 1
		mtrlid_i = dw_sptprice_changemx.Object.mtrlid[i]
		qty_min_i = dw_sptprice_changemx.Object.qty_min[i]
		qty_max_i = dw_sptprice_changemx.Object.qty_max[i]
		jgdscrp_i = dw_sptprice_changemx.Object.jgdscrp[i]
		status_i = dw_sptprice_changemx.Object.status[i]
		woodcode_i = dw_sptprice_changemx.Object.woodcode[i]
		pcode_i = dw_sptprice_changemx.Object.pcode[i]
		
		for j = i + 1 to dw_sptprice_changemx.RowCount()
			mtrlid_j = dw_sptprice_changemx.Object.mtrlid[j]
			qty_min_j = dw_sptprice_changemx.Object.qty_min[j]
			qty_max_j = dw_sptprice_changemx.Object.qty_max[j]
			jgdscrp_j = dw_sptprice_changemx.Object.jgdscrp[j]
			status_j = dw_sptprice_changemx.Object.status[j]
			woodcode_j = dw_sptprice_changemx.Object.woodcode[j]
			pcode_j = dw_sptprice_changemx.Object.pcode[j]
			
			if (mtrlid_i = mtrlid_j &
					and qty_min_i = qty_min_j &
					and qty_max_i = qty_max_j &
					and jgdscrp_i = jgdscrp_j &
					and status_i = status_j &
					and woodcode_i = woodcode_j &
					and pcode_i = pcode_j) then
				msg_sum += '第' + string(i) + '行与第' + string(j) + '行出现重复明细(物料,数量,配置)~r~n'
				rslt = 0
			end if
		next
	next
end if

arg_msg = msg_sum

return rslt



end function

public function integer wf_save ();int rslt = 1

dw_sptprice_changemx.SetFilter('')
dw_sptprice_changemx.Filter()

string arg_msg
if (wf_chk_before_save(ref arg_msg) <> 1) then
	rslt = 0
	OpenWithParm(w_message_err, arg_msg)
	goto ext
end if

long row
row = dw_sptprice_change.GetRow()
if (row <= 0) then
	rslt = 0
	MessageBox('提示', '获取主表信息失败')
	goto ext
end if

oleobject sptprice, sptpriceMxs, item

// 主表
sptprice = FXAppCom.CreatePbDictionary()
sptprice.SetInt('billid', dw_sptprice_change.Object.billid[row])
//sptprice.SetString('billcode', Trim(dw_sptprice_change.Object.billcode[row]))
//sptprice.SetDateTime('billdate', dw_sptprice_change.Object.billdate[row])
sptprice.SetInt('cuscomid', dw_sptprice_change.Object.cuscomid[row])
sptprice.SetInt('sptcomid', dw_sptprice_change.Object.sptcomid[row])
sptprice.SetString('dscrp', Trim(dw_sptprice_change.Object.dscrp[row]))
//sptprice.SetInt('flag', dw_sptprice_change.Object.flag[row])
//sptprice.SetString('auditemp', Trim(dw_sptprice_change.Object.auditemp[row]))
//sptprice.SetDateTime('auditdate', dw_sptprice_change.Object.auditdate[row])
//sptprice.SetDateTime('opdate', dw_sptprice_change.Object.opdate[row])
//sptprice.SetString('opemp', Trim(dw_sptprice_change.Object.opemp[row]))
//sptprice.SetDateTime('moddate', dw_sptprice_change.Object.moddate[row])
//sptprice.SetString('modemp', Trim(dw_sptprice_change.Object.modemp[row]))
sptprice.SetString('inrep', Trim(dw_sptprice_change.Object.inrep[row]))
sptprice.SetInt('billtype', 2) // [2]询价单
//sptprice.SetString('senduser', Trim(dw_sptprice_change.Object.senduser[row]))
//sptprice.SetDateTime('sendtime', dw_sptprice_change.Object.sendtime[row])
//sptprice.SetInt('sendcnt', dw_sptprice_change.Object.sendcnt[row])

// 明细表
sptpriceMxs = FXAppCom.CreArrOfPbDictionary()
long i
decimal price, enprice, rebate
for i = 1 to dw_sptprice_changemx.RowCount()
	item = FXAppCom.CreatePbDictionary()
	
//	item.SetInt('billid', dw_sptprice_changemx.Object.billid[i])
	item.SetInt('printid', i)
	item.SetInt('mtrlid', dw_sptprice_changemx.Object.mtrlid[i])
	item.SetInt('mtrlid_erp', dw_sptprice_changemx.Object.mtrlid_erp[i])
	item.SetDouble('price', dw_sptprice_changemx.Object.price[i]) // null
	item.SetString('dscrp', dw_sptprice_changemx.Object.dscrp[i])
	item.SetDouble('enprice', dw_sptprice_changemx.Object.enprice[i])
	item.SetDouble('rebate', dw_sptprice_changemx.Object.rebate[i])
	item.SetDouble('qty_min', dw_sptprice_changemx.Object.qty_min[i])
	item.SetDouble('qty_max', dw_sptprice_changemx.Object.qty_max[i])
	item.SetString('unit', dw_sptprice_changemx.Object.unit[i])
	item.SetString('jgdscrp', dw_sptprice_changemx.Object.jgdscrp[i])
	item.SetString('status', dw_sptprice_changemx.Object.status[i])
	item.SetString('woodcode', dw_sptprice_changemx.Object.woodcode[i])
	item.SetString('pcode', dw_sptprice_changemx.Object.pcode[i])
	item.SetDateTime('requiredate', dw_sptprice_changemx.Object.requiredate[i])
	item.SetDateTime('replydate', dw_sptprice_changemx.Object.replydate[i]) // null
	item.SetDouble('buydays', dw_sptprice_changemx.Object.buydays[i])
	
	sptpriceMxs.Add(item)
next

FxAppCom.AddSptPriceChange(app_token_fx, sptprice, sptpriceMxs, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '保存失败:' + arg_msg)
else
	MessageBox('提示', '保存成功')
end if

ext:
return rslt




end function

public subroutine wf_new ();long row
row = dw_sptprice_change_list.InsertRow(1)
dw_sptprice_change_list.SelectRow(0, false)
dw_sptprice_change_list.SelectRow(row, true)
dw_sptprice_change_list.SetRow(row)
	
dw_sptprice_change.Reset()
row = dw_sptprice_change.InsertRow(0)
dw_sptprice_change.Object.billid[row] = 0
dw_sptprice_change.Object.billdate[row] = Today()
dw_sptprice_change.Object.cuscomid[row] = 0
dw_sptprice_change.Object.sptcomid[row] = 0
dw_sptprice_change.Object.dscrp[row] = ''
dw_sptprice_change.Object.inrep[row] = ''
dw_sptprice_change.Object.opemp[row] = app_username

dw_sptprice_changemx.Reset()

cb_edit.Enabled = true
end subroutine

public subroutine wf_retrieve_pz ();// 修改状态下使用(新建单据的情况已有相应的获取配置步骤)

if (not ins_edit_mode) then return

long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

string arg_msg
boolean ifNeedInit = false
long sptcomid
sptcomid = dw_sptprice_change_list.Object.sptcomid[row]
if (not IsNull(uo_pz.ins_comid)) then
	if (uo_pz.ins_comid <> sptcomid) then
		ifNeedInit = true
	else
		if (not uo_pz.ins_isReady) then
			uo_pz.uof_get_ready(ref arg_msg)
			if (arg_msg <> '') then
				MessageBox('提示', '获取配置失败:' + arg_msg)
				return
			end if
		end if
	end if
else
	ifNeedInit = true
end if

if (ifNeedInit) then
	uo_pz.init()
	uo_pz.ins_comid = sptcomid
	if (uo_pz.uof_before_ready(ref arg_msg) <> 1) then
		MessageBox('提示', arg_msg)
	end if
end if
end subroutine

on w_spt_price_change_fx.create
int iCurrent
call super::create
this.cb_retrieve=create cb_retrieve
this.cb_new=create cb_new
this.cb_edit=create cb_edit
this.cb_del=create cb_del
this.cb_audit=create cb_audit
this.cb_caudit=create cb_caudit
this.em_pagesize=create em_pagesize
this.cb_toppage=create cb_toppage
this.cb_page_ch=create cb_page_ch
this.st_4=create st_4
this.sle_likestr=create sle_likestr
this.dw_sptprice_change=create dw_sptprice_change
this.st_2=create st_2
this.em_datea=create em_datea
this.st_3=create st_3
this.em_datez=create em_datez
this.dw_sptprice_change_list=create dw_sptprice_change_list
this.cb_mx=create cb_mx
this.p_ljfieb=create p_ljfieb
this.dw_sptprice_changemx=create dw_sptprice_changemx
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_retrieve
this.Control[iCurrent+2]=this.cb_new
this.Control[iCurrent+3]=this.cb_edit
this.Control[iCurrent+4]=this.cb_del
this.Control[iCurrent+5]=this.cb_audit
this.Control[iCurrent+6]=this.cb_caudit
this.Control[iCurrent+7]=this.em_pagesize
this.Control[iCurrent+8]=this.cb_toppage
this.Control[iCurrent+9]=this.cb_page_ch
this.Control[iCurrent+10]=this.st_4
this.Control[iCurrent+11]=this.sle_likestr
this.Control[iCurrent+12]=this.dw_sptprice_change
this.Control[iCurrent+13]=this.st_2
this.Control[iCurrent+14]=this.em_datea
this.Control[iCurrent+15]=this.st_3
this.Control[iCurrent+16]=this.em_datez
this.Control[iCurrent+17]=this.dw_sptprice_change_list
this.Control[iCurrent+18]=this.cb_mx
this.Control[iCurrent+19]=this.p_ljfieb
this.Control[iCurrent+20]=this.dw_sptprice_changemx
end on

on w_spt_price_change_fx.destroy
call super::destroy
destroy(this.cb_retrieve)
destroy(this.cb_new)
destroy(this.cb_edit)
destroy(this.cb_del)
destroy(this.cb_audit)
destroy(this.cb_caudit)
destroy(this.em_pagesize)
destroy(this.cb_toppage)
destroy(this.cb_page_ch)
destroy(this.st_4)
destroy(this.sle_likestr)
destroy(this.dw_sptprice_change)
destroy(this.st_2)
destroy(this.em_datea)
destroy(this.st_3)
destroy(this.em_datez)
destroy(this.dw_sptprice_change_list)
destroy(this.cb_mx)
destroy(this.p_ljfieb)
destroy(this.dw_sptprice_changemx)
end on

event open;call super::open;string arg_msg // 39-供应商询价单查看 40-供应商询价单查看(含单价)
if (f_find_fx_user_power(39, ref arg_msg) <> 1 &
		and f_find_fx_user_power(40, ref arg_msg) <> 1) then
	MessageBox('权限提示', arg_msg)
	Close(this)
	return
end if

em_datea.Text = String(RelativeDate(Today(), - 30))
em_datez.Text = String(Today())

uo_pz = create uo_fx_pz

wf_retrieve_list( )
wf_face()

if (f_find_fx_user_power(43, ref arg_msg) <> 1) then // 43-供应商询价单删除
	cb_del.Enabled = false
end if
if (f_find_fx_user_power(44, ref arg_msg) <> 1) then // 44-供应商询价单审核
	cb_audit.Enabled = false
end if
if (f_find_fx_user_power(45, ref arg_msg) <> 1) then // 45-供应商询价单撤审
	cb_caudit.Enabled = false
end if

if (f_find_fx_user_power(40, ref arg_msg) <> 1) then // 40-供应商询价单查看(含单价)
	dw_sptprice_changemx.Modify('destroy enprice_t ~r~n destroy enprice ~r~n')
	dw_sptprice_changemx.Modify('destroy rebate_t ~r~n destroy rebate ~r~n')
	dw_sptprice_changemx.Modify('destroy compute_1_t ~r~n destroy compute_1 ~r~n')
	dw_sptprice_changemx.Modify('destroy price_t ~r~n destroy price ~r~n')
end if
end event

event close;call super::close;destroy uo_pz
end event

event resize;call super::resize;if (this.Width < 4300) then this.Width = 4300
if (this.Height < 2100) then this.Height = 2100

dw_sptprice_change_list.Width = this.workspacewidth( ) - dw_sptprice_change_list.X

dw_sptprice_changemx.Width = this.workspacewidth( )
dw_sptprice_changemx.Height = this.workspaceheight( ) - dw_sptprice_changemx.Y

p_ljfieb.X = this.workspacewidth( ) - p_ljfieb.Width - 20

// 按钮靠右
cb_exit.X = this.workspacewidth( ) - cb_exit.Width
cb_page_ch.X = cb_exit.X - cb_page_ch.Width - 5
cb_toppage.X = cb_page_ch.X - cb_toppage.Width - 5
em_pagesize.X = cb_toppage.X - em_pagesize.Width - 5
end event

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

type cb_exit from w_publ_base_style`cb_exit within w_spt_price_change_fx
integer x = 3557
end type

type ln_bar from w_publ_base_style`ln_bar within w_spt_price_change_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_spt_price_change_fx
end type

type r_bar from w_publ_base_style`r_bar within w_spt_price_change_fx
end type

type cb_retrieve from uo_imflatbutton within w_spt_price_change_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_list( )
end event

type cb_new from uo_imflatbutton within w_spt_price_change_fx
integer x = 155
integer width = 151
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "新建"
string normalpicname = "new.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;boolean ifSaveAndPass = false

if (not ins_edit_mode) then // 进入新建操作
	string arg_msg
	if (f_find_fx_user_power(41, ref arg_msg) <> 1) then // 41-供应商询价单新建
		MessageBox('权限提示', arg_msg)
		return
	end if
	wf_new()
else // 保存操作
	if (wf_save() <> 1) then return
	ifSaveAndPass = true
end if

ins_edit_mode = not ins_edit_mode
wf_face()
wf_taborder()

if (ifSaveAndPass) then
	wf_retrieve_list( )
end if
end event

type cb_edit from uo_imflatbutton within w_spt_price_change_fx
integer x = 311
integer width = 151
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "修改"
string normalpicname = "open.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

ins_edit_mode = not ins_edit_mode

long billid
if (ins_edit_mode) then // 修改
	string arg_msg
	if (f_find_fx_user_power(42, ref arg_msg) <> 1) then // 42-供应商询价单修改
		MessageBox('权限提示', arg_msg)
		ins_edit_mode = not ins_edit_mode
		return
	end if
	wf_face()
	wf_taborder()
	wf_retrieve_pz()
else // 放弃
	row = dw_sptprice_change_list.GetRow()
	billid = dw_sptprice_change_list.Object.billid[row]
	if (billid > 0) then
		dw_sptprice_change_list.post event RowFocusChanged(row)
	else
		dw_sptprice_change_list.DeleteRow(row)
		wf_retrieve_list( )
	end if
	
	wf_face()
	wf_taborder()
end if
end event

type cb_del from uo_imflatbutton within w_spt_price_change_fx
integer x = 466
integer width = 151
integer height = 164
integer taborder = 20
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 (ins_edit_mode) then return

string arg_msg
if (f_find_fx_user_power(43, ref arg_msg) <> 1) then // 43-供应商询价单删除
	MessageBox('权限提示', arg_msg)
	return
end if

long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

long billid, flag, sendcnt
flag = dw_sptprice_change_list.Object.flag[row]
if (flag > 0) then
	MessageBox('提示', '该单据已经审核,无法删除')
	return
end if

sendcnt = dw_sptprice_change_list.Object.sendcnt[row]
if (sendcnt > 0) then
	if (MessageBox('提示', '该单据发送次数不为零,确认删除?', Question!, YesNoCancel!) <> 1) then return
end if

billid = dw_sptprice_change_list.Object.billid[row]
if (billid <= 0) then return

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('billid', billid)
FXAppCom.DelSptPriceChange(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

MessageBox('提示', '删除成功')
wf_retrieve_list( )
end event

type cb_audit from uo_imflatbutton within w_spt_price_change_fx
integer x = 622
integer width = 151
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "审核"
string normalpicname = "audit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (ins_edit_mode) then return

string arg_msg
if (f_find_fx_user_power(44, ref arg_msg) <> 1) then // 44-供应商询价单审核
	MessageBox('权限提示', arg_msg)
	return
end if

long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

long billid, flag
flag = dw_sptprice_change_list.Object.flag[row]
if (flag > 0) then
	MessageBox('提示', '该单据已经审核')
	return
end if

billid = dw_sptprice_change_list.Object.billid[row]
if (billid <= 0) then return

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('billid', billid)
parm.SetInt('flag', 1)
FXAppCom.AuditSptPriceChange(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

MessageBox('提示', '操作成功')
dw_sptprice_change_list.Object.flag[row] = 1
dw_sptprice_change_list.Object.auditemp[row] = app_username
dw_sptprice_change_list.Object.auditdate[row] = DateTime(Today(), Now())
row = dw_sptprice_change.GetRow()
dw_sptprice_change.Object.flag[row] = 1
dw_sptprice_change.Object.auditemp[row] = app_username
dw_sptprice_change.Object.auditdate[row] = DateTime(Today(), Now())

// 修改 删除 审核 撤审
cb_edit.Enabled = false
cb_del.Enabled = false
cb_audit.Enabled = false
if (f_find_fx_user_power(45, ref arg_msg) = 1) then // 45-供应商询价单撤审
	cb_caudit.Enabled = true
end if
end event

type cb_caudit from uo_imflatbutton within w_spt_price_change_fx
integer x = 777
integer width = 151
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "撤审"
string normalpicname = "caudit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (ins_edit_mode) then return

string arg_msg
if (f_find_fx_user_power(45, ref arg_msg) <> 1) then // 45-供应商询价单撤审
	MessageBox('权限提示', arg_msg)
	return
end if

long row
row = dw_sptprice_change_list.GetRow()
if (row <= 0) then return
if (not dw_sptprice_change_list.IsSelected(row)) then return

long billid, flag
flag = dw_sptprice_change_list.Object.flag[row]
if (flag = 0) then
	MessageBox('提示', '该单据未审核')
	return
end if

billid = dw_sptprice_change_list.Object.billid[row]
if (billid <= 0) then return

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('billid', billid)
parm.SetInt('flag', 0)
FXAppCom.AuditSptPriceChange(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

datetime dtnull
SetNull(dtnull)

MessageBox('提示', '操作成功')
dw_sptprice_change_list.Object.flag[row] = 0
dw_sptprice_change_list.Object.auditemp[row] = ''
dw_sptprice_change_list.Object.auditdate[row] = dtnull
row = dw_sptprice_change.GetRow()
dw_sptprice_change.Object.flag[row] = 0
dw_sptprice_change.Object.auditemp[row] = ''
dw_sptprice_change.Object.auditdate[row] = dtnull

// 修改 删除 审核 撤审
cb_edit.Enabled = true
if (f_find_fx_user_power(43, ref arg_msg) = 1) then // 43-供应商询价单删除
	cb_del.Enabled = true
end if
if (f_find_fx_user_power(44, ref arg_msg) = 1) then // 44-供应商询价单审核
	cb_audit.Enabled = true
end if
cb_caudit.Enabled = false
end event

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

type cb_toppage from uo_imflatbutton within w_spt_price_change_fx
integer x = 3314
integer width = 151
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "首页"
boolean border = false
end type

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

type cb_page_ch from uo_imflatbutton within w_spt_price_change_fx
integer x = 3470
integer width = 82
integer height = 164
integer taborder = 20
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"
menustr = menustr + "|" + "Text=末页~tEvent=ue_page_end"
	
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 st_4 from statictext within w_spt_price_change_fx
integer x = 1111
integer y = 200
integer width = 224
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 = "单号含"
alignment alignment = center!
boolean focusrectangle = false
end type

type sle_likestr from u_sleedit within w_spt_price_change_fx
integer x = 1321
integer y = 184
integer height = 84
integer taborder = 90
boolean bringtotop = true
end type

event keydown;call super::keydown;//if (key = KeyEnter!) then
//	ins_cur_pageNum = 1
//	wf_retrieve_saletask( )
//end if
end event

type dw_sptprice_change from datawindow within w_spt_price_change_fx
integer y = 280
integer width = 1751
integer height = 796
integer taborder = 100
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_spt_price_change_ff"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;if (not ins_edit_mode) then return

if (row <= 0) then return

if ((dwo.Type = 'column' and dwo.Name = 'sptname') or (dwo.Type = 'text' and dwo.Name = 'sptname_t')) then
	long ori_sptcomid, new_sptcomid
	ori_sptcomid = this.Object.sptcomid[row]
	
	s_fx_company s_ret
	Open(w_spt_ch_fx)
	s_ret = Message.PowerObjectParm
	if not IsNull(s_ret) then
		if (s_ret.ifselect) then
			new_sptcomid = s_ret.comid[1]
			if (ori_sptcomid <> new_sptcomid) then
				dw_sptprice_changemx.Reset() // 重选供应商，清空明细物料
				if (new_sptcomid > 0) then
					uo_pz.init()
					uo_pz.ins_comid = new_sptcomid
					string arg_msg
					if (uo_pz.uof_before_ready(ref arg_msg) <> 1) then
						MessageBox('提示', arg_msg)
					end if
				end if
			end if
			
			this.Object.sptcomid[row] = new_sptcomid
			this.Object.sptname[row] = s_ret.comname[1]
		end if
	end if
end if
end event

type st_2 from statictext within w_spt_price_change_fx
integer y = 200
integer width = 183
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 = "日期从"
alignment alignment = center!
boolean focusrectangle = false
end type

type em_datea from editmask within w_spt_price_change_fx
integer x = 187
integer y = 184
integer width = 389
integer height = 84
integer taborder = 70
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type st_3 from statictext within w_spt_price_change_fx
integer x = 581
integer y = 200
integer width = 96
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 = "到"
alignment alignment = center!
boolean focusrectangle = false
end type

type em_datez from editmask within w_spt_price_change_fx
integer x = 672
integer y = 184
integer width = 389
integer height = 84
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type dw_sptprice_change_list from u_dw_rbtnfilter within w_spt_price_change_fx
integer x = 1751
integer y = 280
integer width = 2583
integer height = 796
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string title = "单据摘要内容"
string dataobject = "dw_fx_spt_price_change"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
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 (ins_edit_mode) then return

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 (ins_edit_mode) then return

if IsNull(currentrow) then return
if (currentrow <= 0) then return

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

dw_sptprice_change.Reset()
this.RowsCopy(currentrow, currentrow, Primary!, dw_sptprice_change, 1, Primary!)

// 修改 删除 审核 撤审
string arg_msg
if (this.Object.flag[currentrow] = 1) then // 已审
	cb_edit.Enabled = false
	cb_del.Enabled = false
	cb_audit.Enabled = false
	if (f_find_fx_user_power(45, ref arg_msg) = 1) then // 45-供应商询价单撤审
		cb_caudit.Enabled = true
	end if
elseif (this.Object.flag[currentrow] = 0) then // 未审
	cb_edit.Enabled = true
	if (f_find_fx_user_power(43, ref arg_msg) = 1) then // 43-供应商询价单删除
		cb_del.Enabled = true
	end if
	if (f_find_fx_user_power(44, ref arg_msg) = 1) then // 44-供应商询价单审核
		cb_audit.Enabled = true
	end if
	cb_caudit.Enabled = false
end if

long billid
billid = this.Object.billid[currentrow]
wf_retrieve_mx(billid)

end event

type cb_mx from uo_imflatbutton within w_spt_price_change_fx
integer x = 933
integer width = 274
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "明细功能"
string normalpicname = "mx.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;//
if (not ins_edit_mode) then return

string menuStr = 'Text=增明细~tEvent=ue_addmx' + '|' + 'Text=删明细~tEvent=ue_delmx'

m_Dfc_Control_PopupMenu dmPopupMenu
dmPopupMenu = CREATE m_Dfc_Control_PopupMenu
dmPopupMenu.mf_BuildMenu(THIS, menustr)
dmPopupMenu.mf_PopMenu()
DESTROY dmPopupMenu
end event

type p_ljfieb from picture within w_spt_price_change_fx
integer x = 2126
integer y = 192
integer width = 73
integer height = 64
boolean bringtotop = true
string pointer = "HAND.CUR"
boolean originalsize = true
string picturename = "graphics\ljfieb.bmp"
boolean focusrectangle = false
string powertiptext = "协作"
end type

event clicked;m_Dfc_Control_PopupMenu dmPopupMenu
string menustr

string arg_msg
if (f_find_fx_user_power(46, ref arg_msg) = 1) then // 46-供应商询价单发送单据
	menustr="Text=发送单据~tEvent=ue_send_ljfieb"
end if
	
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 dw_sptprice_changemx from u_dw_rbtnfilter within w_spt_price_change_fx
event ue_dwndropdown pbm_dwndropdown
integer y = 1084
integer width = 4347
integer height = 992
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string dataobject = "dw_fx_spt_price_changemx"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event ue_dwndropdown;//
if (not ins_edit_mode) then return

long row
row = this.GetRow()

if (row <= 0) then return

string arg_msg
if (not uo_pz.ins_isReady) then
	uo_pz.uof_get_ready(ref arg_msg)
	if (arg_msg <> '') then
		MessageBox('提示', '获取配置失败:' + arg_msg)
		return
	end if
end if

s_fx_pzwin_open s_tran
s_tran.arg_mtrlid = this.Object.mtrlid[row]
s_tran.arg_mtrlid_erp = this.Object.mtrlid_erp[row]
s_tran.arg_statusflag = this.Object.statusflag[row]
s_tran.arg_statustype = this.Object.statustype[row]
s_tran.arg_woodcodeflag = this.Object.woodcodeflag[row]
s_tran.arg_woodcodetype = this.Object.woodcodetype[row]
s_tran.arg_pcodeflag = this.Object.pcodeflag[row]
s_tran.arg_pcodetype = this.Object.pcodetype[row]
s_tran.arg_colname = this.GetColumnName()
s_tran.arg_x = parent.X + this.X + this.Pointerx()
s_tran.arg_y = parent.Y + this.Y + this.Pointery()

string ret
ret = uo_pz.uof_open_pzwin(s_tran, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
end if

this.SetItem(row, s_tran.arg_colname, ret)



end event

event doubleclicked;call super::doubleclicked;// 双击空白处
if (not ins_edit_mode) then return

if (dwo.Type <> 'datawindow') then return

parent.post event ue_addmx( )
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 itemfocuschanged;call super::itemfocuschanged;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
	
	string colName
	colName = this.GetColumnName()
	if (colName = 'requiredate') then
		this.SelectText(1, Len(this.GetText()))
	end if
end if
end event

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

