title: Calculate discount price
body: <p>I want to make my application to calculate a discount price. This is how I find my discount price, but I have a little problem (logic problem):</p>
  
  <pre><code>private void UpdateDiscount(object sender, EventArgs e)
  {
      decimal actualPrice = 0;
      decimal discount = 0;
      int calculateDiscount = 0;
      int totalDiscount = 0;
      int afterDiscount = 0;
      int totalAfterDiscount = 0;
      int total = 0;
  
      if (numericTextBox1.TextLength == 6)
      {
          this.numericUpDown2.Enabled = true;
  
          discount = Convert.ToInt32(this.numericUpDown2.Value);
  
          calculateDiscount = Convert.ToInt32(discount / 100);
  
          totalDiscount = calculateDiscount;
  
          if (!string.IsNullOrEmpty(this.numericTextBox3.Text.ToString()))
          {
              actualPrice = Convert.ToDecimal(this.numericTextBox3.Text);
          }
  
          else
          {
              numericTextBox3.Text = "";
          }
  
          afterDiscount = Convert.ToInt32(actualPrice * totalDiscount);
          totalAfterDiscount = Convert.ToInt32(actualPrice);
          total = Convert.ToInt32(totalAfterDiscount - afterDiscount);
  
          if (numericUpDown2.Value &gt; 0)
          {
              this.numericTextBox6.Text = total.ToString();
          }
      }
  
      else if (numericTextBox1.TextLength != 6)
      {
          this.numericUpDown2.Enabled = false;
  
          this.numericUpDown2.Value = 0;
          this.numericTextBox6.Text = "";
      }
  
      else
      {
          actualPrice = 0;
          discount = 0;
          calculateDiscount = 0;
          totalDiscount = 0;
          afterDiscount = 0;
          totalAfterDiscount = 0;
          total = 0;
  
          MessageBox.Show("There is no data based on your selection", "Error");
      }
  }
  </code></pre>
  
  <p>This is the result, the total after discount still same with the total price, even though I already give it discount value.</p>
  
  <p><img src="https://i.stack.imgur.com/OmbYw.png" alt="enter image description here"></p>