/EQT_V1/EQT.DAL/DaRoleFunction.cs
http://sgsoft-las.googlecode.com/ · C# · 79 lines · 48 code · 9 blank · 22 comment · 0 complexity · 03d36c1822cbc94eb3d7792708c82595 MD5 · raw file
- /*
- * ???????????
- *
- * 2009-5-31 SZJ
- *
- *
- * */
-
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Globalization;
- using System.Text;
- using System.Xml;
- using System.Data.Common;
- using Microsoft.Practices.EnterpriseLibrary.Data;
- using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
- //using Microsoft.Practices.EnterpriseLibrary.Logging;
- using EQT.Model;
- //using IDataLayer;
-
- namespace EQT.Dal
- {
- public partial class DaRoleFunction
- {
- internal const string SQL_CLEAR_ROLE_FUNC = "DELETE FROM ROLE_FUNCTIONS WHERE ROLE_ID=@ROLE_ID";
-
- /// <summary>
- /// ???????????
- /// </summary>
- /// <param name="role_id"></param>
- /// <returns></returns>
- public int ClearRoleFuncs(string role_id)
- {
- DbCommand cmd_clear_role_funcs = db.GetSqlStringCommand(SQL_CLEAR_ROLE_FUNC);
- db.AddInParameter(cmd_clear_role_funcs, "ROLE_ID", DbType.String, role_id);
- return db.ExecuteNonQuery(cmd_clear_role_funcs);
- }
-
-
- /// <summary>
- /// ??????????.
- /// </summary>
- /// <param name="role_id"></param>
- /// <param name="funcIdArray"></param>
- /// <returns></returns>
- public int SetRoleFuncs(string role_id, string[] funcIdArray)
- {
- int rc = 0;
- DbCommand cmd_clear_role_funcs = db.GetSqlStringCommand(SQL_CLEAR_ROLE_FUNC);
- db.AddInParameter(cmd_clear_role_funcs, "ROLE_ID", DbType.String, role_id);
-
- using (DbConnection conn = db.CreateConnection())
- {
- conn.Open();
- using (DbTransaction trans = conn.BeginTransaction())
- {
- //?????????
- db.ExecuteNonQuery(cmd_clear_role_funcs, trans);
-
- //????????
- MoRoleFunction mo = new MoRoleFunction();
- mo.Role_Id = role_id;
- foreach (string funcId in funcIdArray)
- {
- mo.Func_Id = funcId;
- rc+= Add(mo, trans);
- }
-
- trans.Commit();
- }
- conn.Close();
-
- }
- return rc;
- }
- }
- }