Beispiel #1
0
        private static DateTime AskForNewOrderDate(string msg = "")
        {
            if (msg != "")
            {
                Console.WriteLine(msg);
            }
            DateTime orderDate;
            int      orderDay = 0, maxYear = 0, orderYear = 0, orderMonth = 0;

            do
            {
                Console.WriteLine("What is the numeric month of the new order?");
                orderMonth = CommonIO.GetIntFromUser(1, 12);

                Console.WriteLine("What is the numeric day of the new order?");
                orderDay = CommonIO.GetIntFromUser(1, 31);

                int maxYr = DateTime.Today.Year + 20;
                Console.WriteLine($"What is the 4 digit year of the order? (Max is {maxYr}.)");
                int currentYr = DateTime.Now.Year;

                int orderYr = CommonIO.GetIntFromUser(currentYr, maxYr);

                orderDate = new DateTime(orderYr, orderMonth, orderDay);
                if (orderDate < DateTime.Now)
                {
                    CommonIO.errMsg("Order dates must be in the future. Please type a new date.");
                }
            } while (orderDate < DateTime.Now);
            return(orderDate);
        }
Beispiel #2
0
        public static string AskForNewCustomerName()
        {
            //TODO: With new customer names, the calling routine should check for blank names, which are usedd in edting.
            bool   wrongInput = true;
            String customerName;

            do
            {
                Console.WriteLine("What is the name of the customer on the new order?");
                customerName = Console.ReadLine();
                wrongInput   = !customerName.All(c => Char.IsLetterOrDigit(c) || c == ' ' ||
                                                 c == ',' || c == '.');
                if (wrongInput)
                {
                    CommonIO.errMsg("Customer names can only contain numbers, letters, periods, and commas.");
                }
                else
                {
                    wrongInput = false;
                }
            } while (wrongInput);
            return(customerName);
        }