private bool VerifyPriceFields() { bool allPricesFieldsValid = true; foreach (PriceCollector priceCollector in priceCollectorList) { if (String.IsNullOrEmpty(priceCollector.BuyPrice) || String.IsNullOrEmpty(priceCollector.SellPrice)) { priceCollector.PriceInputErrorMessage = "价格不能为空"; allPricesFieldsValid = false; } else if (!InputVerifyService.IsPriceValid(priceCollector.BuyPrice) || !InputVerifyService.IsPriceValid(priceCollector.SellPrice)) { priceCollector.PriceInputErrorMessage = "价格格式有误"; allPricesFieldsValid = false; } else { priceCollector.PriceInputErrorMessage = ""; } } if (buckleItem != null) { if (String.IsNullOrEmpty(buckleItem.BuyPrice) || String.IsNullOrEmpty(buckleItem.SellPrice)) { buckleItem.PriceInputErrorMessage = "价格不能为空"; allPricesFieldsValid = false; } else if (!InputVerifyService.IsPriceValid(buckleItem.BuyPrice) || !InputVerifyService.IsPriceValid(buckleItem.SellPrice)) { buckleItem.PriceInputErrorMessage = "价格格式有误"; allPricesFieldsValid = false; } else { buckleItem.PriceInputErrorMessage = ""; } } return(allPricesFieldsValid); }
/// <summary> /// Verify input fields and give notification if input fields not valid /// </summary> /// <returns>Return true if all fields are valid, false otherwise</returns> private bool VerifyInputFields() { bool inputFieldsValid = true; if (roomComboBox.SelectedItem == null) { roomErrMsgTextblock.Visibility = Visibility.Visible; roomErrMsgTextblock.Text = "房间不能为空"; inputFieldsValid = false; } else { roomErrMsgTextblock.Visibility = Visibility.Hidden; roomErrMsgTextblock.Text = ""; } if (positionComboBox.SelectedItem == null) { positionErrMsgTextblock.Visibility = Visibility.Visible; positionErrMsgTextblock.Text = "位置不能为空"; inputFieldsValid = false; } else { positionErrMsgTextblock.Visibility = Visibility.Hidden; positionErrMsgTextblock.Text = ""; } if (bRadioButton.IsChecked == false && xRadioButton.IsChecked == false) { bOrXErrMsgTextblock.Visibility = Visibility.Visible; bOrXErrMsgTextblock.Text = "板或线不能为空"; inputFieldsValid = false; } else { bOrXErrMsgTextblock.Visibility = Visibility.Hidden; bOrXErrMsgTextblock.Text = ""; } if (productNameComboBox.SelectedItem == null) { productNameErrMsgTextblock.Visibility = Visibility.Visible; productNameErrMsgTextblock.Text = "产品名称不能为空"; inputFieldsValid = false; } else { productNameErrMsgTextblock.Visibility = Visibility.Hidden; productNameErrMsgTextblock.Text = ""; } if (typeTextBox.Text == string.Empty) { typeErrMsgTextblock.Visibility = Visibility.Visible; typeErrMsgTextblock.Text = "规格不能为空"; inputFieldsValid = false; } else if (!InputVerifyService.IsTypeValid(typeTextBox.Text)) { typeErrMsgTextblock.Visibility = Visibility.Visible; typeErrMsgTextblock.Text = "规格格式有误"; inputFieldsValid = false; } else { typeErrMsgTextblock.Visibility = Visibility.Hidden; typeErrMsgTextblock.Text = ""; } if (sizeTextBox.Text == string.Empty) { sizeErrMsgTextblock.Visibility = Visibility.Visible; sizeErrMsgTextblock.Text = "尺寸不能为空"; inputFieldsValid = false; } else if (!InputVerifyService.IsSizeValid(sizeTextBox.Text)) { sizeErrMsgTextblock.Visibility = Visibility.Visible; sizeErrMsgTextblock.Text = "仅允许整数,小数,加号,减号,不含空格"; inputFieldsValid = false; } else { sizeErrMsgTextblock.Visibility = Visibility.Hidden; sizeErrMsgTextblock.Text = ""; } if (unitLengthTextBox.Visibility == Visibility.Visible) { if (unitLengthTextBox.Text == string.Empty) { unitLengthErrMsgTextblock.Visibility = Visibility.Visible; unitLengthErrMsgTextblock.Text = "单片长度不能为空"; inputFieldsValid = false; } else if (!InputVerifyService.IsUnitLengthValid(unitLengthTextBox.Text)) { unitLengthErrMsgTextblock.Visibility = Visibility.Visible; unitLengthErrMsgTextblock.Text = "单片长度格式有误"; inputFieldsValid = false; } else { unitLengthErrMsgTextblock.Visibility = Visibility.Hidden; unitLengthErrMsgTextblock.Text = ""; } } if (applyDirectionComboBox.Visibility == Visibility.Visible) { if (applyDirectionComboBox.SelectedItem == null) { applyDirectionErrMsgTextblock.Visibility = Visibility.Visible; applyDirectionErrMsgTextblock.Text = "铺贴方向不能为空"; inputFieldsValid = false; } else { applyDirectionErrMsgTextblock.Visibility = Visibility.Hidden; applyDirectionErrMsgTextblock.Text = ""; } } return(inputFieldsValid); }