PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

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