Beispiel #1
0
        public void TestCRUDOrder()
        {
            string customerName = "AnLe";

            List <Department> departments = departmentBLL.ListDepartment();
            List <Employee>   employees   = employeeBLL.ListEmployeeByDepartment(departments[0]);

            List <Menu>     menus     = menuBLL.ListMenu();
            List <MenuItem> menuItems = menuItemBLL.FindByMenuID(menus[0]);

            List <OrderDetail> listOrderDetail = new List <OrderDetail>();

            listOrderDetail.Add(new OrderDetail
            {
                OrderID    = 0,
                MenuItemID = menuItems[0].ID,
                Price      = menuItems[0].Price,
                Quantity   = 10
            });
            listOrderDetail.Add(new OrderDetail
            {
                OrderID    = 0,
                MenuItemID = menuItems[1].ID,
                Price      = menuItems[1].Price,
                Quantity   = 20
            });
            listOrderDetail.Add(new OrderDetail
            {
                OrderID    = 0,
                MenuItemID = menuItems[2].ID,
                Price      = menuItems[2].Price,
                Quantity   = 30
            });

            List <Area>  areas     = areaBLL.ListArea();
            List <Table> allTables = tableBLL.ListTablesByArea(areas[0]);

            List <Table> tables = new List <Table>();

            tables.Add(allTables[0]);

            Order orderExpected = orderBLL.CreateOrder(employees[0], tables, customerName, listOrderDetail);

            Order currentOrder = orderBLL.GetCurrentOrderByTable(allTables[0]);

            Assert.AreEqual(currentOrder.CustomerName, customerName);
            Assert.AreEqual(currentOrder.EmployeeID, employees[0].ID);

            allTables = tableBLL.ListTablesByArea(areas[0]);

            Assert.AreEqual(1, allTables[0].Status);
            Assert.AreEqual(currentOrder.ID, orderExpected.ID);

            TestAddFood(currentOrder);
        }
Beispiel #2
0
        public void TestCRUDMenuItem()
        {
            List <Menu> menus = menuBLL.ListMenu();

            int    menuIDTest     = menus[0].ID;
            string nameTest       = "Phá lấu bò gà heo";
            int    priceTest      = 30000;
            int    priceAfterTest = 25000;
            string rootPath       = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName;

            byte[] imageTest = File.ReadAllBytes(rootPath + "/data/images/com-chien-ca-man.jpg");

            MenuItem menuItemTest = new MenuItem();

            menuItemTest.MenuID     = menuIDTest;
            menuItemTest.Name       = nameTest;
            menuItemTest.Price      = priceTest;
            menuItemTest.PriceAfter = priceAfterTest;
            menuItemTest.Image      = imageTest;

            MenuItem        menuItemExpected = menuItemBLL.CreateMenuItem(menuItemTest);
            bool            isCreated        = false;
            List <MenuItem> menuItems        = menuItemBLL.FindByMenuID(menus[0]);

            for (int i = 0; i < menuItems.Count; i++)
            {
                if (menuItemExpected.ID == menuItems[i].ID &&
                    menuItemExpected.MenuID == menuItems[i].MenuID &&
                    menuItemExpected.Name == menuItems[i].Name &&
                    menuItemExpected.Price == menuItems[i].Price &&
                    menuItemExpected.PriceAfter == menuItems[i].PriceAfter &&
                    menuItemExpected.Image == imageTest)
                {
                    isCreated = true;
                }
            }

            Assert.AreEqual(true, isCreated);

            TestUpdateMenuItem(menuItemExpected);
        }
Beispiel #3
0
        private void LoadData()
        {
            MenuBLL         menuBLL = new MenuBLL();
            List <DAL.Menu> menus   = menuBLL.ListMenu();

            //lsCategory.DataSource = listMenuItem; problem

            this.tabControl.Controls.Clear();
            foreach (DAL.Menu menu in menus)
            {
                var t = new TabPage();
                t.Location = new Point(4, 22);
                //t.Name = menu.Name;
                t.Name    = menu.Name;
                t.Padding = new Padding(3);
                t.Size    = new Size(597, 257);
                t.Font    = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
                t.Text    = menu.Name;
                t.UseVisualStyleBackColor = true;
                t.AutoScroll = true;
                t.Tag        = menu;
                this.tabControl.Controls.Add(t);

                // add layout
                FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
                flowLayoutPanel.Dock       = DockStyle.Fill;
                flowLayoutPanel.AutoScroll = true;
                t.Controls.Add(flowLayoutPanel);

                // add menu item
                MenuItemBLL menuItemBLL = new MenuItemBLL();
                //List<DAL.MenuItem> menuItems = menuItemBLL.FindByMenuID(menu);
                List <DAL.MenuItem> menuItems = menuItemBLL.FindByMenuID(menu);
                //lsCategory.DataSource = listMenuItem;
                for (int i = 0; i < menuItems.Count; i++)
                {
                    MenuItemControl menuItemControl = new MenuItemControl(menuItems[i], false);
                    menuItemControl.Tag       = i;
                    menuItemControl.OnEdit   += new MenuItemControl.OnEditHandler(this.menuItemControl_OnEdit);
                    menuItemControl.OnDelete += new MenuItemControl.OnDeleteHandler(this.menuItemControl_OnDelete);
                    flowLayoutPanel.Controls.Add(menuItemControl);
                    //menuItemControl.Click += new EventHandler(this.MenuItem_OnClick);
                }
            }
        }
Beispiel #4
0
        private void LoadData()
        {
            this.lbTable.Text = this.getTableName();

            // Get order
            if (this.Tables[0].Status != 0)
            {
                // had created order
                OrderBLL orderBLL = new OrderBLL();
                this.order = orderBLL.GetCurrentOrderByTable(this.Tables[0]);
                if (order != null)
                {
                    foreach (OrderDetail od in this.order.OrderDetails)
                    {
                        this.NewSelectMenuItem(od.MenuItem, (int)od.Quantity, od);
                    }

                    // get order tables
                    this.Tables.Clear();
                    foreach (var od in this.order.OrderTables)
                    {
                        this.Tables.Add(od.Table);
                    }
                    this.lbTable.Text = this.getTableName();

                    this.OldTables = new List <Table>(this.Tables);
                }

                this.txtCustomerName.Text = this.order.CustomerName;

                this.calculateFoodPrice();
                this.calculateDiscount();
                this.Extra = this.order.Extra == null ? 0 : (decimal)this.order.Extra;
                if (this.order.VAT != null)
                {
                    this.VAT = (decimal)this.order.VAT;
                }
            }

            // Load menu
            MenuBLL         menuBLL = new MenuBLL();
            List <DAL.Menu> menus   = menuBLL.ListMenu();

            this.tabControl.Controls.Clear();

            foreach (DAL.Menu menu in menus)
            {
                var t = new TabPage();
                t.Location = new Point(4, 22);
                t.Name     = menu.Name;
                t.Padding  = new Padding(3);
                t.Size     = new Size(597, 257);
                t.Font     = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
                t.Text     = menu.Name;
                t.UseVisualStyleBackColor = true;
                t.AutoScroll = true;
                this.tabControl.Controls.Add(t);

                // add layout
                FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
                flowLayoutPanel.Dock       = DockStyle.Fill;
                flowLayoutPanel.AutoScroll = true;
                t.Controls.Add(flowLayoutPanel);

                // add menu item
                MenuItemBLL         menuItemBLL = new MenuItemBLL();
                List <DAL.MenuItem> menuItems   = menuItemBLL.FindByMenuID(menu);
                for (int i = 0; i < menuItems.Count; i++)
                {
                    MenuItemControl menuItemControl = new MenuItemControl(menuItems[i]);
                    menuItemControl.Tag = i;
                    flowLayoutPanel.Controls.Add(menuItemControl);
                    menuItemControl.Click += new EventHandler(this.MenuItem_OnClick);
                }
            }

            // Show/Hide bottom buttonBar
            if (this.order == null)
            {
                this.layoutButton.Hide();
                this.tabControl.Height += this.layoutButton.Height;
            }
        }