/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

  1. /*
  2. * ???????????
  3. *
  4. * 2009-5-31 SZJ
  5. *
  6. *
  7. * */
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Globalization;
  13. using System.Text;
  14. using System.Xml;
  15. using System.Data.Common;
  16. using Microsoft.Practices.EnterpriseLibrary.Data;
  17. using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
  18. //using Microsoft.Practices.EnterpriseLibrary.Logging;
  19. using EQT.Model;
  20. //using IDataLayer;
  21. namespace EQT.Dal
  22. {
  23. public partial class DaRoleFunction
  24. {
  25. internal const string SQL_CLEAR_ROLE_FUNC = "DELETE FROM ROLE_FUNCTIONS WHERE ROLE_ID=@ROLE_ID";
  26. /// <summary>
  27. /// ???????????
  28. /// </summary>
  29. /// <param name="role_id"></param>
  30. /// <returns></returns>
  31. public int ClearRoleFuncs(string role_id)
  32. {
  33. DbCommand cmd_clear_role_funcs = db.GetSqlStringCommand(SQL_CLEAR_ROLE_FUNC);
  34. db.AddInParameter(cmd_clear_role_funcs, "ROLE_ID", DbType.String, role_id);
  35. return db.ExecuteNonQuery(cmd_clear_role_funcs);
  36. }
  37. /// <summary>
  38. /// ??????????.
  39. /// </summary>
  40. /// <param name="role_id"></param>
  41. /// <param name="funcIdArray"></param>
  42. /// <returns></returns>
  43. public int SetRoleFuncs(string role_id, string[] funcIdArray)
  44. {
  45. int rc = 0;
  46. DbCommand cmd_clear_role_funcs = db.GetSqlStringCommand(SQL_CLEAR_ROLE_FUNC);
  47. db.AddInParameter(cmd_clear_role_funcs, "ROLE_ID", DbType.String, role_id);
  48. using (DbConnection conn = db.CreateConnection())
  49. {
  50. conn.Open();
  51. using (DbTransaction trans = conn.BeginTransaction())
  52. {
  53. //?????????
  54. db.ExecuteNonQuery(cmd_clear_role_funcs, trans);
  55. //????????
  56. MoRoleFunction mo = new MoRoleFunction();
  57. mo.Role_Id = role_id;
  58. foreach (string funcId in funcIdArray)
  59. {
  60. mo.Func_Id = funcId;
  61. rc+= Add(mo, trans);
  62. }
  63. trans.Commit();
  64. }
  65. conn.Close();
  66. }
  67. return rc;
  68. }
  69. }
  70. }