Exemple #1
0
        public static void UpdatePetFriendly(Animal animal, string update)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var  petFriendly            = (from p in db.Animals where p.ID == animal.ID select p).FirstOrDefault();
            bool isPetFriendly;

            if (update.ToLower() == "yes")
            {
                isPetFriendly = true;
            }

            else
            {
                isPetFriendly = false;
            }
            animal.kidFriendly = isPetFriendly;

            try

            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #2
0
        public static void AddNewClient(string firstName, string lastName, string username, string password, string email, string streetAddress, int zipCode, int state)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext("c:/Documents/HumaneSociety/HumaneSociety/HumaneSociety.dbml");
            Client client = new Client();

            client.firstName = firstName;
            client.lastName  = lastName;
            client.userName  = username;
            client.pass      = password;
            client.email     = email;
            UserAddress address = new UserAddress();

            address.addessLine1 = streetAddress;
            address.zipcode     = zipCode;
            address.USStates    = state;
            client.userAddress  = address.ID;
            db.Clients.InsertOnSubmit(client);
            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #3
0
        public static void UpdateWeight(Animal animal, string update)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var weight = (from w in db.Animals where w.ID == animal.ID select w).FirstOrDefault();

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #4
0
        public static void UpdateDemeanor(Animal animal, string update)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var demeanor = (from d in db.Animals where d.ID == animal.ID select d).FirstOrDefault();

            demeanor.demeanor = update;
            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #5
0
        public static void UpdateAge(Animal animal, string update)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var age = (from a in db.Animals where a.ID == animal.ID select a).FirstOrDefault();

            age.age = Int32.Parse(update);
            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #6
0
        public static void CreateNewEmployee(Employee employee, string create)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Employees.InsertOnSubmit(employee);

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #7
0
        public static void AddAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Animals.InsertOnSubmit(animal);

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #8
0
        public static void UpdateEmail(Client client)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var clientData = db.Clients.Where(c => c.ID == client.ID).Select(c => c).First();

            clientData.email = client.email;
            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #9
0
        public static void DeleteOldEmployee(Employee employee, string delete)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var oldEmployee             = (from o in db.Employees where o.employeeNumber == employee.employeeNumber && o.lastName == employee.lastName select o).FirstOrDefault();

            db.Employees.DeleteOnSubmit(oldEmployee);

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #10
0
        public static void RemoveAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var animalToRemove          = (from a in db.Animals where a.ID == animal.ID select a).FirstOrDefault();

            db.Animals.DeleteOnSubmit(animalToRemove);

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #11
0
        public static void AddUsernameAndPassword(Employee employee, string userName, string password)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var addEmployee             = (from e in db.Employees where e.ID == employee.ID select e).FirstOrDefault();

            addEmployee.userName = userName;
            addEmployee.pass     = password;

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #12
0
        public static Client GetClient(string userName, string password)
        {
            HumaneSocietyDataContext db      = new HumaneSocietyDataContext("c:/Documents/HumaneSociety/HumaneSociety/HumaneSociety.dbml");
            Table <Client>           clients = db.GetTable <Client>();
            var getClient = db.Clients.Where(c => c.userName == userName).Select(c => c).FirstOrDefault();

            try
            {
                if (password == getClient.pass)
                {
                    return(getClient);
                }
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
            return(getClient);
        }
Exemple #13
0
        public static void UpdateEmployeeInfo(Employee employee, string update)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            int      employeeNumber     = int.Parse(UserInterface.GetStringData("employee number", "the employee's original"));
            Employee employeetoUpdate   = GetEmployeeByEmployeeNumber(employeeNumber);
            var      employeeInContext  = (from u in db.Employees where employeetoUpdate.ID == u.ID select u).FirstOrDefault();

            employeeInContext.email          = employee.email;
            employeeInContext.lastName       = employee.lastName;
            employeeInContext.employeeNumber = employee.employeeNumber;
            employeeInContext.firsttName     = employee.firsttName;

            try
            {
                db.SubmitChanges();
            }

            catch (Exception e)
            {
                UserInterface.DisplayExceptionMessage(e);
            }
        }
Exemple #14
0
        public static int GetBreedKey(string breed)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var breedID = (from c in context.Breeds where c.breed1 == breed select c.ID).FirstOrDefault();

            if (breedID < 0)
            {
                Breed newBreed = new Breed();
                newBreed.breed1 = breed;
                context.Breeds.InsertOnSubmit(newBreed);
                try
                {
                    context.SubmitChanges();
                }
                catch (Exception e)
                {
                    UserInterface.DisplayExceptionMessage(e);
                }
                return(newBreed.ID);
            }
            return(breedID);
        }
Exemple #15
0
        public static int GetShotID(string name)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            bool shotExist = db.Shots.Any(s => s.name == name);

            if (shotExist == false)
            {
                Shot shotToAdd = new Shot();
                shotToAdd.name = name;
                db.Shots.InsertOnSubmit(shotToAdd);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    UserInterface.DisplayExceptionMessage(e);
                }
            }
            var shotID = (from s in db.Shots where s.name == name select s.ID).FirstOrDefault();

            return(shotID);
        }