diff --git a/Bootstrap.DataAccess/GroupHelper.cs b/Bootstrap.DataAccess/GroupHelper.cs
index dee1b0c8..d3c0ed63 100644
--- a/Bootstrap.DataAccess/GroupHelper.cs
+++ b/Bootstrap.DataAccess/GroupHelper.cs
@@ -59,29 +59,23 @@ namespace Bootstrap.DataAccess
///
public static bool DeleteGroup(string ids)
{
- var ret = false;
+ bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
- using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
+ try
{
- try
+ using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteGroups"))
{
- string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Groups where ID in ({0})", ids);
- sql += string.Format("delete from RoleGroup where GroupID in ({0});", ids);
- sql += string.Format("delete from UserGroup where GroupID in ({0});", ids);
- using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
- {
- DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
- }
- CacheCleanUtility.ClearCache(groupIds: ids);
- ret = true;
+ cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input));
+ DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
- catch (Exception ex)
- {
- ExceptionManager.Publish(ex);
- transaction.RollbackTransaction();
- }
- return ret;
+ CacheCleanUtility.ClearCache(groupIds: ids);
+ ret = true;
}
+ catch (Exception ex)
+ {
+ ExceptionManager.Publish(ex);
+ }
+ return ret;
}
///
/// 保存新建/更新的群组信息
diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs
index 3b441533..53082ed7 100644
--- a/Bootstrap.DataAccess/MenuHelper.cs
+++ b/Bootstrap.DataAccess/MenuHelper.cs
@@ -130,24 +130,19 @@ namespace Bootstrap.DataAccess
{
bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
- using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
+ try
{
- try
+ using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteMenus"))
{
- string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Navigations where ID in ({0})", ids);
- sql += string.Format("delete from NavigationRole where NavigationID in ({0});", ids);
- using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
- {
- DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
- }
- CacheCleanUtility.ClearCache(menuIds: ids);
- ret = true;
- }
- catch (Exception ex)
- {
- ExceptionManager.Publish(ex);
- transaction.RollbackTransaction();
+ cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input));
+ DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
+ CacheCleanUtility.ClearCache(menuIds: ids);
+ ret = true;
+ }
+ catch (Exception ex)
+ {
+ ExceptionManager.Publish(ex);
}
return ret;
}
diff --git a/Bootstrap.DataAccess/RoleHelper.cs b/Bootstrap.DataAccess/RoleHelper.cs
index 4ea35963..290ecebb 100644
--- a/Bootstrap.DataAccess/RoleHelper.cs
+++ b/Bootstrap.DataAccess/RoleHelper.cs
@@ -141,30 +141,23 @@ namespace Bootstrap.DataAccess
/// 删除角色表
///
///
- public static bool DeleteRole(string IDs)
+ public static bool DeleteRole(string ids)
{
bool ret = false;
- if (string.IsNullOrEmpty(IDs) || IDs.Contains("'")) return ret;
- using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
+ if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
+ try
{
- try
+ using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteRoles"))
{
- string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Roles where ID in ({0});", IDs);
- sql += string.Format("delete from UserRole where RoleID in ({0});", IDs);
- sql += string.Format("delete from RoleGroup where RoleID in ({0});", IDs);
- sql += string.Format("delete from NavigationRole where RoleID in ({0});", IDs);
- using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
- {
- DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
- }
- CacheCleanUtility.ClearCache(roleIds: IDs);
- ret = true;
- }
- catch (Exception ex)
- {
- ExceptionManager.Publish(ex);
- transaction.RollbackTransaction();
+ cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input));
+ DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
+ CacheCleanUtility.ClearCache(roleIds: ids);
+ ret = true;
+ }
+ catch (Exception ex)
+ {
+ ExceptionManager.Publish(ex);
}
return ret;
}
diff --git a/DatabaseScripts/Procedures.sql b/DatabaseScripts/Procedures.sql
index 130a8e14..37a29d3b 100644
--- a/DatabaseScripts/Procedures.sql
+++ b/DatabaseScripts/Procedures.sql
@@ -27,3 +27,82 @@ BEGIN
exec(@sql)
END
GO
+
+Drop PROCEDURE Proc_DeleteRoles
+GO
+-- =============================================
+-- Author: LiuChun
+-- Create date: 2016-11-07
+-- Description:
+-- =============================================
+Create PROCEDURE Proc_DeleteRoles
+ -- Add the parameters for the stored procedure here
+ @ids varchar(max)
+ WITH ENCRYPTION
+AS
+BEGIN
+ -- SET NOCOUNT ON added to prevent extra result sets from
+ -- interfering with SELECT statements.
+ SET NOCOUNT ON;
+ SET XACT_ABORT ON;
+ -- Insert statements for procedure here
+ declare @sql varchar(max)
+ set @sql = 'delete from UserRole where RoleID in (' + @ids + ');'
+ set @sql += 'delete from RoleGroup where RoleID in (' + @ids + ');'
+ set @sql += 'delete from NavigationRole where RoleID in (' + @ids + ');'
+ set @sql += 'delete from Roles where ID in (' + @ids + ');'
+ exec(@sql)
+END
+GO
+
+
+Drop PROCEDURE Proc_DeleteGroups
+GO
+-- =============================================
+-- Author: LiuChun
+-- Create date: 2016-11-07
+-- Description:
+-- =============================================
+Create PROCEDURE Proc_DeleteGroups
+ -- Add the parameters for the stored procedure here
+ @ids varchar(max)
+ WITH ENCRYPTION
+AS
+BEGIN
+ -- SET NOCOUNT ON added to prevent extra result sets from
+ -- interfering with SELECT statements.
+ SET NOCOUNT ON;
+ SET XACT_ABORT ON;
+ -- Insert statements for procedure here
+ declare @sql varchar(max)
+ set @sql = 'delete from UserGroup where GroupID in (' + @ids + ');'
+ set @sql += 'delete from RoleGroup where GroupID in (' + @ids + ');'
+ set @sql += 'delete from Groups where ID in (' + @ids + ');'
+ exec(@sql)
+END
+GO
+
+Drop PROCEDURE Proc_DeleteMenus
+GO
+-- =============================================
+-- Author: LiuChun
+-- Create date: 2016-11-07
+-- Description:
+-- =============================================
+Create PROCEDURE Proc_DeleteMenus
+ -- Add the parameters for the stored procedure here
+ @ids varchar(max)
+ WITH ENCRYPTION
+AS
+BEGIN
+ -- SET NOCOUNT ON added to prevent extra result sets from
+ -- interfering with SELECT statements.
+ SET NOCOUNT ON;
+ SET XACT_ABORT ON;
+ -- Insert statements for procedure here
+ declare @sql varchar(max)
+ set @sql = 'delete from NavigationRole where NavigationID in (' + @ids + ');'
+ set @sql += 'delete from Navigations where ID in (' + @ids + ');'
+ exec(@sql)
+END
+GO
\ No newline at end of file