$PBExportHeader$uo_ddlb_storageid.sru
forward
global type uo_ddlb_storageid from dropdownlistbox
end type
end forward

global type uo_ddlb_storageid from dropdownlistbox
integer width = 247
integer height = 228
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type
global uo_ddlb_storageid uo_ddlb_storageid

type variables
long uo_storageid
long uo_storageid_arr[]
end variables

event constructor;Long ll_storageid
String ls_storagename,ls_scode
Long ll_storageid_ddlb_text
String ls_storagename_ddlbtext,ls_scode_ddlbtext
String ls_ddlbtext
Long cnt = 0 
Long ll_i
Int li_inuse

FOR ll_i = 1 To UpperBound(sys_user_storageid)
	ll_storageid = sys_user_storageid[ll_i]
	SELECT storagename,scode,inuse
		INTO :ls_storagename,:ls_scode,:li_inuse
		FROM u_storage
		WHERE storageid = :ll_storageid
		Order By scode Asc;
	IF sqlca.SQLCode <> 0 Or IsNull(ls_storagename) THEN ls_storagename = ''
	IF sqlca.SQLCode <> 0 Or IsNull(ls_scode) THEN ls_scode = ''
	
	IF li_inuse = 0 THEN CONTINUE
	
	ls_ddlbtext = f_scode_name(ll_storageid,ls_scode,ls_storagename)
	
	This.AddItem (ls_ddlbtext)
	
	ll_storageid_ddlb_text = ll_storageid
	ls_storagename_ddlbtext = ls_storagename
	ls_scode_ddlbtext = ls_scode
	
	cnt++
NEXT

This.uo_storageid = ll_storageid_ddlb_text
uo_storageid_arr[1] = ll_storageid_ddlb_text
This.Text = f_scode_name(ll_storageid_ddlb_text,ls_scode_ddlbtext,ls_storagename_ddlbtext)

//SELECT count(*) Into :cnt From u_storage Where inuse = 1 ;
IF cnt > 1 THEN
	This.AddItem ('[全部仓库]')
END IF


end event

event selectionchanged;Long ll_storageid_arr[]

IF THIS.Text = '[全部仓库]' THEN
	uo_storageid = -1
	ll_storageid_arr = sys_user_storageid
	uo_storageid_arr = ll_storageid_arr
ELSE
	uo_storageid = Long(Mid ( THIS.Text,Pos(THIS.Text,'[') + 1,Len(THIS.Text) - Pos(THIS.Text,'[') - 1 ))
	ll_storageid_arr[1] = uo_storageid
	uo_storageid_arr = ll_storageid_arr
END IF



end event

on uo_ddlb_storageid.create
end on

on uo_ddlb_storageid.destroy
end on

