///<summary> ///Reads the price the user has put in the "txtPrice" textbox and handles it. ///</summary> private bool ReadAndValidatePrice() { if (!InputUtility.GetPositiveDouble(txtPrice.Text, out price)) { MessageBox.Show("Invalid input in the price field! Price cannot be empty," + Environment.NewLine + "it must have at least one digit (not blank), and it has" + Environment.NewLine + "to be a value above 0 and below 1000. ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice.Focus(); txtPrice.Text = "0.0"; txtPrice.SelectAll(); return(false); } else { return(true); } }
///<summary> ///Reads the name the user has put in the "txtName" textbox and handles it. ///</summary> private bool ReadAndValidateName() { name = txtName.Text; if (!InputUtility.ValidateString(name)) { MessageBox.Show("Invalid input in the name field! Name cannot be empty," + Environment.NewLine + "and must have at least one character (not blank)", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtName.Focus(); txtName.Text = " "; txtName.SelectAll(); return(false); } else { return(true); } }