title: C# Bank Account Deposit
body: <p>Hi guys I have this bank account project which displays account info when user selected index. This information includes the current balance that the account has. And then I also has deposit simulation which the amount I deposit should add up to the current balance. I cant figure out why its not doing the work.</p>
  
  <p>I have this code for my selectedindex which pulls up the account info.</p>
  
  <pre><code>private void accountNumComboBox_SelectedIndexChanged(object sender, EventArgs e)
      {
          if (accountNumComboBox.SelectedIndex == 0)
          {
  
  
              ownerIdLabel.Text = "0001";
              balanceLabel.Text = savings1.Balance.ToString("c");
              interestLabel.Text = (string.Format("{0}%", savings1.Interest));
              interestRLabel.Text = "Interest Rate:";
          }
  </code></pre>
  
  <p>And I have this code for the deposit button</p>
  
  <pre><code>    private void depositButton_Click(object sender, EventArgs e)
      {
          decimal amount;
          if (decimal.TryParse(depositTextBox.Text, out amount))
          {
              account.Deposit(amount);
              account.Balance += amount;
              depositTextBox.Clear();
          }
          else
          {
              MessageBox.Show("Pls enter valid amount.");
          }
      }
  </code></pre>
  
  <p>The amount I enter wont add up to the current balance in the balancelabel.Text . Thank you so much for your help.</p>
  
  <p>EDIT: I also got this in my BankAccount class</p>
  
  <pre><code>public decimal Balance
      {
          get { return _balance; }
          set { _balance = value; }
      }
      public BankAccount(decimal intialBalance, string ownerId, string accountNumber)
      {
  
          _balance = intialBalance;
          _customerId = ownerId;
          _accountNumber = accountNumber;
      }
  
  
      public void Deposit(decimal amount)
      {
          if ( amount&gt;0)
          _balance += amount;
          else
              throw new Exception("Credit must be &gt; zero");
      }
      public void Withdraw(decimal amount)
      {
          _balance -= amount;
      }
  </code></pre>