Esempio n. 1
0
        /// <summary>
        /// 新增或更新用户角色信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static bool AddOrUpdateUserRoleInfo(UserRole info, EnumAddOrUpdate mode)
        {
            bool           ret   = false;
            IDbConnection  conn  = null;
            IDbCommand     cmd   = null;
            IDbTransaction trans = null;

            try
            {
                IUserRole dp = DataProvider.DbUserRoleDP;
                conn = DbConnOperation.CreateMySqlConnection();
                cmd  = conn.CreateCommand();
                conn.Open();
                trans           = conn.BeginTransaction();
                cmd.Transaction = trans;
                ret             = dp.AddOrUpdateUserRoleInfo(cmd, info, mode);
                trans.Commit();
            }
            catch (Exception ex)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                log.Error(string.Format("AddOrUpdateUserRoleInfo()出错,错误信息如下:{0}", ex.Message));
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(ret);
        }