Пример #1
0
        public List <Dogs> GetDogByRegNo(string reg_No)
        {
            List <Dogs> retVal = new List <Dogs>();

            try
            {
                DogsBL dogs = new DogsBL(_connString);
                tblDogs = dogs.GetDogByRegNo(reg_No);

                if (tblDogs != null && tblDogs.Rows.Count > 0)
                {
                    foreach (DataRow row in tblDogs.Rows)
                    {
                        Dogs dog = new Dogs(_connString, Utils.DBNullToGuid(row["Dog_ID"]));
                        retVal.Add(dog);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retVal);
        }
Пример #2
0
        public List <Dogs> GetDogsByDog_Breed_ID(List <DogBreeds> lkpDogBreeds)
        {
            List <Dogs> retVal = new List <Dogs>();

            string dog_Breed_IDs = null;

            foreach (DogBreeds dog_Breed in lkpDogBreeds)
            {
                dog_Breed_IDs += dog_Breed.Dog_Breed_ID + ", ";
            }
            string Breed_IDs = dog_Breed_IDs.Substring(0, dog_Breed_IDs.Length - 2);


            try
            {
                DogsBL dogs = new DogsBL(_connString);
                tblDogs = dogs.GetDogsWhereBreed_IDInList(Breed_IDs);

                if (tblDogs != null && tblDogs.Rows.Count > 0)
                {
                    foreach (DataRow row in tblDogs.Rows)
                    {
                        Dogs dog = new Dogs(_connString, Utils.DBNullToGuid(row["Dog_ID"]));
                        retVal.Add(dog);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retVal);
        }
Пример #3
0
        public int AddDog(Dogs dog)
        {
            if (MyDogList == null)
                MyDogList = new List<Dogs>();
            bool foundDog = false;
            foreach (Dogs d in MyDogList)
            {
                if (d.Dog_ID == dog.Dog_ID)
                    foundDog = true;
            }
            if (!foundDog)
                MyDogList.Add(dog);

            return MyDogList.Count;
        }
Пример #4
0
        private static List <Dogs> OwnerDogsInCurrentClass(string connString, List <DogOwners> ownerDogList, Guid show_ID, Guid show_Entry_Class_ID)
        {
            List <Dogs> retVal = new List <Dogs>();

            try
            {
                List <Dogs> existsInCurrentClass       = new List <Dogs>();
                List <Dogs> ownerDogsNotInCurrentClass = new List <Dogs>();
                foreach (DogOwners dog in ownerDogList)
                {
                    DogClasses        dc     = new DogClasses(connString);
                    List <DogClasses> dcList = dc.GetDog_ClassesByDog_ID(show_ID, dog.Dog_ID);
                    if (dcList != null && dcList.Count > 0)
                    {
                        foreach (DogClasses dogClassRow in dcList)
                        {
                            Guid dog_ID = new Guid(dogClassRow.Dog_ID.ToString());
                            if (dogClassRow.Show_Entry_Class_ID == show_Entry_Class_ID)
                            {
                                if (!retVal.Exists(delegate(Dogs i) { return(i.Dog_ID == dog_ID); }))
                                {
                                    Dogs d = new Dogs(connString, dog_ID);
                                    retVal.Add(d);
                                }
                                else
                                {
                                    Dogs d = new Dogs(connString, dog_ID);
                                    existsInCurrentClass.Add(d);
                                }
                            }
                            else
                            {
                                Dogs d = new Dogs(connString, dog_ID);
                                ownerDogsNotInCurrentClass.Add(d);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retVal);
        }
Пример #5
0
        public int AddDog(Dogs dog)
        {
            if (MyDogList == null)
            {
                MyDogList = new List <Dogs>();
            }
            bool foundDog = false;

            foreach (Dogs d in MyDogList)
            {
                if (d.Dog_ID == dog.Dog_ID)
                {
                    foundDog = true;
                }
            }
            if (!foundDog)
            {
                MyDogList.Add(dog);
            }

            return(MyDogList.Count);
        }
Пример #6
0
 private bool IsOldestDog(sss.tblOwnersDogsClassesDrawnListRow row)
 {
     bool oldestDog = true;
     Dogs currentDog = new Dogs(row.Dog_ID);
     int? currentYOB = currentDog.Year_Of_Birth;
     if(currentYOB == null)
     {
         DateTime? currentDOB = currentDog.Date_Of_Birth;
         if(currentDOB != null)
         {
             DateTime dteCurrentDOB = (DateTime)currentDOB;
             currentYOB = dteCurrentDOB.Year;
         }
         else
         {
             return true;
         }
     }
     DogOwners dogOwner = new DogOwners();
     List<DogOwners> dogOwnerList = dogOwner.GetDogOwnersByOwner_ID(row.Owner_ID);
     foreach (DogOwners dogOwnerRow in dogOwnerList)
     {
         if (dogOwnerRow.Dog_ID != row.Dog_ID)
         {
             Dogs thisDog = new Dogs(dogOwnerRow.Dog_ID);
             int? thisYOB = thisDog.Year_Of_Birth;
             if (thisYOB == null)
             {
                 DateTime? thisDOB = thisDog.Date_Of_Birth;
                 if (thisDOB != null)
                 {
                     DateTime dteThisDOB = (DateTime)thisDOB;
                     thisYOB = dteThisDOB.Year;
                 }
                 else
                 {
                     thisYOB=0;
                 }
             }
             if (thisYOB < currentYOB)
                 return false;
         }
     }
     return oldestDog;
 }
Пример #7
0
 private static List<Dogs> OwnerDogsInCurrentClass(List<DogOwners> ownerDogList, Guid show_Entry_Class_ID)
 {
     List<Dogs> ownerDogsInCurrentClass = new List<Dogs>();
     List<Dogs> existsInCurrentClass = new List<Dogs>();
     List<Dogs> ownerDogsNotInCurrentClass = new List<Dogs>();
     foreach (DogOwners dog in ownerDogList)
     {
         DogClasses dc = new DogClasses();
         List<DogClasses> dcList = dc.GetDog_ClassesByDog_ID(dog.Dog_ID);
         if(dcList != null && dcList.Count > 0)
         {
             foreach (DogClasses dogClassRow in dcList)
             {
                 Guid dog_ID = new Guid(dogClassRow.Dog_ID.ToString());
                 if (dogClassRow.Show_Entry_Class_ID == show_Entry_Class_ID)
                 {
                     if (!ownerDogsInCurrentClass.Exists(delegate(Dogs i) { return i.Dog_ID == dog_ID; }))
                     {
                         Dogs d = new Dogs(dog_ID);
                         ownerDogsInCurrentClass.Add(d);
                     }
                     else
                     {
                         Dogs d = new Dogs(dog_ID);
                         existsInCurrentClass.Add(d);
                     }
                 }
                 else
                 {
                     Dogs d = new Dogs(dog_ID);
                     ownerDogsNotInCurrentClass.Add(d);
                 }
             }
         }
     }
     return ownerDogsInCurrentClass;
 }
Пример #8
0
 private static List<DogsInClass> AllocateDogsToClassParts(List<DogClasses> dogClassList, List<ClassParts> classParts)
 {
     PartCount = 0;
     List<DogsInClass> allDogsInClass = new List<DogsInClass>();
     foreach (DogClasses dogClass in dogClassList)
     {
         Guid show_Entry_Class_ID = new Guid(dogClass.Show_Entry_Class_ID.ToString());
         List<DogOwners> dogOwnersList = new List<DogOwners>();
         DogOwners dogOwners = new DogOwners();
         Guid dog_ID = new Guid(dogClass.Dog_ID.ToString());
         dogOwnersList = dogOwners.GetDogOwnersByDog_ID(dog_ID);
         foreach (DogOwners owner in dogOwnersList)
         {
             List<DogOwners> dogOwnerDogList = new List<DogOwners>();
             DogOwners dogOwnerDogs = new DogOwners();
             dogOwnerDogList = dogOwnerDogs.GetDogOwnersByOwner_ID(owner.Owner_ID);
             List<Dogs> ownerDogsInClassList = new List<Dogs>();
             ownerDogsInClassList = OwnerDogsInCurrentClass(dogOwnerDogList, show_Entry_Class_ID);
             if (ownerDogsInClassList.Count == 1)
             {
                 if (!FoundInList(allDogsInClass, ownerDogsInClassList[0].Dog_ID))
                 {
                     Dogs dog = new Dogs(ownerDogsInClassList[0].Dog_ID);
                     DogsInClass dogInClass = new DogsInClass();
                     dogInClass.Dog = dog;
                     dogInClass.Dog_Class_ID = GetDogClassID(dog.Dog_ID, show_Entry_Class_ID);
                     dogInClass.Show_Final_Class_ID = NextPart(classParts);
                     dogInClass.AddToPart = PartCount;
                     allDogsInClass.Add(dogInClass);
                 }
             }
             else if (ownerDogsInClassList.Count == 2)
             {
                 if (!FoundInList(allDogsInClass, ownerDogsInClassList[0].Dog_ID))
                 {
                     Dogs dog1 = new Dogs(ownerDogsInClassList[0].Dog_ID);
                     DogsInClass dogInClass1 = new DogsInClass();
                     dogInClass1.Dog = dog1;
                     dogInClass1.Dog_Class_ID = GetDogClassID(dog1.Dog_ID, show_Entry_Class_ID);
                     dogInClass1.Show_Final_Class_ID = NextPart(classParts);
                     dogInClass1.AddToPart = PartCount;
                     allDogsInClass.Add(dogInClass1);
                 }
                 if (!FoundInList(allDogsInClass, ownerDogsInClassList[1].Dog_ID))
                 {
                     Dogs dog2 = new Dogs(ownerDogsInClassList[1].Dog_ID);
                     DogsInClass dogInClass2 = new DogsInClass();
                     dogInClass2.Dog = dog2;
                     dogInClass2.Dog_Class_ID = GetDogClassID(dog2.Dog_ID, show_Entry_Class_ID);
                     dogInClass2.Show_Final_Class_ID = NextPart(classParts);
                     dogInClass2.AddToPart = PartCount;
                     allDogsInClass.Add(dogInClass2);
                 }
             }
             else
             {
                 foreach (Dogs ownerDog in ownerDogsInClassList)
                 {
                     if (!FoundInList(allDogsInClass, ownerDog.Dog_ID))
                     {
                         Dogs dog = new Dogs(ownerDog.Dog_ID);
                         DogsInClass dogInClass = new DogsInClass();
                         dogInClass.Dog = dog;
                         dogInClass.Dog_Class_ID = GetDogClassID(dog.Dog_ID, show_Entry_Class_ID);
                         dogInClass.Show_Final_Class_ID = NextPart(classParts);
                         dogInClass.AddToPart = PartCount;
                         allDogsInClass.Add(dogInClass);
                     }
                 }
             }
         }
     }
     return allDogsInClass;
 }
Пример #9
0
        public List<Dogs> GetDogsLikeDog_Pet_Name(string dog_Pet_Name)
        {
            List<Dogs> dogList = new List<Dogs>();
            DogsBL dogs = new DogsBL();
            tblDogs = dogs.GetDogsLikeDog_Pet_Name(dog_Pet_Name);

            if (tblDogs != null && tblDogs.Count > 0)
            {
                foreach (sss.tblDogsRow row in tblDogs)
                {
                    Dogs dog = new Dogs(row.Dog_ID);
                    dogList.Add(dog);
                }
            }
            return dogList;
        }
Пример #10
0
        public List<Dogs> GetDogsByDog_Breed_ID(List<DogBreeds> lkpDogBreeds)
        {
            string dog_Breed_IDs = null;
            foreach (DogBreeds dog_Breed in lkpDogBreeds)
            {
                dog_Breed_IDs += dog_Breed.Dog_Breed_ID + ", ";
            }
            string Breed_IDs = dog_Breed_IDs.Substring(0, dog_Breed_IDs.Length - 2);

            List<Dogs> dogList = new List<Dogs>();
            DogsBL dogs = new DogsBL();
            tblDogs = dogs.GetDogsWhereBreed_IDInList(Breed_IDs);

            if (tblDogs != null && tblDogs.Count > 0)
            {
                foreach (sss.tblDogsRow row in tblDogs)
                {
                    Dogs dog = new Dogs(row.Dog_ID);
                    dogList.Add(dog);
                }
            }
            return dogList;
        }
Пример #11
0
        private static List <DogsInClass> AllocateDogsToClassParts(string connString, List <DogClasses> dogClassList, List <ClassParts> classParts, Guid show_ID)
        {
            List <DogsInClass> retVal = new List <DogsInClass>();

            try
            {
                PartCount = 0;
                int[] dogsInPart = new int[classParts.Count];
                foreach (DogClasses dogClass in dogClassList)
                {
                    Guid             show_Entry_Class_ID = new Guid(dogClass.Show_Entry_Class_ID.ToString());
                    List <DogOwners> dogOwnersList       = new List <DogOwners>();
                    DogOwners        dogOwners           = new DogOwners(connString);
                    Guid             dog_ID = new Guid(dogClass.Dog_ID.ToString());
                    dogOwnersList = dogOwners.GetDogOwnersByDog_ID(dog_ID);
                    foreach (DogOwners owner in dogOwnersList)
                    {
                        List <DogOwners> dogOwnerDogList = new List <DogOwners>();
                        DogOwners        dogOwnerDogs    = new DogOwners(connString);
                        dogOwnerDogList = dogOwnerDogs.GetDogOwnersByOwner_ID(owner.Owner_ID);
                        List <Dogs> ownerDogsInClassList = new List <Dogs>();
                        ownerDogsInClassList = OwnerDogsInCurrentClass(connString, dogOwnerDogList, show_ID, show_Entry_Class_ID);
                        if (dogClass.Preferred_Part > 0)
                        {
                            foreach (Dogs ownerDog in ownerDogsInClassList)
                            {
                                if (!FoundInList(retVal, ownerDog.Dog_ID))
                                {
                                    Dogs        dog        = new Dogs(connString, ownerDog.Dog_ID);
                                    DogsInClass dogInClass = new DogsInClass();
                                    dogInClass.Dog                 = dog;
                                    dogInClass.Dog_Class_ID        = GetDogClassID(connString, dog.Dog_ID, show_Entry_Class_ID);
                                    dogInClass.Show_Final_Class_ID = classParts[dogClass.Preferred_Part - 1].Show_Final_Class_ID;
                                    dogInClass.AddToPart           = dogClass.Preferred_Part;
                                    retVal.Add(dogInClass);
                                    dogsInPart[dogClass.Preferred_Part - 1]++;
                                }
                            }
                        }
                    }
                }
                foreach (DogClasses dogClass in dogClassList)
                {
                    Guid             show_Entry_Class_ID = new Guid(dogClass.Show_Entry_Class_ID.ToString());
                    List <DogOwners> dogOwnersList       = new List <DogOwners>();
                    DogOwners        dogOwners           = new DogOwners(connString);
                    Guid             dog_ID = new Guid(dogClass.Dog_ID.ToString());
                    dogOwnersList = dogOwners.GetDogOwnersByDog_ID(dog_ID);
                    foreach (DogOwners owner in dogOwnersList)
                    {
                        List <DogOwners> dogOwnerDogList = new List <DogOwners>();
                        DogOwners        dogOwnerDogs    = new DogOwners(connString);
                        dogOwnerDogList = dogOwnerDogs.GetDogOwnersByOwner_ID(owner.Owner_ID);
                        List <Dogs> ownerDogsInClassList = new List <Dogs>();
                        ownerDogsInClassList = OwnerDogsInCurrentClass(connString, dogOwnerDogList, show_ID, show_Entry_Class_ID);
                        if (dogClass.Preferred_Part > 0)
                        {
                            foreach (Dogs ownerDog in ownerDogsInClassList)
                            {
                                if (!FoundInList(retVal, ownerDog.Dog_ID))
                                {
                                    Dogs        dog        = new Dogs(connString, ownerDog.Dog_ID);
                                    DogsInClass dogInClass = new DogsInClass();
                                    dogInClass.Dog                 = dog;
                                    dogInClass.Dog_Class_ID        = GetDogClassID(connString, dog.Dog_ID, show_Entry_Class_ID);
                                    dogInClass.Show_Final_Class_ID = classParts[dogClass.Preferred_Part - 1].Show_Final_Class_ID;
                                    dogInClass.AddToPart           = dogClass.Preferred_Part;
                                    retVal.Add(dogInClass);
                                    dogsInPart[dogClass.Preferred_Part - 1]++;
                                }
                            }
                        }
                        if (ownerDogsInClassList.Count == 1)
                        {
                            if (!FoundInList(retVal, ownerDogsInClassList[0].Dog_ID))
                            {
                                Dogs        dog        = new Dogs(connString, ownerDogsInClassList[0].Dog_ID);
                                DogsInClass dogInClass = new DogsInClass();
                                dogInClass.Dog                 = dog;
                                dogInClass.Dog_Class_ID        = GetDogClassID(connString, dog.Dog_ID, show_Entry_Class_ID);
                                dogInClass.Show_Final_Class_ID = GetEmptiestClassPart(classParts, dogsInPart);
                                dogInClass.AddToPart           = PartCount;
                                retVal.Add(dogInClass);
                                dogsInPart[PartCount - 1]++;
                            }
                        }
                        else if (ownerDogsInClassList.Count == 2)
                        {
                            if (!FoundInList(retVal, ownerDogsInClassList[0].Dog_ID))
                            {
                                Dogs        dog1        = new Dogs(connString, ownerDogsInClassList[0].Dog_ID);
                                DogsInClass dogInClass1 = new DogsInClass();
                                dogInClass1.Dog                 = dog1;
                                dogInClass1.Dog_Class_ID        = GetDogClassID(connString, dog1.Dog_ID, show_Entry_Class_ID);
                                dogInClass1.Show_Final_Class_ID = NextPart(classParts);
                                dogInClass1.AddToPart           = PartCount;
                                retVal.Add(dogInClass1);
                                dogsInPart[PartCount - 1]++;
                            }
                            if (!FoundInList(retVal, ownerDogsInClassList[1].Dog_ID))
                            {
                                Dogs        dog2        = new Dogs(connString, ownerDogsInClassList[1].Dog_ID);
                                DogsInClass dogInClass2 = new DogsInClass();
                                dogInClass2.Dog                 = dog2;
                                dogInClass2.Dog_Class_ID        = GetDogClassID(connString, dog2.Dog_ID, show_Entry_Class_ID);
                                dogInClass2.Show_Final_Class_ID = NextPart(classParts);
                                dogInClass2.AddToPart           = PartCount;
                                retVal.Add(dogInClass2);
                                dogsInPart[PartCount - 1]++;
                            }
                        }
                        else
                        {
                            foreach (Dogs ownerDog in ownerDogsInClassList)
                            {
                                if (!FoundInList(retVal, ownerDog.Dog_ID))
                                {
                                    Dogs        dog        = new Dogs(connString, ownerDog.Dog_ID);
                                    DogsInClass dogInClass = new DogsInClass();
                                    dogInClass.Dog                 = dog;
                                    dogInClass.Dog_Class_ID        = GetDogClassID(connString, dog.Dog_ID, show_Entry_Class_ID);
                                    dogInClass.Show_Final_Class_ID = NextPart(classParts);
                                    dogInClass.AddToPart           = PartCount;
                                    retVal.Add(dogInClass);
                                    dogsInPart[PartCount - 1]++;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retVal);
        }