Exemple #1
0
        public Boolean[] CheckForMatch(DonorDetail aDonor)
        {
            List <string> temp = DbToCustomObject(aDonor);

            Boolean[] isFound = UserSearchMatchRecord(temp);

/*            //When user fails validation
 *          if (isFound ==null)
 *              return null;*/

            //If no match at all of current record to user input
            int allFalse = isFound.Where(x => x == false).Count();

            if (allFalse == isFound.Count())
            {
                return(null);
            }

            //If exact match found, no more will exist, so stop searching
            int allTrue = isFound.Where(x => x == true).Count();

            if (allTrue == isFound.Count())
            {
                UpdateSearchType("exact");
            }

            return(isFound);
        }
Exemple #2
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");
            }
        }
Exemple #3
0
        public void GetAllMatches(Boolean[] currentRecord, DonorDetail record)
        {
            List <string> temp = DbToCustomObject(record);

            Boolean[] foundParts = UserSearchMatchRecord(temp);
            if (foundParts.SequenceEqual(currentRecord))
            {
                aSearch.Add(record);
            }
        }
 public void PopulateViewGUI()
 {
     principleDonor         = Account.GetDonorDetails();
     donorIDLabel.Content   = $"Donor ID: {principleDonor.DonorID}";
     birthLabel.Content     = $"DOB: {principleDonor.DOB}";
     genderLabel.Content    = $"Gender: {principleDonor.Gender}";
     raceLabel.Content      = $"Ethnicity: {principleDonor.Ethnicity}";
     bloodTypeLabel.Content = $"Blood Type: {principleDonor.BloodType}";
     rhFactorLabel.Content  = $"RH Factor {principleDonor.RHFactor}";
     pastLabel.Content      = $"History {principleDonor.MedicalHistory}";
 }
Exemple #5
0
        public List <string> DbToCustomObject(DonorDetail aDonor)
        {
            List <string> temp = new List <string>
            {
                aDonor.DOB.ToString(),
                          aDonor.Gender,
                          aDonor.Ethnicity,
                          aDonor.BloodType,
                          aDonor.RHFactor
            };

            return(temp);
        }
        public void ValidateDonorDetails()
        {
            var databaseContext = new UserRegistrationDBEntities();
            var user            = new DonorDetail()

            {
                DonorID        = Int32.Parse(donorIDText.Text.Trim()),
                DOB            = Convert.ToDateTime(birthText.Text.Trim()),
                Gender         = genderText.Text.Trim(),
                Ethnicity      = ethnicityText.Text.Trim(),
                BloodType      = bloodTypeText.Text.Trim(),
                RHFactor       = rhFactorText.Text.Trim(),
                MedicalHistory = historyText.Text.Trim(),
                NhsID          = principleUser.NhsID
            };

            databaseContext.DonorDetails.Add(user);
            databaseContext.SaveChanges();
            MessageBox.Show("Donor Data Added");
            SharedFunctions.BackToAccount(this);
        }