private void NationalIDBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { int id; if (txtNationalIDBox.Text == "") { ErrorProvider.SetError(txtNationalIDBox, "you must enter nationalID"); } else if (!int.TryParse(txtNationalIDBox.Text, out id)) { ErrorProvider.SetError(txtNationalIDBox, "NationalID must be a numeric"); } else if (Convert.ToInt32(txtNationalIDBox.Text) < 1 || Convert.ToInt32(txtNationalIDBox.Text) > 1000000) { ErrorProvider.SetError(txtNationalIDBox, "Valid values within 1-1000000000"); } else if ((newEmployee.ExistNationalID(id) == 1 && id != newEmployee.NationalID && !addNewEmployee) || (addNewEmployee && newEmployee.ExistNationalID(id) == 1)) { ErrorProvider.SetError(txtNationalIDBox, "NationalID is related to other employee"); } else { ErrorProvider.SetError(txtNationalIDBox, ""); CorrectProvider.SetError(txtNationalIDBox, "Valid nationalID"); } }
private void BirthDatePicker_Validating(object sender, System.ComponentModel.CancelEventArgs e) { DateTime BoD = BirthDatePicker.Value.Date; DateTime date = DateTime.Now.Date; if (date.Year - BoD.Year < 18) { ErrorProvider.SetError(BirthDatePicker, "Age must be greater than or equal 18"); } else { ErrorProvider.SetError(BirthDatePicker, ""); CorrectProvider.SetError(BirthDatePicker, "Valid age"); } }
private void NameBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (txtNameBox.Text == "") { ErrorProvider.SetError(txtNameBox, "You must enter name"); } else if (txtNameBox.Text.Length > 100) { ErrorProvider.SetError(txtNameBox, "Name length must be less than 100 characters"); } else { ErrorProvider.SetError(txtNameBox, ""); CorrectProvider.SetError(txtNameBox, "Valid name"); } }
private void WeightBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { double weight; if (txtWeightBox.Text == "") { ErrorProvider.SetError(txtWeightBox, "Fill the weight"); } else if (!Double.TryParse(txtWeightBox.Text, out weight)) { ErrorProvider.SetError(txtWeightBox, "Must be a numeric"); } else if (Convert.ToInt32(txtWeightBox.Text) < 1 || Convert.ToInt32(txtWeightBox.Text) > 400) { ErrorProvider.SetError(txtWeightBox, "Valid values 1-400"); } else { ErrorProvider.SetError(txtWeightBox, ""); CorrectProvider.SetError(txtWeightBox, "Valid weight"); } }