/// <summary> /// 添加角色信息 /// </summary> /// <param name="roles"></param> /// <returns></returns> public string AddRole(Roles roles) { sbString.Clear(); try { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@RoleName",roles.RoleName), new SqlParameter("@RoleDescription",roles.RoleDescription), new SqlParameter("@RoleId",roles.RoleID){ Direction=ParameterDirection.Output} }; SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_InsertRole", parameter); return parameter[2].Value.ToString(); } catch (SqlException) { return ""; } }
partial void InsertRoles(Roles instance);
partial void DeleteRoles(Roles instance);
partial void UpdateRoles(Roles instance);
/// <summary> /// 更新角色信息 /// </summary> /// <param name="roles"></param> /// <returns></returns> public bool UpdateRole(Roles roles) { sbString.Clear(); try { sbString.Append("update Roles set RoleName=@RoleName,RoleDescription=@RoleDescription where RoleID=@RoleID"); SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@RoleName",roles.RoleName), new SqlParameter("@RoleDescription",roles.RoleDescription), new SqlParameter("@RoleID",roles.RoleID) }; SqlHelper.ExecuteNonQuery(CommandType.Text, sbString.ToString(), parameter); } catch (SqlException) { return false; } return true; }