Beispiel #1
0
        private static void AddRecordsIntoProductBatch(int lastId, ProductBatchQuery productBatchQuery)
        {
            bool flag = true;

            while (flag)
            {
                try
                {
                    Console.Write("Please, input corrrect existing product id: ");
                    int id = ConsoleInput.InputInt();
                    Console.Write("Please, input corrrect product product quantity: ");
                    int quantity = ConsoleInput.InputInt();

                    ProductBatch productBatch = new ProductBatch
                    {
                        BatchId_FK      = lastId,
                        ProductId_FK    = id,
                        ProductQuantity = quantity
                    };
                    productBatchQuery.AddNewRecord(productBatch);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                Console.Write("Add another one product to the batch? (y/n): ");
                string str = Console.ReadLine();
                if (str == "n")
                {
                    flag = false;
                }
            }
        }
Beispiel #2
0
        public static void AddNewBatch(SqlConnection connection)
        {
            Batch batch = new Batch();

            Console.WriteLine("Please, enter the batch details: ");

            Console.Write("Date: ");
            batch.Date = ConsoleInput.InputDate();

            Console.Write("Select batch type: ");
            batch.BatchType = SelectBatchType();

            BatchQuery batchQuery = new BatchQuery(connection);

            batchQuery.AddNewRecord(batch);
            int lastId = batchQuery.GetLastId();

            Console.WriteLine("Please, add products to the batch (input product's Id and quantity): ");
            ProductBatchQuery productBatchQuery = new ProductBatchQuery(connection);

            AddRecordsIntoProductBatch(lastId, productBatchQuery);
        }