public bool validateSpecificItemAttributes(out object[] elements) { bool valid = true; uiSpecificItemAttributesErrorProvider.Clear(); elements = new object[2]; decimal shoeSize = -1; Shoe.shoeType?shoeType = null; if (string.IsNullOrWhiteSpace(uiShoeSizeUpDown.Text) || !(decimal.TryParse(uiShoeSizeUpDown.Text, out shoeSize)) || shoeSize <= 0) { uiSpecificItemAttributesErrorProvider.SetError(uiShoeSizeUpDown, "Please enter valid shoe size"); uiSpecificItemAttributesErrorProvider.SetIconPadding(uiShoeSizeUpDown, 10); valid = false; } if (uiShoeTypeComboBox.SelectedIndex < 0) { uiSpecificItemAttributesErrorProvider.SetError(uiShoeSizeUpDown, "Please select shoe type"); uiSpecificItemAttributesErrorProvider.SetIconPadding(uiShoeSizeUpDown, 10); valid = false; } else { shoeType = (Shoe.shoeType)uiShoeTypeComboBox.SelectedItem; } elements[0] = shoeSize; elements[1] = (Shoe.shoeType)shoeType; return(valid); }
protected override void addItem() { if (validateSpecificItemAttributes(out object[] elements) && base.validateGeneralItemAttributes()) { this.shoeSize = (decimal)elements[0]; this.shoeType = (Shoe.shoeType)elements[1]; this.DialogResult = DialogResult.OK; this.Close(); } }