예제 #1
0
        public Bitmap GetImage(string type, OwnerTypes owner)
        {
            Bitmap b = Properties.Resources.ResourceManager.GetObject(owner.ToString() + type, Properties.Resources.Culture) as Bitmap;

            if (b == null)
            {
                throw new NullReferenceException(String.Format("The image with the name of {0} could not be found", owner.ToString() + type));
            }
            return(b);
        }
예제 #2
0
        public void UpdateOwner(OwnerTypes type)
        {
            int    id = -1;
            string input;
            Owners owners = ownerDB.GetOwnersByType(type).ToList();

            Console.WriteLine(owners.ToString());
            while (id < 1)
            {
                Console.Write($"Which {type.ToString()} would you like? : ");
                input = Utility.ReadAndCheckForQuit();
                if (!int.TryParse(input, out id))
                {
                    Console.WriteLine("Please enter a valid number");
                }
            }

            Owner owner = null;

            try
            {
                owner = ownerDB.GetOwnerById(id);
                Console.WriteLine($"You selected : {owner.ToString()}");
            }
            catch
            {
                Console.WriteLine($"Couldn't find that... please enter valid id");
                UpdateOwner(type);
            }

            id = -1;
            while (id < 1)
            {
                Console.Write($"Which field to modify? 1 = First Name, 2 = Last Name etc... : ");
                input = Utility.ReadAndCheckForQuit();
                if (!int.TryParse(input, out id))
                {
                    Console.WriteLine("Please enter a valid number");
                }
            }

            Console.Write("Enter new field value : ");
            input = Console.ReadLine();

            bool success = InsertNewValue(id, input, owner);

            success = ownerDB.UpdateOwner(owner);
            string msg = success ? "Update successful" : "Update failed";

            Console.WriteLine(msg);
        }