Esempio n. 1
0
        private bool DataIsValid()
        {
            if (string.IsNullOrWhiteSpace(txtLastname.Text))
            {
                MessageDialog.ShowValidationError(txtLastname, "Lastname must NOT be blank.");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(txtFirstname.Text))
            {
                MessageDialog.ShowValidationError(txtFirstname, "Firstname must NOT be blank.");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(cboGender.Text))
            {
                MessageDialog.ShowValidationError(cboGender, "Gender must NOT be blank.");
                return(false);
            }


            if (string.IsNullOrWhiteSpace(cboCountry.Text))
            {
                MessageDialog.ShowValidationError(cboCountry, "Country must NOT be blank.");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(cboProvince.Text))
            {
                MessageDialog.ShowValidationError(cboProvince, "Province must NOT be blank.");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(cboTown.Text))
            {
                MessageDialog.ShowValidationError(cboTown, "Town must NOT be blank.");
                return(false);
            }


            var reader   = new PersonDataReader();
            var findItem = reader.GetItem(txtLastname.Text, txtFirstname.Text, txtMiddlename.Text);

            if (findItem != null && findItem.Id != ItemData.Id)
            {
                var response = MessageDialog.Ask("Create Duplicate Record?",
                                                 string.Format(@"System detected a similar contact with the following details:<br/><br/>
                                                Fullname : <b>{0}</b><br/>
                                                BirthDate: <b>{1}</b>", findItem.Name.Fullname,
                                                               findItem.BirthDate.ToString("yyyy MMMM dd")));

                if (response == MessageDialogResult.No)
                {
                    return(false);
                }
            }

            return(true);
        }