$PBExportHeader$u_dropdowndatalist.sru
$PBExportComments$DropDownDataList~r~nUsage:~r~nRetrieve(sqlca,"select name,id from users")~r~nll_id=GetData()~r~n
forward
global type u_dropdowndatalist from dropdownlistbox
end type
end forward
global type u_dropdowndatalist from dropdownlistbox
int Width=247
int Height=228
int TabOrder=10
BorderStyle BorderStyle=StyleLowered!
boolean VScrollBar=true
long TextColor=33554432
int TextSize=-12
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
global u_dropdowndatalist u_dropdowndatalist
type variables
datastore ids
end variables
forward prototypes
public function any getdata ()
public function long retrieve (ref transaction ao_sqlca, string as_sqlselect)
end prototypes
public function any getdata ();any la_ret
long i
setnull(la_ret)
if this.text<>"" then
i=ids.find("#2='"+this.text+"'",1,ids.rowcount())
//ids.filter()
if i>0 then
la_ret=ids.Object.data[i, 1]
end if
end if
return la_ret
end function
public function long retrieve (ref transaction ao_sqlca, string as_sqlselect);long ll,i
string errors,ls_sql
//根据sql语句产生数据窗口
ls_sql = sqlca.SyntaxFromSQL(as_sqlselect, 'style(type=grid)',errors)
//sql语句有错误
if len(errors) > 0 then
messagebox('错误1', errors)
return -1
end if
//根据语法动态创建数据窗口
ids.create(ls_sql,errors)
if len(errors) > 0 then
messagebox('错误2', errors)
return -1
end if
ll =ids.settransobject(sqlca)
//messagebox('',string(ll)+sqlca.sqlerrtext)
ll = ids.retrieve()
ll = ids.rowcount()
//messagebox('',string(ll)+sqlca.sqlerrtext+ids.getsqlselect())
//把数据插入控件
for i = 1 to ll
this.additem(string(ids.Object.Data[i,2]))
next
//成功返回0
return ll
end function
event destructor;if isvalid(ids) then
destroy ids
end if