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(); } }
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(); } }
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(); }
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(); } }