$PBExportHeader$w_mtrlware_cust_fx.srw
$PBExportComments$(销售)查看 客户推送的库存信息
forward
global type w_mtrlware_cust_fx from w_publ_pageretr_easyq
end type
type dw_cust from u_dw_rbtnfilter within w_mtrlware_cust_fx
end type
end forward

global type w_mtrlware_cust_fx from w_publ_pageretr_easyq
integer width = 4713
integer height = 2500
string title = "客户库存信息"
windowstate windowstate = normal!
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
dw_cust dw_cust
end type
global w_mtrlware_cust_fx w_mtrlware_cust_fx

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

long ins_comid
end variables

forward prototypes
public subroutine wf_get_cust ()
public subroutine wf_get_mtrlware (long arg_comid)
end prototypes

public subroutine wf_get_cust ();dw_cust.Reset()
dw_pageretr.Reset()

string arg_msg
oleobject obj, parm, list, item
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
obj = FXAppCom.GetMyCustList(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取客户列表失败:' + arg_msg)
	return
end if

list = obj.GetPBArray('list')
dw_cust.SetRedraw(false)
long i, row
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	
	dw_cust.Object.comid[i] = item.GetInt('comid')
	dw_cust.Object.comname[i] = item.GetString('comname')
	dw_cust.Object.simplename[i] = item.GetString('simplename')
	dw_cust.Object.address[i] = item.GetString('address')
	dw_cust.Object.freight[i] = item.GetString('freight')
	dw_cust.Object.freight_tele[i] = item.GetString('freight_tele')
next
if (dw_cust.RowCount() > 0) then
	dw_cust.SetRow(1)
	dw_cust.SelectRow(0, false)
	dw_cust.SelectRow(1, true)
	dw_cust.Post Event RowFocusChanged(1)
end if
dw_cust.SetRedraw(true)
end subroutine

public subroutine wf_get_mtrlware (long arg_comid);int rslt = 1

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

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

long pageNum
pageNum = ins_cur_pageNum

string likeStr
//likeStr = Trim(sle_usual_query.Text)

oleobject obj
obj = FXAppCom.GetMtrlwarePropel(app_token_fx, arg_comid, pageSize, pageNum, likeStr, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ins_totalPages = obj.GetInt('totalPages')

dw_pageretr.Reset()
dw_pageretr.SetRedraw(false)
oleobject list, item
list = obj.GetArrOfPBDictionary('List')
long i, row
for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	row = dw_pageretr.InsertRow(0)
	dw_pageretr.Object.comid[row] = item.GetInt('comid')
	dw_pageretr.Object.comid_send[row] = item.GetInt('comid_send')
	dw_pageretr.Object.scid[row] = item.GetInt('scid')
	dw_pageretr.Object.mtrlwareid[row] = item.GetInt('mtrlwareid')
	dw_pageretr.Object.mtrlid[row] = item.GetInt('mtrlid')
	dw_pageretr.Object.mtrlcode[row] = item.GetString('mtrlcode')
	dw_pageretr.Object.mtrlname[row] = item.GetString('mtrlname')
	dw_pageretr.Object.storagename[row] = item.GetString('storagename')
	dw_pageretr.Object.status[row] = item.GetString('status')
	dw_pageretr.Object.woodcode[row] = item.GetString('woodcode')
	dw_pageretr.Object.pcode[row] = item.GetString('pcode')
	dw_pageretr.Object.plancode[row] = item.GetString('plancode')
	dw_pageretr.Object.mtrlcuscode[row] = item.GetString('mtrlcuscode')
	dw_pageretr.Object.location[row] = item.GetString('location')
	dw_pageretr.Object.notauditnoallocqty[row] = item.GetDouble('notauditnoallocqty')
	if not IsNull(item.GetDateTime('senddate')) then
		dw_pageretr.Object.senddate[row] = item.GetDateTime('senddate')
	end if
	dw_pageretr.Object.mtrlmode[row] = item.GetString('mtrlmode')
	dw_pageretr.Object.unit[row] = item.GetString('unit')
next
dw_pageretr.SetRedraw(true)

ext:
if (rslt = 0) then
	MessageBox('提示', '获取库存信息失败:' + arg_msg)
else
	
end if

end subroutine

on w_mtrlware_cust_fx.create
int iCurrent
call super::create
this.dw_cust=create dw_cust
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.dw_cust
end on

on w_mtrlware_cust_fx.destroy
call super::destroy
destroy(this.dw_cust)
end on

event open;wf_movetocenter()

string arg_msg
if (f_find_fx_user_power(32, ref arg_msg) <> 1) then // 32-客户库存查看
	MessageBox('权限提示', arg_msg)
	Close(this)
	return
end if

dw_cust.Modify('destroy custype_t ~r~n destroy custype ~r~n destroy tele_t ~r~n destroy tele ~r~n') // 删除客户联系人、联系电话列

wf_get_cust()
end event

event resize;if (this.Width < 4400) then this.Width = 4400
if (this.Height < 2300) then this.Height = 2300

ln_bar.EndX = THIS.Width
ln_bar2.EndX = THIS.Width
ln_1.EndX = THIS.Width
ln_2.EndX = THIS.Width
r_bar.Width = THIS.Width

dw_cust.Width = this.workspacewidth()

dw_pageretr.Height = this.workspaceheight() - dw_cust.Y - dw_cust.Height
dw_pageretr.Width = this.workspacewidth()

cb_exit.X = this.workspacewidth( ) - cb_exit.Width
cb_nextpage.X = cb_exit.X - cb_nextpage.Width - 5
cb_retrieveall.X = cb_nextpage.X - cb_retrieveall.Width - 5
em_pagerowno.X = cb_retrieveall.X - em_pagerowno.Width - 5
end event

event ue_page2;// 上页
if (ins_cur_pageNum = 1) then return

ins_cur_pageNum --
wf_get_mtrlware(ins_comid)
end event

event ue_page3;// 下页
if (ins_cur_pageNum >= ins_totalPages) then return

ins_cur_pageNum ++
wf_get_mtrlware(ins_comid)
end event

event ue_page4;// 末页
if (ins_cur_pageNum = ins_totalPages) then return

ins_cur_pageNum = ins_totalPages
wf_get_mtrlware(ins_comid)
end event

type cb_func from w_publ_pageretr_easyq`cb_func within w_mtrlware_cust_fx
end type

type cb_exit from w_publ_pageretr_easyq`cb_exit within w_mtrlware_cust_fx
integer x = 4347
integer picsize = 16
toolbaralignment pic_align = alignattop!
end type

type sle_usual_query from w_publ_pageretr_easyq`sle_usual_query within w_mtrlware_cust_fx
boolean visible = false
integer x = 1435
integer y = 2252
boolean enabled = false
end type

type cb_retrieveall from w_publ_pageretr_easyq`cb_retrieveall within w_mtrlware_cust_fx
end type

event cb_retrieveall::clicked;ins_cur_pageNum = 1
wf_get_mtrlware(ins_comid)
end event

type em_pagerowno from w_publ_pageretr_easyq`em_pagerowno within w_mtrlware_cust_fx
integer x = 1806
integer y = 40
integer height = 80
string text = "100"
end type

type dw_pageretr from w_publ_pageretr_easyq`dw_pageretr within w_mtrlware_cust_fx
integer y = 484
integer width = 3319
integer height = 1584
string dataobject = "dw_fx_mtrlware_propel"
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type st_1 from w_publ_pageretr_easyq`st_1 within w_mtrlware_cust_fx
boolean visible = false
integer x = 1225
integer y = 2272
end type

type cb_nextpage from w_publ_pageretr_easyq`cb_nextpage within w_mtrlware_cust_fx
end type

type ddlb_yl from w_publ_pageretr_easyq`ddlb_yl within w_mtrlware_cust_fx
integer x = 1211
integer y = 40
end type

type cbx_yl from w_publ_pageretr_easyq`cbx_yl within w_mtrlware_cust_fx
integer x = 1006
integer y = 44
long backcolor = 16777215
end type

type cb_psetup from w_publ_pageretr_easyq`cb_psetup within w_mtrlware_cust_fx
end type

type cb_2 from w_publ_pageretr_easyq`cb_2 within w_mtrlware_cust_fx
end type

type cb_refresh from w_publ_pageretr_easyq`cb_refresh within w_mtrlware_cust_fx
end type

event cb_refresh::clicked;call super::clicked;wf_get_cust()
end event

type cb_help from w_publ_pageretr_easyq`cb_help within w_mtrlware_cust_fx
boolean visible = false
integer x = 3250
boolean enabled = false
end type

type cb_copyself from w_publ_pageretr_easyq`cb_copyself within w_mtrlware_cust_fx
end type

type gb_2 from w_publ_pageretr_easyq`gb_2 within w_mtrlware_cust_fx
end type

type ln_bar from w_publ_pageretr_easyq`ln_bar within w_mtrlware_cust_fx
end type

type ln_bar2 from w_publ_pageretr_easyq`ln_bar2 within w_mtrlware_cust_fx
end type

type r_bar from w_publ_pageretr_easyq`r_bar within w_mtrlware_cust_fx
end type

type ln_1 from w_publ_pageretr_easyq`ln_1 within w_mtrlware_cust_fx
integer beginy = 172
integer endy = 172
end type

type ln_2 from w_publ_pageretr_easyq`ln_2 within w_mtrlware_cust_fx
integer beginy = 176
integer endy = 176
end type

type dw_cust from u_dw_rbtnfilter within w_mtrlware_cust_fx
integer y = 172
integer width = 1179
integer height = 312
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_fx_cust_ch"
boolean hscrollbar = true
boolean vscrollbar = 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.SetRow(row)
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if
end event

event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
	ins_comid = this.Object.comid[currentrow]
	wf_get_mtrlware(ins_comid)
end if
end event

