private void DescuentoTxt_Leave(object sender, EventArgs e) { if (!PrincipalFrm.ValidarNumero(DescuentoTxt.Text)) { DescuentoTxt.Focus(); DescuentoTxt.BackColor = System.Drawing.Color.IndianRed; this._val = false; } else { DescuentoTxt.BackColor = System.Drawing.Color.White; this._val = true; } }
private void DescuentoTxt_TextChanged(object sender, EventArgs e) { if (!(this.PrecioFinalLbl.Text != "") || !this.flagProduct) { return; } double num1 = Convert.ToDouble(this.PrecioLbl.Text.Substring(1, this.PrecioLbl.Text.Length - 2)); this.DescuentoTxt.Text.IndexOf('%'); if (this.DescuentoTxt.Text.IndexOf('%') == -1 && this.DescuentoTxt.Text != "") { double num2 = Convert.ToDouble(this.DescuentoTxt.Text); double num3 = num1 - num2; PrecioFinalLbl.Text = "= $" + num3.ToString("n2"); } else if (this.DescuentoTxt.Text.IndexOf('%') > -1 && this.DescuentoTxt.Text != "") { int num2 = (int)this.DescuentoTxt.Text.Last <char>(); double num3 = 0; try { num3 = Convert.ToDouble(this.DescuentoTxt.Text.Substring(0, this.DescuentoTxt.Text.Length - 1)); } catch (FormatException) { DescuentoTxt.Text = "0%"; DescuentoTxt.SelectAll(); num3 = Convert.ToDouble(this.DescuentoTxt.Text.Substring(0, this.DescuentoTxt.Text.Length - 1)); } double num4 = num1 / 100.0 * num3; this.PrecioFinalLbl.Text = "= $" + (num1 - num4).ToString("n2"); } else { if (!(this.DescuentoTxt.Text == "")) { return; } this.PrecioFinalLbl.Text = "= $" + num1.ToString("n2"); } }