AutoThrCode 三层结构业务层代码自动生成工具
2024-07-21 02:23:23
供稿:网友
请看下面示例:
数据表结构如下:
生成的 属性成员 和 添加,更新的代码:
'autothrcode自动生成三层结构业务逻辑层代码
'isdotnet 版权所有
'作者:梦虫
'msn:[email protected]
'http://www.isdotnet.com
'本代码引用 isdotnet.data.sqldbhelper 类,请将 adohelper.dll 拷贝到web程序的bin目录下
'请在web程序的web.config文件的节配置数据库连接字符串,"connectionstring" value="server=(local); database=databasename; user id=sa; password=sa;" />
imports system
imports system.data
imports system.data.sqlclient
class dbshippers
'属性成员errmsg
private _errmsg as string
public property [errmsg] as string
get
return me._errmsg
end get
set(byval value as string)
me._errmsg = value
end set
end property
'属性成员:shipperid
private intshipperid as integer
public property [shipperid] as integer
get
return me.intshipperid
end get
set(byval value as integer )
me.intshipperid = value
end set
end property
'属性成员:companyname
private strcompanyname as string
public property [companyname] as string
get
return me.strcompanyname
end get
set(byval value as string )
me.strcompanyname = value
end set
end property
'属性成员:phone
private strphone as string
public property [phone] as string
get
return me.strphone
end get
set(byval value as string )
me.strphone = value
end set
end property
'添加
public function shippers_insert() as boolean
dim db as new isdotnet.data.sqldbhelper
dim strsql as string = "insert into [shippers] ([companyname],[phone]) values (@companyname,@phone)"
dim param() as sqlparameter = { _
db.makeinparam("@companyname", sqldbtype.nvarchar, 40, me.strcompanyname) , _
db.makeinparam("@phone", sqldbtype.nvarchar, 24, me.strphone) _
}
if db.execute(strsql,param) then
return true
else
me._errmsg = db.errmsg
return false
end if
end function
'更新
public function shippers_update() as boolean
dim db as new isdotnet.data.sqldbhelper
dim strsql as string = "update [shippers] set [companyname][email protected],[phone][email protected] where [shipperid][email protected]"
dim param() as sqlparameter = { _
db.makeinparam("@companyname", sqldbtype.nvarchar, 40, me.strcompanyname) , _
db.makeinparam("@phone", sqldbtype.nvarchar, 24, me.strphone) , _
db.makeinparam("@shipperid", sqldbtype.int, 0, me.intshipperid) _
}
if db.execute(strsql, param) then
return true
else
me.errmsg = db.errmsg
return false
end if
end function
end class
此程序部分界面截屏