예제 #1
0
        /**
         * 刪除角色存取項目資料檔
         **/
        public int Delete(CODE_ROLE_ITEM roleItem, SqlConnection conn, SqlTransaction transaction)
        {
            string     sql     = @"delete CODE_ROLE_ITEM
        where 1=1
        and ROLE_ID = @ROLE_ID and ITEM_ID = @ITEM_ID and AUTH_TYPE = @AUTH_TYPE
        ";
            SqlCommand command = conn.CreateCommand();

            command.Connection  = conn;
            command.Transaction = transaction;

            try
            {
                command.CommandText = sql;
                command.Parameters.AddWithValue("@ROLE_ID", StringUtil.toString(roleItem.ROLE_ID));
                command.Parameters.AddWithValue("@ITEM_ID", StringUtil.toString(roleItem.ITEM_ID));
                command.Parameters.AddWithValue("@AUTH_TYPE", StringUtil.toString(roleItem.AUTH_TYPE));

                int cnt = command.ExecuteNonQuery();

                return(cnt);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        /// <summary>
        /// 新增角色存取項目資料
        /// </summary>
        /// <param name="roleFunc"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public int Insert(CODE_ROLE_ITEM roleItem, SqlConnection conn, SqlTransaction transaction)
        {
            string     sql     = @"insert into CODE_ROLE_ITEM
        (ROLE_ID, ITEM_ID, AUTH_TYPE, LAST_UPDATE_UID, LAST_UPDATE_DT)
        values (@ROLE_ID, @ITEM_ID, @AUTH_TYPE, @LAST_UPDATE_UID, @LAST_UPDATE_DT)
        ";
            SqlCommand command = conn.CreateCommand();

            command.Connection  = conn;
            command.Transaction = transaction;

            try
            {
                command.CommandText = sql;
                command.Parameters.AddWithValue("@ROLE_ID", StringUtil.toString(roleItem.ROLE_ID));
                command.Parameters.AddWithValue("@ITEM_ID", StringUtil.toString(roleItem.ITEM_ID));
                command.Parameters.AddWithValue("@AUTH_TYPE", StringUtil.toString(roleItem.AUTH_TYPE));
                command.Parameters.AddWithValue("@LAST_UPDATE_UID", StringUtil.toString(roleItem.LAST_UPDATE_UID));
                command.Parameters.AddWithValue("@LAST_UPDATE_DT", DateTime.Now);

                int cnt = command.ExecuteNonQuery();

                return(cnt);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        /// <summary>
        /// 處理角色存取項目異動
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="aplyNO"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        private void procRoleItemHis(string roleId, string aplyNo, SqlConnection conn, SqlTransaction transaction)
        {
            CodeRoleItemHisDao       codeRoleItemHisDao = new CodeRoleItemHisDao();
            List <CodeRoleItemModel> cRoleItemList      = codeRoleItemHisDao.qryByAplyNo(aplyNo, "");

            if (cRoleItemList != null)
            {
                if (cRoleItemList.Count > 0)
                {
                    CodeRoleItemDao codeRoleItemDao = new CodeRoleItemDao();

                    foreach (CodeRoleItemModel d in cRoleItemList)
                    {
                        CODE_ROLE_ITEM dItem = new CODE_ROLE_ITEM();
                        Log            log   = new Log();

                        switch (d.execAction)
                        {
                        case "A":
                            dItem.ROLE_ID         = roleId;
                            dItem.ITEM_ID         = d.itemId;
                            dItem.AUTH_TYPE       = d.authType;
                            dItem.LAST_UPDATE_UID = Session["UserID"].ToString();
                            dItem.LAST_UPDATE_DT  = DateTime.Now;


                            //新增資料
                            codeRoleItemDao.Insert(dItem, conn, transaction);


                            //新增LOG
                            log.CFUNCTION = "角色管理(存取項目)-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = codeRoleItemDao.logContent(dItem);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            break;

                        case "D":
                            dItem = codeRoleItemDao.getRoleItemByKey(roleId, d.itemId, d.authType);

                            //新增LOG
                            log.CFUNCTION = "角色管理(存取項目)-刪除";
                            log.CACTION   = "D";
                            log.CCONTENT  = codeRoleItemDao.logContent(dItem);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //刪除資料
                            codeRoleItemDao.Delete(dItem, conn, transaction);

                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
예제 #4
0
        /**
         * 將角色存取項目資料檔的各欄位組成一字串,for Log
         **/
        public String logContent(CODE_ROLE_ITEM roleItem)
        {
            String content = "";

            content += StringUtil.toString(roleItem.ROLE_ID) + '|';
            content += StringUtil.toString(roleItem.ITEM_ID) + '|';
            content += StringUtil.toString(roleItem.AUTH_TYPE) + '|';
            content += StringUtil.toString(roleItem.LAST_UPDATE_UID) + '|';
            content += roleItem.LAST_UPDATE_DT;

            return(content);
        }
예제 #5
0
        public CODE_ROLE_ITEM getRoleItemByKey(string roleId, string itemId, string authType)
        {
            using (new TransactionScope(
                       TransactionScopeOption.Required,
                       new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadUncommitted
            }))
            {
                using (dbTreasuryEntities db = new dbTreasuryEntities())
                {
                    CODE_ROLE_ITEM roleItem = db.CODE_ROLE_ITEM.Where(x => x.ROLE_ID == roleId &&
                                                                      x.ITEM_ID == itemId && x.AUTH_TYPE == authType).FirstOrDefault();

                    return(roleItem);
                }
            }
        }