/// <summary> /// Validating the textbox trade-in allowance /// </summary> void txtTradeinAllowance_Validating(object sender, CancelEventArgs e) { string errorMessage = string.Empty; if (!AutomotiveManager.IsNumeric(txtTradeinAllowance.Text)) { errorMessage = "Please enter a numeric value."; txtTradeinAllowance.Focus(); } else if (decimal.Parse(txtTradeinAllowance.Text) < 0) { errorMessage = "Please enter a value greater than or equal to zero."; txtTradeinAllowance.Focus(); } if (errorMessage != string.Empty) { e.Cancel = true; errorProvider.SetError(txtTradeinAllowance, errorMessage); } }
/// <summary> /// Handles the validating of the txtCost /// </summary> void txtCost_Validating(object sender, CancelEventArgs e) { string errorMessage = string.Empty; if (!AutomotiveManager.IsNumeric(txtCost.Text)) { errorMessage = "Please enter a numeric value."; } else if (decimal.Parse(txtCost.Text) <= 0) { errorMessage = "Please enter a value greater than zero."; } if (errorMessage != string.Empty) { e.Cancel = true; errorProvider.SetError(txtCost, errorMessage); txtCost.Focus(); txtCost.SelectAll(); } }
/// <summary> /// Validating the textbox vehicle sale price /// </summary> void txtVehicleSalePrice_Validating(object sender, CancelEventArgs e) { txtVehicleSalePrice.Text = txtVehicleSalePrice.Text.Trim(); string errorMessage = string.Empty; if (!AutomotiveManager.IsNumeric(txtVehicleSalePrice.Text)) { errorMessage = "Please enter a numeric value."; txtVehicleSalePrice.Focus(); } else if (decimal.Parse(txtVehicleSalePrice.Text) <= 0) { errorMessage = "Please enter a value greater than zero."; txtVehicleSalePrice.Focus(); } if (!errorMessage.Equals(string.Empty)) { e.Cancel = true; errorProvider.SetError(txtVehicleSalePrice, errorMessage); } }