示例#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);
        }
示例#2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var id = 0;

            if (!int.TryParse(txtIdNum.Text, out id))
            {
                MessageDialog.ShowValidationError(txtIdNum, "You have entered an Invalid Id");
                return;
            }


            var reader = new PersonDataReader();
            var item   = reader.GetItem(id);

            if (item == null)
            {
                MessageDialog.ShowValidationError(txtIdNum, "You have entered an Invalid Id");
                return;
            }

            ItemData = item;

            DialogResult = DialogResult.OK;
        }