How to change UI button of a particular gameobject to another UI button

Hi, I am having a problem and that is I want the buy button change to equip button if in game currency purchase went successfully of the particular item that player bought. I have 2 buttons buyButton and equipButton I want buybutton to disable and equipButton after a successful purchase of a particular item. Here is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.EventSystems;

public class shop : MonoBehaviour
{
public TMPro.TextMeshProUGUI scoreText;
public GameObject Item1;
public GameObject Item2;
public GameObject Item3;
public GameObject Item4;
public TMPro.TextMeshProUGUI notenough;
public TMPro.TextMeshProUGUI notenough1;
public TMPro.TextMeshProUGUI notenough2;
public TMPro.TextMeshProUGUI notenough3;
public GameObject buyButton;
public GameObject equipButton;
public float sec = 14f;

 private Dictionary<GameObject, float> ItemPrices;


void Start ()
{
    scoreText.text = "Score : " + ((int)PlayerPrefs.GetFloat ("Highscore")).ToString();

  ItemPrices = new Dictionary<GameObject, float>()
  {
   { Item1, 50f },
   { Item2, 80f },
   {Item3, 3500f},
   { Item4, 5000f },
   };
   notenough.enabled = false;
   notenough1.enabled = false;
   notenough2.enabled = false;
   notenough3.enabled = false;
}

public void PurchaseItem(GameObject Item)

{
foreach(KeyValuePair<GameObject, float> item in ItemPrices)
{
if (item.Key == Item)
{

         float price = item.Value;
         float val = PlayerPrefs.GetFloat ("Highscore"); 
         if(val >= price)
         {
         val -= item.Value;
          PlayerPrefs.SetFloat("Highscore", val);
          scoreText.text = "Score : " + ((int)PlayerPrefs.GetFloat ("Highscore")).ToString();
         /* if(item.Key == Item)
          {
              buyButton.SetActive(false);
              equipButton.SetActive(true);
          }*/
             // Take away the cost of the item from the player's currency
             //PlayerPrefs.GetFloat ("Highscore") -= item.Value;
         }
         else
         {
             Debug.Log("not enough money");
              notenough.enabled = true;
              notenough1.enabled = true;
              notenough2.enabled = true;
              notenough3.enabled = true;
             Invoke("noen", 2);
         }
        }     
   }

}

/*public void buy()
{

  if (val >= price)
  {
    PurchaseItem();
  }
  else
  {
    
  }*/

public void noen()
{
notenough.enabled = false;
notenough1.enabled = false;
notenough2.enabled = false;
notenough3.enabled = false;

}

}

You don’t need the foreach(), just use float price = ItemPrices[Item] to get the price.
Then your if() statement just checks one item price and not all of them.
Also no need to check key == Item since the Item was used as the Key to get the price.
I think the foreach() is what’s causing the problem. Double check your logic flow.

@CmdrZin Thanks but my problem is not that. I have 4 items each of them have 4 active buy buttons and 4 disabled equip buttons and they all have their own panels . I referenced all the 4 equip and buy button in the script now. But how will my script check which product the player bought and then disable the buy button and activate equip button if the purchase went successfully?