传入实体执行(可添加 修改 删除)事务。 IDbHelper dbHelper = new OracleHelper(ConfigHelper.GetConfigString( BusinessDbConnection )); bool result = true ; try { dbHelper.BeginTransaction(); //主表 TE_AREAManager manager = new TE_AREAManager(
传入实体执行(可添加 修改 删除)事务。
SmartB2B 是一款基于PHP、MySQL、Smarty的B2B行业电子商务网站管理系统,系统提供了供求模型、企业模型、产品模型、人才招聘模型、资讯模型等模块,适用于想在行业里取得领先地位的企业快速假设B2B网站,可以运行于Linux与Windows等多重服务器环境,安装方便,使用灵活。 系统使用当前流行的PHP语言开发,以MySQL为数据库,采用B/S架构,MVC模式开发。融入了模型化、模板
IDbHelper
dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result
= true;
try
{
dbHelper.BeginTransaction();
//主表
TE_AREAManager
manager = new TE_AREAManager(dbHelper,
userInfo);
TE_AREAEntity
tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
manager.Delete(tE_AREAEntity);
//子表
TE_AREA_SUBManager
submanager = new TE_AREA_SUBManager(dbHelper,
userInfo);
TE_AREA_SUBEntity
tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
submanager.Delete(tE_AREA_SUBEntity);
//事务提交
dbHelper.CommitTransaction();
}
catch(Exception
ex)
{
//事务回滚
dbHelper.RollbackTransaction();
result=false;
}
可以传入sql语句执行事务
IDbHelper
dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result
= true;
try
{
dbHelper.BeginTransaction();
string commandText
= "
DELETE FROM TE_AREA WHERE ID=" +
dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(sqlString);
commandText
= "
DELETE FROM TE_AREA_SUB WHERE ID=" +
dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(commandText);
dbHelper.CommitTransaction();
}
catch(Exception
ex)
{
dbHelper.RollbackTransaction();
result=false;
}
还可以同时传入实体,SQL语句
IDbHelper
dbHelper = new OracleHelper(ConfigHelper.GetConfigString("BusinessDbConnection"));
bool result
= true;
try
{
dbHelper.BeginTransaction();
//主表
TE_AREAManager
manager = new TE_AREAManager(dbHelper,
userInfo);
TE_AREAEntity
tE_AREAEntity = manager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
manager.Delete(tE_AREAEntity);
//子表
TE_AREA_SUBManager
submanager = new TE_AREA_SUBManager(dbHelper,
userInfo);
TE_AREA_SUBEntity
tE_AREA_SUBEntity = submanager.GetObject(dbHelper.SqlSafe(eatxtAREA_ID));
submanager.Delete(tE_AREA_SUBEntity);
//执行SQL语句
string commandText
= "
DELETE FROM JINTIANDA WHERE ID=" +
dbHelper.SqlSafe(id);
dbHelper.ExecuteNonQuery(commandText);
//事务提交
dbHelper.CommitTransaction();
}
catch(Exception
ex)
{
//事务回滚
dbHelper.RollbackTransaction();
result=false;
}









