Beispiel #1
0
        public void SearchASpecificAnimal()
        {
            Console.WriteLine("Enter the animal name of the animal you are looking for");
            animalName = Console.ReadLine();

            HsdbLinqToSqlDataContext dbAnimSearch = new HsdbLinqToSqlDataContext();
            var animalResult = dbAnimSearch.Animals.Where(n => n.Name == animalName).Select(s => s).ToList();

            if (animalResult != null)
            {
                Console.WriteLine("\nSEARCH RESULTS: \n");
                foreach (var match in animalResult)
                {
                    Console.WriteLine("  Room: " + match.Room);
                    Console.WriteLine("  Name: " + match.Name);
                    Console.WriteLine("  Animal Type: " + match.AnimalType);
                    Console.WriteLine("  Gender: " + match.Gender);
                    Console.WriteLine("  Food: " + match.Food);
                    Console.WriteLine("  Shots: " + match.Shot);
                    Console.WriteLine("  Price: " + match.Price);
                }
            }
            else
            {
                Console.WriteLine("! No Matches Found. !\n\n");
            }

            GetOptionToEdit();
        }
Beispiel #2
0
        public void SearchByBoth()
        {
            HsdbLinqToSqlDataContext dbAnimSearch = new HsdbLinqToSqlDataContext();
            var animalResult = dbAnimSearch.Animals.Where(t => t.AnimalType == typeChoice).Where(g => g.Gender == genderChoice).Select(anim => anim).ToList();

            if (animalResult != null)
            {
                Console.WriteLine("\nSEARCH RESULTS: \n");
                foreach (var match in animalResult)
                {
                    Console.WriteLine("  Room: " + match.Room);
                    Console.WriteLine("  Name: " + match.Name);
                    Console.WriteLine("  Animal Type: " + match.AnimalType);
                    Console.WriteLine("  Gender: " + match.Gender);
                    Console.WriteLine("  Food: " + match.Food);
                    Console.WriteLine("  Shots: " + match.Shot);
                    Console.WriteLine("  Price: " + match.Price);
                }
            }
            else
            {
                Console.WriteLine("! No Matches Found. !\n\n");
            }
            Console.WriteLine("Press any key to continue....");
            Console.ReadKey();
        }
Beispiel #3
0
        public Register()
        {
            HsdbLinqToSqlDataContext dbAdopterObj = new HsdbLinqToSqlDataContext();

            Adopter adopter = new Adopter();

            Console.WriteLine("\nFill out user registration information below ..");
            Console.WriteLine("Enter First Name:");
            adopter.P_FirstName = Console.ReadLine();
            Console.WriteLine("Enter Last Name:");
            adopter.P_LastName = Console.ReadLine();
            Console.WriteLine("Enter Address:");
            adopter.P_Address = Console.ReadLine();
            Console.WriteLine("Enter City:");
            adopter.P_City = Console.ReadLine();
            Console.WriteLine("Enter State:");
            adopter.P_State = Console.ReadLine();
            Console.WriteLine("Enter Zip:");
            adopter.P_Zip = Console.ReadLine();
            Console.WriteLine("Phone:");
            adopter.P_Phone = Console.ReadLine();

            dbAdopterObj.Adopters.InsertOnSubmit(adopter);
            try
            {
                dbAdopterObj.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("An error occurred, sorry for the inconvenience");
                dbAdopterObj.SubmitChanges();
            }
        }
Beispiel #4
0
        private void DeleteAnimalFromTable(string animToEdit)
        {
            HsdbLinqToSqlDataContext removeAnimObj   = new HsdbLinqToSqlDataContext();
            List <Animal>            removeFromGroup = (from animal in removeAnimObj.Animals
                                                        where (animal.Room == animToEdit)
                                                        select animal).ToList();


            removeAnimObj.Animals.DeleteAllOnSubmit(removeFromGroup);
            removeAnimObj.SubmitChanges();
            Console.WriteLine("This record has been deleted, Press any key to return to the Main Menu");
            Console.ReadKey();
            MainMenu mainMenu = new MainMenu();
        }
Beispiel #5
0
        public void EditShot(string animToEdit)
        {
            using (HsdbLinqToSqlDataContext editShotObj = new HsdbLinqToSqlDataContext())
            {
                Animal animal = new Animal();

                if (animal.Shot == animToEdit)
                {
                    Console.WriteLine("Please enter Animal Type Value to be updated.");
                    animal.Shot = Console.ReadLine();
                }

                editShotObj.SubmitChanges();
            }
        }
Beispiel #6
0
        private void CollectPayment(string animToEdit)
        {
            HsdbLinqToSqlDataContext payAnimBalance = new HsdbLinqToSqlDataContext();
            var animalPrice = payAnimBalance.Animals.Where(r => r.Room == animToEdit).Select(p => p).ToList();

            if (animalPrice != null)
            {
                Console.WriteLine("\nSEARCH RESULTS: \n");
                foreach (var adoptee in animalPrice)
                {
                    Console.WriteLine("  Price: " + adoptee.Price);
                    CollectMoney();
                }
            }
            else
            {
                Console.WriteLine("! No Matches Found. !\n");
            }
        }
Beispiel #7
0
        public AddAnimalData()
        {
            HsdbLinqToSqlDataContext dbAnimObject = new HsdbLinqToSqlDataContext();

            Animal animal = new Animal();

            Console.WriteLine("\nEnter New animal info according to options.");
            Console.WriteLine("1. Room Placement: ");
            animal.Room = Console.ReadLine().ToLower();
            Console.WriteLine("2. Animal's Name: ");
            animal.Name = Console.ReadLine().ToLower();
            Console.WriteLine("3. Animal Type: ");
            animal.AnimalType = Console.ReadLine().ToLower();
            Console.WriteLine("4. Gender: ");
            animal.Gender = Console.ReadLine().ToLower();
            Console.WriteLine("5. Food: ");
            animal.Food = Console.ReadLine().ToLower();
            Console.WriteLine("6. Shots: ");
            animal.Shot = Console.ReadLine().ToLower();
            Console.WriteLine("7. Price: ");
            priceInput = Console.ReadLine();
            if (Decimal.TryParse(priceInput, out setPrice))
            {
                animal.Price = setPrice;
            }
            else
            {
                Console.WriteLine("Unable to parse '{0}'.", priceInput);
            }

            dbAnimObject.Animals.InsertOnSubmit(animal);
            try
            {
                dbAnimObject.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("An error occurred, sorry for the inconvenience");
                dbAnimObject.SubmitChanges();
            }
        }
Beispiel #8
0
 public static void ImportData(string file)
 {
     try
     {
         HsdbLinqToSqlDataContext dbImportObj = new HsdbLinqToSqlDataContext();
         var importFile = GetFromCSV(file);
         foreach (var row in importFile)
         {
             AddAnimalData animImport = new AddAnimalData();
         }
         Console.WriteLine("File successfully added.\n\n");
         Console.WriteLine("Press [ENTER] to continue....");
         Console.ReadKey();
     }
     catch (Exception)
     {
         Console.WriteLine("An import error occurred, you must manually enter animals at this time");
         Console.ReadKey();
     }
 }
Beispiel #9
0
        public void SearchAdoperByName()
        {
            DbConnect db = new DbConnect();

            Adopter adopter = new Adopter();

            Console.WriteLine("Enter Adopter's First Name");
            adpFName = Console.ReadLine();
            Console.WriteLine("Enter Adopter's Last Name");
            adpLName = Console.ReadLine();
            HsdbLinqToSqlDataContext dbAdopter = new HsdbLinqToSqlDataContext();
            var adopterResult = dbAdopter.Adopters.Where(f => f.P_FirstName == adpFName).Where(l => l.P_LastName == adpLName).Select(a => a).ToList();

            if (adopterResult != null)
            {
                Console.WriteLine("\nSEARCH RESULTS: \n");
                foreach (var person in adopterResult)
                {
                    Console.WriteLine("  ID: " + person.PersonID);
                    Console.WriteLine("  First Name: " + person.P_FirstName);
                    Console.WriteLine("  Last Name: " + person.P_LastName);
                    Console.WriteLine("  Address: " + person.P_Address);
                    Console.WriteLine("  City: " + person.P_City);
                    Console.WriteLine("  State: " + person.P_State);
                    Console.WriteLine("  Zip: " + person.P_Zip);
                    Console.WriteLine("  Phone: " + person.P_Phone);
                }
            }
            else
            {
                Console.WriteLine("! No Matches Found. !\n\n");
            }
            Console.WriteLine("Press any key to continue....");

            Console.ReadKey();
        }