public bool CheckValidFields() { if (FieldValidation.IsValidDecimalNumericField(textBoxBudget.Text) == false) { MessageBox.Show("Invalid value typed for budget! Type another!"); return(false); } if (FieldValidation.IsValidFloatNumericField(textBoxWallsHeight.Text) == false) { MessageBox.Show("Invalid value typed for walls height! Type another!"); return(false); } if (FieldValidation.IsValidLongNumericField(textBoxTelephoneNumber.Text) == false) { MessageBox.Show("Invalid value typed for telephone number! Type another!"); return(false); } if (FieldValidation.IsValidEmail(textBoxEmailAddress.Text) == false) { MessageBox.Show("Invalid value typed for email! Type another!"); return(false); } return(true); }
private void btnAddToScene_Click(object sender, RoutedEventArgs e) { if (checkBoxIsSuspendable.IsChecked == true) { if (textBoxChosenHeight.Text.Length == 0 || Convert.ToSingle(textBoxChosenHeight.Text) == 0) { MessageBox.Show("Type a height for the suspended object!"); return; } if (FieldValidation.IsValidFloatNumericField(textBoxChosenHeight.Text) == false) { MessageBox.Show("Invalid value typed for walls height! Type another!"); return; } else { ChosenHeight = Convert.ToSingle(textBoxChosenHeight.Text); if (SelectedObject.Height + ChosenHeight * scaleFactor > sceneHeight) { MessageBox.Show("The chosen height is invalid! Type another!"); return; } } } SelectedObject.Price = Convert.ToDecimal(textBlockTotalPrice.Text); if (actualPrice + SelectedObject.Price > projectBudget) { MessageBox.Show("The object can't be added! You are exceeding the budget!"); addPermission = false; return; } if (SelectedObject.Height > sceneHeight) { MessageBox.Show("The object can't be added! Its height is exceeding the walls height!"); return; } SelectedObject.Translate = new Point3d(SelectedObject.Translate.X, ChosenHeight * realHeightScaleFactor * 50, SelectedObject.Translate.Z); //InitializeSelectedObjectMaterials(); SelectedObject.SetMaterials(selectedObjectMaterials); SelectedObject.MaterialsPrice = Convert.ToDecimal(textBlockMaterialsPrice.Text); if (ChosenHeight * realHeightScaleFactor * 50 > 0) { SelectedObject.IsSuspendable = true; } this.Close(); }