Ejemplo n.º 1
0
        private void Send_Click(object sender, RoutedEventArgs e)
        {
            var currentYear = DateTime.Now.Year;

            if (ageText.Text.Equals(String.Empty) == false)
            {
                birthYear = currentYear - Int32.Parse(ageText.Text.Trim());
            }

            bool passed     = Validation();
            bool checkEmpty = SharedFunctions.CheckEmptyOnly(this);

            if (!checkEmpty) //First validation
            {
                if (passed)  //Second validation
                {
                    toFind = new DonorDetail
                    {
                        Gender    = genderText.Text.Trim(),
                        Ethnicity = ethnicityText.Text.Trim(),
                        BloodType = bloodTypeText.Text.Trim(),
                        RHFactor  = rhFactorText.Text.Trim()
                    };

                    using (var context = new UserRegistrationDBEntities())
                    {
                        bool      start          = false;
                        Boolean[] similarRecords = null;
                        var       records        = context.DonorDetails;
                        foreach (var record in records)
                        {
                            if (!start)
                            {
                                similarRecords = CheckForMatch(record);
                                if (similarRecords == null)
                                {
                                    continue;
                                }
                                start = true;
                            }
                            GetAllMatches(similarRecords, record);
                            if (searchType.Equals("exact"))
                            {
                                break;
                            }
                        }
                        ChangeSearchStatus(true);
                        SharedFunctions.ViewAllRecords(this);
                    }
                }
            }
            else
            {
                MessageBox.Show($"No search data added");
            }
        }