Example #1
0
        /// <summary>
        /// 新增一批数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns></returns>
        public int Add(RoleModuleEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"Insert into RoleModule(RoleID,Remark,ModuleID) Values");
            strSql.Append("(@RoleID,@Remark,@ModuleID)");
            SqlParameter[] param =
            {
                new SqlParameter("@RoleID",   model.RoleID),
                new SqlParameter("@Remark",   model.Remark),
                new SqlParameter("@ModuleID", model.ModuleID)
            };

            try
            {
                int result = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), param);
                if (result > 0)
                {
                    return(result);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 /// <summary>
 /// 添加一批数据
 /// </summary>
 /// <param name="roleId">角色ID</param>
 /// <param name="moduleIDs">模块ID</param>
 /// <returns></returns>
 public void Add(int roleId, List <int> moduleIDs)
 {
     try
     {
         DeleteRoleModule(roleId);
         List <RoleModuleEntity> list = new List <RoleModuleEntity>();
         foreach (int item in moduleIDs)
         {
             RoleModuleEntity model = new RoleModuleEntity();
             model.RoleID   = roleId;
             model.ModuleID = item;
             list.Add(model);
         }
         foreach (RoleModuleEntity entity in list)
         {
             Add(entity);
         }
         cleanDeathData();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }