private bool IsFormComplete() { if ((!string.IsNullOrEmpty(Title)) && (!string.IsNullOrEmpty(Director)) && (!string.IsNullOrEmpty(Year)) && (!string.IsNullOrEmpty(Description)) && IsFileSelected()) { // Validate form values if (Year.Contains("-")) { SetMessage("Year is invalid.", ERROR_COLOR); return(false); } if (!Int32.TryParse(Year, out _yearInt)) { SetMessage("Year is invalid.", ERROR_COLOR); return(false); } if ((_yearInt < 1888) || (_yearInt > DateTime.Now.Year)) { SetMessage("We only rent movies that are currently released. Please check the date.", ERROR_COLOR); return(false); } if (Price.Contains("-")) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } if (!(Price.Length == 4)) { SetMessage("Price must be in format \"x.xx\".", ERROR_COLOR); return(false); } if (!Price.Contains(".") || !Price.Substring(1, 1).Contains(".")) { SetMessage("Price must be in format \"x.xx\".", ERROR_COLOR); return(false); } if (!Decimal.TryParse(Price, out _priceDecimal)) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } if (!(_priceDecimal > 0)) { SetMessage("Price is invalid.", ERROR_COLOR); return(false); } return(true); } else { SetMessage(ERROR, ERROR_COLOR); return(false); } }