$PBExportHeader$w_spt_mtrl_view_fx.srw
$PBExportComments$供应商产品浏览
forward
global type w_spt_mtrl_view_fx from w_publ_base
end type
type ddlb_spt from dropdownlistbox within w_spt_mtrl_view_fx
end type
type st_1 from statictext within w_spt_mtrl_view_fx
end type
type tv_1 from uo_tv_fx_mtrltype within w_spt_mtrl_view_fx
end type
type st_2 from statictext within w_spt_mtrl_view_fx
end type
type dw_1 from datawindow within w_spt_mtrl_view_fx
end type
type st_3 from statictext within w_spt_mtrl_view_fx
end type
type pb_1 from picturebutton within w_spt_mtrl_view_fx
end type
type sle_filter from singlelineedit within w_spt_mtrl_view_fx
end type
type cbx_all from checkbox within w_spt_mtrl_view_fx
end type
type p_shopcart from picture within w_spt_mtrl_view_fx
end type
type st_shopcart_cnt from statictext within w_spt_mtrl_view_fx
end type
type em_pagesize from editmask within w_spt_mtrl_view_fx
end type
type pb_uppage from picturebutton within w_spt_mtrl_view_fx
end type
type pb_dnpage from picturebutton within w_spt_mtrl_view_fx
end type
type st_4 from statictext within w_spt_mtrl_view_fx
end type
type em_cur_page from editmask within w_spt_mtrl_view_fx
end type
type st_allpages from statictext within w_spt_mtrl_view_fx
end type
type pb_page_top from picturebutton within w_spt_mtrl_view_fx
end type
type pb_page_end from picturebutton within w_spt_mtrl_view_fx
end type
end forward

global type w_spt_mtrl_view_fx from w_publ_base
integer width = 4366
integer height = 2784
string title = "供应商产品浏览"
boolean maxbox = true
boolean resizable = true
long backcolor = 16777215
ddlb_spt ddlb_spt
st_1 st_1
tv_1 tv_1
st_2 st_2
dw_1 dw_1
st_3 st_3
pb_1 pb_1
sle_filter sle_filter
cbx_all cbx_all
p_shopcart p_shopcart
st_shopcart_cnt st_shopcart_cnt
em_pagesize em_pagesize
pb_uppage pb_uppage
pb_dnpage pb_dnpage
st_4 st_4
em_cur_page em_cur_page
st_allpages st_allpages
pb_page_top pb_page_top
pb_page_end pb_page_end
end type
global w_spt_mtrl_view_fx w_spt_mtrl_view_fx

type variables
datastore ins_ds_spt // 存放供应商列表

long ins_pagenum = 1
long ins_allpages = 1
end variables

forward prototypes
public subroutine wf_retrieve_mtrltype (readonly long arg_comid)
public subroutine wf_retrieve_mtrl (readonly long a_mtrltypeid, readonly long a_sonflag)
public subroutine wf_download_pic_async ()
public subroutine wf_retrieve_pic ()
public subroutine wf_add_shopcart (readonly long arg_mode)
public subroutine wf_retrieve_price ()
end prototypes

public subroutine wf_retrieve_mtrltype (readonly long arg_comid);string arg_msg
oleobject mtrltypes
mtrltypes = FXAppCom.GetSptMtrltypeBySptcomid(app_token_fx, arg_comid, ref arg_msg)
IF (arg_msg <> '') THEN
	MessageBox('提示', '获取物料类别失败:' + arg_msg)
	RETURN
END IF

if (mtrltypes.Count <= 0) then return

datastore ds
ds = create datastore
ds.DataObject = 'ds_fx_mtrltype'

long i, row
oleobject mtrltype
for i = 1 to mtrltypes.Count
	mtrltype = mtrltypes.GetItem(i - 1)
	
	row = ds.InsertRow(0)
	ds.Object.comid[row] = mtrltype.GetInt('comid')
	ds.Object.mtrltypeid[row] = mtrltype.GetInt('mtrltypeid')
	ds.Object.mtrltype[row] = mtrltype.GetString('mtrltype')
	ds.Object.handtype[row] = mtrltype.GetString('handtype')
	ds.Object.sonflag[row] = mtrltype.GetInt('sonflag')
	ds.Object.parentid[row] = mtrltype.GetInt('parentid')
	ds.Object.mtrltypeid_erp[row] = mtrltype.GetInt('mtrltypeid_erp')
next

tv_1.uof_init(ds)
end subroutine

public subroutine wf_retrieve_mtrl (readonly long a_mtrltypeid, readonly long a_sonflag);dw_1.Reset()

string arg_msg
//if (f_find_fx_user_power(48, ref arg_msg) <> 1) then // 48-供应商产品浏览
//	MessageBox('权限提示', arg_msg)
//	return
//end if

cbx_all.Checked = false

long pagesize
pagesize = long(em_pagesize.Text)

oleobject parm, rslt
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('mtrltypeid', a_mtrltypeid)
parm.SetInt('sonflag', a_sonflag)
parm.SetInt('pagesize', pagesize)
parm.SetInt('pagenum', ins_pagenum)
parm.SetString('likeStr', Trim(sle_filter.Text))

rslt = FXAppCom.GetSptMtrlWithPageSize(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取产品信息失败:' + arg_msg)
	return
end if

oleobject mtrls, mtrl
mtrls = rslt.GetArrOfPBDictionary('list')
ins_allpages = rslt.GetInt('allpages')

em_cur_page.Text = string(ins_pagenum)
st_allpages.Text = '/' + string(ins_allpages)

long i, cnt, row
cnt = mtrls.Count

string exePath
exePath = GetCurrentDirectory()

dw_1.SetRedraw(false)
for i = 1 to cnt
	mtrl = mtrls.GetItem(i - 1)
	
	row = dw_1.InsertRow(0)
	dw_1.Object.ch[row] = 0
	dw_1.Object.fxmtrlid[row] = mtrl.GetInt('fxmtrlid')
	dw_1.Object.comid[row] = mtrl.GetInt('comid')
	dw_1.Object.mtrlid[row] = mtrl.GetInt('mtrlid')
	dw_1.Object.mtrlcode[row] = mtrl.GetString('mtrlcode')
	dw_1.Object.mtrlname[row] = mtrl.GetString('mtrlname')
	dw_1.Object.mtrlmode[row] = mtrl.GetString('mtrlmode')
	dw_1.Object.mtrlsectype[row] = mtrl.GetString('mtrlsectype')
	dw_1.Object.zxmtrlmode[row] = mtrl.GetString('zxmtrlmode')
	dw_1.Object.usermtrlmode[row] = mtrl.GetString('usermtrlmode')
//	dw_1.Object.statusflag[row] = mtrl.GetInt('statusflag')
//	dw_1.Object.statustype[row] = mtrl.GetInt('statustype')
//	dw_1.Object.woodcodeflag[row] = mtrl.GetInt('woodcodeflag')
//	dw_1.Object.woodcodetype[row] = mtrl.GetInt('woodcodetype')
//	dw_1.Object.pcodeflag[row] = mtrl.GetInt('pcodeflag')
//	dw_1.Object.pcodetype[row] = mtrl.GetInt('pcodetype')
//	dw_1.Object.configcodetype[row] = mtrl.GetInt('configcodetype')
	dw_1.Object.unit[row] = mtrl.GetString('unit')
	dw_1.Object.filetype[row] = mtrl.GetString('fileType')
	dw_1.Object.shopcart_pic_path[row] = exePath + '\graphics\shopcart_add.png'
next
dw_1.SetRedraw(true)

if (dw_1.RowCount() > 0) then
	wf_retrieve_pic()
	wf_download_pic_async()
	wf_retrieve_price()
end if



end subroutine

public subroutine wf_download_pic_async ();if (dw_1.RowCount() <= 0) then return

string exePath
exePath = GetCurrentDirectory()

oleobject parm, list, item
parm = FXAppCom.CreatePbDictionary()
list = FXAppCom.CreArrOfPbDictionary()

long i
for i = 1 to dw_1.RowCount()
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('comid', dw_1.Object.comid[i])
	item.SetInt('relid_erp', dw_1.Object.mtrlid[i])
	
	list.Add(item)
next

parm.SetString('token', app_token_fx)
parm.SetString('exePath', exePath)
parm.SetObject('list', list)

string arg_msg
FXAppCom.DownloadPicFilesAsync(parm, ref arg_msg)
if (arg_msg <> '') then
	Timer(0)
	MessageBox('提示', '请求产品图片失败:' + arg_msg)
else
	Timer(0.8)
end if
end subroutine

public subroutine wf_retrieve_pic ();if (dw_1.RowCount() <= 0) then return

long i
long comid, mtrlid
string picFilePath, exePath, filetype
exePath = GetCurrentDirectory()

dw_1.SetRedraw(false)
for i = 1 to dw_1.RowCount()
	comid = dw_1.Object.comid[i]
	mtrlid = dw_1.Object.mtrlid[i]
	filetype = Trim(dw_1.Object.filetype[i])
	
	picFilePath = exePath + '\cache\mtrlpic\c_' + string(comid) + '_m_' + string(mtrlid) + '.' + filetype
	
	if (FileExists(picFilePath)) then
		dw_1.Object.filepath[i] = picFilePath
	else
		dw_1.Object.filepath[i] = exePath + '\graphics\mtrl_view.png'
	end if
next
dw_1.SetRedraw(true)
end subroutine

public subroutine wf_add_shopcart (readonly long arg_mode);// arg_mode  0-单选 1-多选

s_fx_mtrldef s_ch
long comid, mtrlid
decimal price, qty
long row, i
long index = 1

if (arg_mode = 0) then // 单选
	row = dw_1.GetRow()
	if (row > 0) then
		s_ch.comid[index] = dw_1.Object.comid[row]
		s_ch.mtrlid[index] = dw_1.Object.mtrlid[row]
		s_ch.price[index] = dw_1.Object.hisprice[row]
		s_ch.fxmtrlid[index] = dw_1.Object.fxmtrlid[row]
		s_ch.qty[index] = 1
	else
		return
	end if
elseif (arg_mode = 1) then // 多选
	for i = 1 to dw_1.RowCount()
		if (dw_1.Object.ch[i] = 0) then continue
		
		s_ch.comid[index] = dw_1.Object.comid[i]
		s_ch.mtrlid[index] = dw_1.Object.mtrlid[i]
		s_ch.price[index] = dw_1.Object.hisprice[i]
		s_ch.fxmtrlid[index] = dw_1.Object.fxmtrlid[row]
		s_ch.qty[index] = 1
		
		index ++
	next
	
	if (UpperBound(s_ch.comid) <= 0) then return
else
	return
end if

oleobject list, item
list = FXAppCom.CreArrOfPbDictionary()
for i = 1 to UpperBound(s_ch.comid)
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('comid', s_ch.comid[i])
	item.SetInt('mtrlid', s_ch.mtrlid[i])
	item.SetDouble('price', s_ch.price[index])
	item.SetDouble('qty', s_ch.qty[index])
	item.SetInt('fxmtrlid', s_ch.fxmtrlid[i])
	
	list.Add(item)
next

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetObject('list', list)

oleobject ret
string arg_msg
ret = FXAppCom.AddShopcart(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '添加购物车操作失败:' + arg_msg)
	return
end if

long cnt
cnt = ret.GetInt('cnt')
if (cnt <= 999) then
	st_shopcart_cnt.Text = string(cnt)
else
	st_shopcart_cnt.Text = '...'
end if

s_toast_parm s_parm
s_parm.Width = 1000
s_parm.Height = 200
s_parm.msg = '成功添加至购物车'
s_parm.showtime = 0.5
OpenWithParm(w_toast, s_parm)


end subroutine

public subroutine wf_retrieve_price ();string arg_msg
//if (f_find_fx_user_power(49, ref arg_msg) <> 1) then // 49-供应商产品浏览(可获取最新报价)
//	dw_1.Modify('destroy hisprice_1 ~r~n destroy hisprice ~r~n')
//	return
//end if

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

oleobject ReqList, item
ReqList = FXAppCom.CreArrOfPbDictionary()
long i
for i = 1 to dw_1.RowCount()
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('mtrlid', dw_1.Object.fxmtrlid[i])
	
	ReqList.Add(item)
next

oleobject parm, retParm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetObject('reqlist', ReqList)
retParm = FXAppCom.GetAuditSptPriceByFxmtrlid(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

long mtrlid, row
decimal price
oleobject RspList
RspList = retParm.GetArrOfPBDictionary('rsplist')
dw_1.SetRedraw(false)
for i = 1 to RspList.Count
	item = RspList.GetItem(i - 1)
	
	mtrlid = item.GetInt('mtrlid')
	row = dw_1.Find('fxmtrlid = ' + string(mtrlid), 1, dw_1.RowCount())
	if (row > 0) then
		price = item.GetDouble('price')
		dw_1.Object.hisprice[row] = price
	end if
next
dw_1.SetRedraw(true)




end subroutine

on w_spt_mtrl_view_fx.create
int iCurrent
call super::create
this.ddlb_spt=create ddlb_spt
this.st_1=create st_1
this.tv_1=create tv_1
this.st_2=create st_2
this.dw_1=create dw_1
this.st_3=create st_3
this.pb_1=create pb_1
this.sle_filter=create sle_filter
this.cbx_all=create cbx_all
this.p_shopcart=create p_shopcart
this.st_shopcart_cnt=create st_shopcart_cnt
this.em_pagesize=create em_pagesize
this.pb_uppage=create pb_uppage
this.pb_dnpage=create pb_dnpage
this.st_4=create st_4
this.em_cur_page=create em_cur_page
this.st_allpages=create st_allpages
this.pb_page_top=create pb_page_top
this.pb_page_end=create pb_page_end
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.ddlb_spt
this.Control[iCurrent+2]=this.st_1
this.Control[iCurrent+3]=this.tv_1
this.Control[iCurrent+4]=this.st_2
this.Control[iCurrent+5]=this.dw_1
this.Control[iCurrent+6]=this.st_3
this.Control[iCurrent+7]=this.pb_1
this.Control[iCurrent+8]=this.sle_filter
this.Control[iCurrent+9]=this.cbx_all
this.Control[iCurrent+10]=this.p_shopcart
this.Control[iCurrent+11]=this.st_shopcart_cnt
this.Control[iCurrent+12]=this.em_pagesize
this.Control[iCurrent+13]=this.pb_uppage
this.Control[iCurrent+14]=this.pb_dnpage
this.Control[iCurrent+15]=this.st_4
this.Control[iCurrent+16]=this.em_cur_page
this.Control[iCurrent+17]=this.st_allpages
this.Control[iCurrent+18]=this.pb_page_top
this.Control[iCurrent+19]=this.pb_page_end
end on

on w_spt_mtrl_view_fx.destroy
call super::destroy
destroy(this.ddlb_spt)
destroy(this.st_1)
destroy(this.tv_1)
destroy(this.st_2)
destroy(this.dw_1)
destroy(this.st_3)
destroy(this.pb_1)
destroy(this.sle_filter)
destroy(this.cbx_all)
destroy(this.p_shopcart)
destroy(this.st_shopcart_cnt)
destroy(this.em_pagesize)
destroy(this.pb_uppage)
destroy(this.pb_dnpage)
destroy(this.st_4)
destroy(this.em_cur_page)
destroy(this.st_allpages)
destroy(this.pb_page_top)
destroy(this.pb_page_end)
end on

event open;call super::open;string arg_msg // 48-供应商产品浏览(附购物车功能) 49-供应商产品浏览(可获取历史报价)
//if (f_find_fx_user_power(48, ref arg_msg) <> 1 &
//		and f_find_fx_user_power(49, ref arg_msg) <> 1) then
//	MessageBox('权限提示', arg_msg)
//	Close(this)
//	return
//end if

ins_ds_spt = create datastore
ins_ds_spt.DataObject = 'dw_fx_spt_ch'
ins_ds_spt.Reset()

oleobject list, item
list = FXAppCom.GetMySptList(app_token_fx, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取供应商列表失败:' + arg_msg)
	return
end if

long i, row, index
string temp_comname
if (list.Count > 0) then
	for i = 1 to list.Count
		row = ins_ds_spt.InsertRow(0)
		item = list.GetItem(i - 1)
		
		temp_comname = item.GetString('comname')
		index = ddlb_spt.InsertItem(temp_comname, 0)
		
		ins_ds_spt.Object.ch[row] = index // ch字段记录index
		ins_ds_spt.Object.comid[row] = item.GetInt('comid')
		ins_ds_spt.Object.comname[row] = temp_comname
		ins_ds_spt.Object.simplename[row] = item.GetString('simplename')
//		ins_ds_spt.Object.custype[row] = item.GetString('custype')
//		ins_ds_spt.Object.tele[row] = item.GetString('tele')
		ins_ds_spt.Object.address[row] = item.GetString('address')
		ins_ds_spt.Object.freight[row] = item.GetString('freight')
		ins_ds_spt.Object.freight_tele[row] = item.GetString('freight_tele')
	next
	
	ins_ds_spt.AcceptText()
	ddlb_spt.SelectItem(1)
	ddlb_spt.post event selectionchanged(1) 
else
	ddlb_spt.InsertItem('-=没有供应商=-', 0)
end if

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)

oleobject ret
ret = FXAppCom.AddShopcart(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '刷新购物车数量失败:' + arg_msg)
	return
end if

long cnt
cnt = ret.GetInt('cnt')
if (cnt <= 999) then
	st_shopcart_cnt.Text = string(cnt)
else
	st_shopcart_cnt.Text = '...'
end if






end event

event timer;call super::timer;string arg_msg
long ret

ret = FXAppCom.DownloadPicFilesTimer(ref arg_msg)
if (arg_msg <> '') then
	Timer(0)
	MessageBox('提示', arg_msg)
	return
end if

if (ret = 0) then // 继续等待
	Timer(0.8)
elseif (ret = 1) then // 下载完成
	Timer(0)
elseif (ret = -1) then
	Timer(0)
	MessageBox('提示', '请求过于频繁,请稍后再试')
else
	Timer(0)
end if
end event

event resize;call super::resize;if this.width < 4320 then this.Width = 4320
if this.Height < 2680 then this.Height = 2680

tv_1.Height = this.workspaceheight( ) - tv_1.Y

dw_1.Height = this.workspaceheight( ) - dw_1.Y
dw_1.Width = this.workspacewidth( ) - dw_1.X

pb_page_end.X = this.workspacewidth( ) - 80 - pb_page_end.Width // 80
pb_dnpage.X = pb_page_end.X - 12 - pb_dnpage.Width
pb_uppage.X = pb_dnpage.X - 12 - pb_uppage.Width
pb_page_top.X = pb_uppage.X - 12 - pb_page_top.Width
st_allpages.X = pb_page_top.X - 20 - st_allpages.Width
em_cur_page.X = st_allpages.X - 2 - em_cur_page.Width
st_4.X = em_cur_page.X - 2 - st_4.Width

p_shopcart.X = this.workspacewidth( ) - 80 - p_shopcart.Width // 80
st_shopcart_cnt.X = p_shopcart.X + 64
end event

event key;call super::key;if (key = KeyF12!) then
	s_toast_parm s_parm
	s_parm.Width = 1000
	s_parm.Height = 200
	s_parm.msg = 'qweasd'
	s_parm.showtime = 0.4
	OpenWithParm(w_toast, s_parm)
end if
end event

type cb_func from w_publ_base`cb_func within w_spt_mtrl_view_fx
boolean visible = false
integer y = 2280
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_spt_mtrl_view_fx
boolean visible = false
integer y = 2280
boolean enabled = false
boolean cancel = false
end type

type ddlb_spt from dropdownlistbox within w_spt_mtrl_view_fx
integer x = 18
integer y = 112
integer width = 965
integer height = 300
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;if (this.Text = '-=没有供应商=-') then return

long comid, findRow
if (index > 0) then
	findRow = ins_ds_spt.Find('ch = ' + string(index), 1, ins_ds_spt.RowCount())
	if (findRow > 0) then
		comid = ins_ds_spt.Object.comid[findRow]
		wf_retrieve_mtrltype(comid)
	end if
end if
end event

type st_1 from statictext within w_spt_mtrl_view_fx
integer x = 325
integer y = 36
integer width = 343
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 tv_1 from uo_tv_fx_mtrltype within w_spt_mtrl_view_fx
integer x = 18
integer y = 300
integer width = 965
integer height = 1900
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
fontcharset fontcharset = gb2312charset!
fontfamily fontfamily = anyfont!
string facename = "宋体"
string picturename[] = {"StaticText!","Structure5!"}
end type

event selectionchanged;call super::selectionchanged;wf_retrieve_mtrl(this.ins_cur_info.mtrltypeid[1], this.ins_cur_info.sonflag[1])
end event

type st_2 from statictext within w_spt_mtrl_view_fx
integer x = 352
integer y = 220
integer width = 288
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 dw_1 from datawindow within w_spt_mtrl_view_fx
integer x = 997
integer y = 300
integer width = 3259
integer height = 1896
integer taborder = 30
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_spt_mtrl_view"
boolean vscrollbar = true
boolean livescroll = true
end type

event clicked;if (row > 0) then
	this.SelectRow(0, false)
//	this.SelectRow(row, true)
	this.SetRow(row)
	
	if (dwo.Name = 'shopcart_pic_path') then
		wf_add_shopcart(0)
	end if
end if
end event

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

event scrollhorizontal;this.object.DataWindow.HorizontalScrollPosition = 0
end event

type st_3 from statictext within w_spt_mtrl_view_fx
integer x = 1765
integer y = 220
integer width = 562
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 pb_1 from picturebutton within w_spt_mtrl_view_fx
boolean visible = false
integer x = 137
integer y = 2408
integer width = 110
integer height = 96
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string pointer = "HAND.CUR"
boolean enabled = false
string picturename = "OutputPrevious!"
end type

event clicked;if (this.PictureName = 'OutputPrevious!') then
	dw_1.SetSort('hisprice asc')
	dw_1.Sort()
	this.PictureName = 'OutputNext!'
else
	dw_1.SetSort('hisprice desc')
	dw_1.Sort()
	this.PictureName = 'OutputPrevious!'
end if
end event

type sle_filter from singlelineedit within w_spt_mtrl_view_fx
integer x = 2313
integer y = 204
integer width = 699
integer height = 84
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

event modified;this.Text = Trim(this.Text)
ins_pagenum = 1

wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])

//if (str <> '') then
//	//filter = 'mtrlcode like "%' + str + '%" or mtrlname like "%' + str + '%" or mtrlmode like "%' + str + '%"'
//	filter = ' (mtrlcode like ~'%' + str + '%~') '
//	filter += ' or (mtrlname like ~'%' + str + '%~') '
//	filter += ' or (mtrlmode like ~'%' + str + '%~') '
//	dw_1.SetFilter(filter)
//	dw_1.Filter()
//else
//	dw_1.SetFilter('')
//	dw_1.Filter()
//end if
end event

type cbx_all from checkbox within w_spt_mtrl_view_fx
integer x = 1033
integer y = 216
integer width = 224
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()
	dw_1.Object.ch[i] = ch
next
end event

type p_shopcart from picture within w_spt_mtrl_view_fx
integer x = 4027
integer y = 16
integer width = 219
integer height = 160
boolean bringtotop = true
string pointer = "HAND.CUR"
string picturename = "graphics\shopcart_empty.png"
boolean focusrectangle = false
end type

event clicked;if (IsValid(s_win_open[50].win)) then // 50-我的购物车
	Close(s_win_open[50].win)
end if

Open(w_shopcart_fx)
end event

type st_shopcart_cnt from statictext within w_spt_mtrl_view_fx
integer x = 4091
integer y = 60
integer width = 123
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string pointer = "HAND.CUR"
long backcolor = 16777215
string text = "0"
alignment alignment = center!
boolean focusrectangle = false
end type

event clicked;p_shopcart.post event clicked()
end event

type em_pagesize from editmask within w_spt_mtrl_view_fx
boolean visible = false
integer x = 265
integer y = 2412
integer width = 247
integer height = 84
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean enabled = false
string text = "5"
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "#"
boolean spin = true
double increment = 50
string minmax = "1~~1000"
end type

type pb_uppage from picturebutton within w_spt_mtrl_view_fx
integer x = 3899
integer y = 196
integer width = 110
integer height = 96
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string pointer = "HAND.CUR"
string picturename = "graphics\page_up.BMP"
string disabledname = "graphics\page_up.BMP"
alignment htextalign = right!
string powertiptext = "上一页"
end type

event clicked;if (ins_pagenum <= 1) then return

ins_pagenum --
wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])
end event

type pb_dnpage from picturebutton within w_spt_mtrl_view_fx
integer x = 4023
integer y = 196
integer width = 110
integer height = 96
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string pointer = "HAND.CUR"
string picturename = "graphics\page_dn.BMP"
string disabledname = "graphics\page_dn.BMP"
alignment htextalign = right!
string powertiptext = "下一页"
end type

event clicked;if (ins_pagenum >= ins_allpages) then return

ins_pagenum ++
wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])
end event

type st_4 from statictext within w_spt_mtrl_view_fx
integer x = 3237
integer y = 220
integer width = 183
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 16777215
string text = "当前页"
alignment alignment = center!
boolean focusrectangle = false
end type

type em_cur_page from editmask within w_spt_mtrl_view_fx
integer x = 3429
integer y = 212
integer width = 128
integer height = 68
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "1"
alignment alignment = center!
string mask = "#####"
string minmax = "1~~999"
end type

event modified;long page

if IsNumber(this.Text) then
	page = long(this.Text)
	if (page >=1 and page <= ins_allpages) then
		ins_pagenum = page
		wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])
	else
		this.Text = string(ins_pagenum)
	end if
else
	this.Text = string(ins_pagenum)
end if
end event

type st_allpages from statictext within w_spt_mtrl_view_fx
integer x = 3566
integer y = 220
integer width = 178
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 16777215
string text = "/1"
boolean focusrectangle = false
end type

type pb_page_top from picturebutton within w_spt_mtrl_view_fx
integer x = 3776
integer y = 196
integer width = 110
integer height = 96
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\page_top.BMP"
string disabledname = "graphics\page_top.BMP"
alignment htextalign = right!
string powertiptext = "首页"
end type

event clicked;ins_pagenum = 1
wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])
end event

type pb_page_end from picturebutton within w_spt_mtrl_view_fx
integer x = 4146
integer y = 196
integer width = 110
integer height = 96
integer taborder = 10
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string picturename = "graphics\page_end.BMP"
string disabledname = "graphics\page_end.BMP"
alignment htextalign = right!
string powertiptext = "末页"
end type

event clicked;ins_pagenum = ins_allpages
wf_retrieve_mtrl(tv_1.ins_cur_info.mtrltypeid[1], tv_1.ins_cur_info.sonflag[1])
end event

