public bool ReadDate(out Date dateValue, TValueRequired valueRequiredDirective) { bool valueOk = true; dateValue = null; if (this.Text != "") { try { dateValue = Date.Parse(this.Text); } catch (Exception exception) { valueOk = false; MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Question); this.Select(); } } else if (valueRequiredDirective == TValueRequired.ValueRequired) { valueOk = false; MessageBox.Show("Must enter a value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question); this.Select(); } return(valueOk); }
public bool ReadString(out string stringValue, TValueRequired valueRequiredDirective) { bool valueOk = true; int numOfSpaces = 0; string message = ""; if ((stringValue = this.Text) == "" && valueRequiredDirective == TValueRequired.ValueRequired) { message = "Must enter a value"; valueOk = false; } if (valueOk) { for (int i = 0; i < stringValue.Length; i++) { if (stringValue[i] == ' ') { numOfSpaces++; } } if (numOfSpaces == stringValue.Length && valueRequiredDirective == TValueRequired.ValueRequired) { message = "Must enter at least one non-space character in value"; valueOk = false; } } if (!valueOk) { MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Question); this.Select(); } return(valueOk); }
public bool ReadString(out string stringValue, TValueRequired valueRequiredDirective) { bool valueOk=true; int numOfSpaces = 0; string message=""; if ((stringValue = this.Text)=="" && valueRequiredDirective==TValueRequired.ValueRequired) { message = "Must enter a value"; valueOk = false; } if (valueOk) { for(int i=0; i<stringValue.Length; i++) if (stringValue[i]==' ') numOfSpaces++; if (numOfSpaces==stringValue.Length && valueRequiredDirective==TValueRequired.ValueRequired) { message = "Must enter at least one non-space character in value"; valueOk = false; } } if (! valueOk) { MessageBox.Show(message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Question); this.Select(); } return valueOk; }
public bool ReadDate(out Date dateValue, TValueRequired valueRequiredDirective) { bool valueOk = true; dateValue = null; if (this.Text!="") { try { dateValue = Date.Parse(this.Text); } catch (Exception exception) { valueOk = false; MessageBox.Show(exception.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Question); this.Select(); } } else if (valueRequiredDirective==TValueRequired.ValueRequired) { valueOk = false; MessageBox.Show("Must enter a value","Error",MessageBoxButtons.OK,MessageBoxIcon.Question); this.Select(); } return valueOk; }