예제 #1
0
        public void Create_ReturnsGeneratedOrderId()
        {
            var   orderRepository = new SqlOrderRepository(connectionString);
            Order order           = new Order {
                AccountId = "acc1"
            };
            int orderId1 = orderRepository.Create(order);
            int orderId2 = orderRepository.Create(order);

            Assert.True(orderId2 > orderId1);
        }
예제 #2
0
        private void UpdateOrderButton_Click(object sender, EventArgs e)
        {
            try
            {
                OrdersData od = new OrdersData();

                SqlOrderRepository orders = new SqlOrderRepository(connectionString);
                orders.UpdateOrder(Convert.ToInt32(OrderIDTextbox.Text), Convert.ToInt32(MemberIDTextbox.Text), Convert.ToInt32(EmployeeIDTextbox.Text), Convert.ToInt32(ShipmentIDTextbox.Text), Convert.ToDateTime(OrderDateTextBox.Text), ShipmentAddressTextbox.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        private void View_Orders_Load(object sender, EventArgs e)
        {
            Text = "View Orders from Table " + tableNumber.ToString();

            string connectionString = "Server=mssql.cs.ksu.edu;Database=santiagoscavone;UID=santiagoscavone;Pwd=Sqlpassword1!";

            orderRepository = new SqlOrderRepository(connectionString);

            IReadOnlyList <DatabaseData.Models.Order> orders = orderRepository.FetchAllOrdersFromTable(tableNumber);

            foreach (DatabaseData.Models.Order o in orders)
            {
                OrdersListBox.Items.Add(o.OrderID);
            }
        }
        public Controller Create(ControllerContext cc, Type controllerType)
        {
            // Create Scoped components
            var context           = new CommerceContext(this.configuration.ConnectionString).TrackDisposable(cc);
            var productRepository = new SqlProductRepository(context);
            var orderRepository   = new SqlOrderRepository(context);

            // Create Transient components
            switch (controllerType.Name)
            {
            case nameof(HomeController):
                return(new HomeController());

            case nameof(InventoryController):
                return(new InventoryController(
                           productRepository,
                           this.Decorate(
                               context,
                               new AdjustInventoryService(
                                   new SqlInventoryRepository(context),
                                   this.Handler <InventoryAdjusted>(context)))));

            case nameof(OrderController):
                return(new OrderController(
                           orderApprover: Decorate(
                               context,
                               new ApproveOrderService(
                                   orderRepository,
                                   this.Handler <OrderApproved>(context))),
                           orderCancellor: Decorate(
                               context,
                               new CancelOrderService(
                                   orderRepository,
                                   this.Handler <OrderCancelled>(context)))));

            case nameof(ProductController):
                return(new ProductController(
                           productRepository,
                           productDeleter: Decorate(context, new DeleteProductService(productRepository)),
                           productInserter: Decorate(context, new InsertProductService(productRepository)),
                           productUpdater: Decorate(context, new UpdateProductService(productRepository))));

            default:
                throw new InvalidOperationException($"Unknown controller {controllerType}.");
            }
        }
예제 #5
0
        private void retrieveOrders_Click(object sender, EventArgs e)
        {
            SqlOrderRepository     orders    = new SqlOrderRepository(connectionString);
            IReadOnlyList <Orders> orderList = orders.RetrieveOrders();

            dataGridView1.DataSource = orderList;

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                DataGridViewColumn columnOne = dataGridView1.Columns[0];
                columnOne.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnTwo = dataGridView1.Columns[1];
                columnTwo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnThree = dataGridView1.Columns[2];
                columnThree.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
예제 #6
0
        private void orderCount_Click(object sender, EventArgs e)
        {
            SqlOrderRepository orders = new SqlOrderRepository(connectionString);

            OrderCount        oo   = orders.RetrieveOrderCount(startDatePicker.Value, endDatePicker.Value);
            List <OrderCount> list = new List <OrderCount>();

            list.Add(oo);
            dataGridView1.DataSource = list;

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                DataGridViewColumn columnOne = dataGridView1.Columns[0];
                columnOne.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnTwo = dataGridView1.Columns[1];
                columnTwo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnThree = dataGridView1.Columns[2];
                columnThree.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
예제 #7
0
        private void Done_Click(object sender, EventArgs e)
        {
            try
            {
                string             connectionString = "Server=mssql.cs.ksu.edu;Database=santiagoscavone;UID=santiagoscavone;Pwd=Sqlpassword1!";
                SqlOrderRepository sqlo             = new SqlOrderRepository(connectionString);
                if (selectedWaiter != null)
                {
                    DatabaseData.Models.Order o = sqlo.AddOrder(selectedWaiter.FirstName, selectedWaiter.LastName, tableno);
                    foreach (Food f in orderFoods)
                    {
                        Food added = sqlo.AddFood(o.OrderID, f.Name, f.Quantity, f.IngredientsUsed);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            View_Orders vo = new View_Orders(tableno);

            this.Hide();
            vo.Show();
        }
예제 #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                menuItemsRepository  = new SqlMenuItemsRepository(connectionString);
                orderRepository      = new SqlOrderRepository(connectionString);
                waiterRepository     = new SqlWaiterRepository(connectionString);
                statisticsRepository = new SqlStatisticsRepository(connectionString);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            PropertiesDict = new[] {
                HireWaiterPanel,
                FireWaiterPanel,
                AddMenuItemPanel,
                RemoveMenuItemPanel,
                AddIngredientPanel,
                RestockIngredientPanel
            };

            ReportsDict = new[] {
                DailySalesPanel,
                MostOrderedFoodPanel,
                EotMPanel,
                EmployeeShiftsPanel,
                ProfitMadePanel
            };

            FireWaiterListLoad();
            RemoveMenuItemListLoad();
            RestockIngredientListLoad();

            DailySalesOutputTable.ColumnCount     = 3;
            DailySalesOutputTable.Columns[0].Name = "Product Name";
            DailySalesOutputTable.Columns[1].Name = "Total Sales";
            DailySalesOutputTable.Columns[2].Name = "Times Ordered";

            EotMOutputTable.ColumnCount     = 6;
            EotMOutputTable.Columns[0].Name = "First Name";
            EotMOutputTable.Columns[1].Name = "Last Name";
            EotMOutputTable.Columns[2].Name = "Hours Worked";
            EotMOutputTable.Columns[3].Name = "Orders Served";
            EotMOutputTable.Columns[4].Name = "Tips Earned";
            EotMOutputTable.Columns[5].Name = "Average Tip per Order";

            MostOrderedFoodOutputTable.ColumnCount     = 3;
            MostOrderedFoodOutputTable.Columns[0].Name = "Name";
            MostOrderedFoodOutputTable.Columns[1].Name = "Amount Sold";
            MostOrderedFoodOutputTable.Columns[2].Name = "Total Earnings";

            EmployeeShiftsOutputTable.ColumnCount     = 5;
            EmployeeShiftsOutputTable.Columns[0].Name = "First Name";
            EmployeeShiftsOutputTable.Columns[1].Name = "Last Name";
            EmployeeShiftsOutputTable.Columns[2].Name = "Hours Worked";
            EmployeeShiftsOutputTable.Columns[3].Name = "Employee Earnings";
            EmployeeShiftsOutputTable.Columns[4].Name = "Orders Served";

            ProfitMadeOutput.ColumnCount     = 7;
            ProfitMadeOutput.Columns[0].Name = "Year";
            ProfitMadeOutput.Columns[1].Name = "Month";
            ProfitMadeOutput.Columns[2].Name = "Total Earnings";
            ProfitMadeOutput.Columns[3].Name = "Employee Cost";
            ProfitMadeOutput.Columns[4].Name = "Ingredient Cost";
            ProfitMadeOutput.Columns[5].Name = "Month Profit";
            ProfitMadeOutput.Columns[6].Name = "Total Profit";
        }