public TestBase(string testInfo)
        {
            string msg = $"{nameof(testInfo)} cannot be empty.";

            Check.NotNullOrEmptyOrWhitespace(testInfo, msg);

            string fileName = $"Data Source={testInfo}.sqlite";

            MenuValidator   menuValidator   = new MenuValidator();
            ModuleValidator moduleValidator = new ModuleValidator();

            DbContextOptions <ControlPanelContext> dbContext = new DbContextOptionsBuilder <ControlPanelContext>()
                                                               .UseSqlite(fileName)
                                                               .UseLoggerFactory(LoggerFactory)
                                                               .EnableDetailedErrors()
                                                               .EnableSensitiveDataLogging()
                                                               .Options;

            MenuBusinessLogic   = new MenuBusinessLogic(menuValidator, dbContext);
            ModuleBusinessLogic = new ModuleBusinessLogic(MenuBusinessLogic, moduleValidator, dbContext);

            using (ControlPanelContext ctx = new ControlPanelContext(dbContext))
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
            }
        }
        private void listBox1_Click(object sender, EventArgs e)
        {
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            int index = listBox1.SelectedIndex;

            if (listBox1.SelectedIndex != -1)
            {
                string     menuname = listBox1.SelectedItem.ToString();
                Model.Menu menu     = menuBusinessLogic.GetMenuByName(menuname);
                dataGridView1.Rows[cellRowIndex].Cells[0].Value = menuname;
                dataGridView1.Rows[cellRowIndex].Cells[2].Value = menu.Unit;
                dataGridView1.Rows[cellRowIndex].Cells[4].Value = menu.MenuQuote;
                dataGridView1.Rows[cellRowIndex].Cells[5].Value = menu.MenuRate;
                dataGridView1.Rows[cellRowIndex].Cells[6].Value = menu.MenuPrice;
            }
            if (dataGridView1.Rows[cellRowIndex].Cells[3].Value != null)
            {
                double totalMoney = 0;
                double count      = Convert.ToDouble(dataGridView1.Rows[cellRowIndex].Cells[3].Value);
                double price      = Convert.ToDouble(dataGridView1.Rows[cellRowIndex].Cells[6].Value);
                double money      = count * price;
                dataGridView1.Rows[cellRowIndex].Cells[7].Value = money;
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[7].Value != null)
                    {
                        money       = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value);
                        totalMoney += money;
                    }
                }
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[7].Value = totalMoney.ToString();
            }
            this.listBox1.DataSource = null;
            listBox1.Visible         = false;
        }
Beispiel #3
0
        public void Throw_ValidationException_WhenInputIsInvalid(
            int id,
            string name,
            string desc,
            int moduleId,
            int isActive,
            string menuRoute)
        {
            // Arrange
            DomainModel.Entities.Menu menu = new DomainModel.Entities.Menu
            {
                Id          = id,
                Name        = name,
                Description = desc,
                ModuleId    = moduleId,
                IsActive    = isActive,
                MenuRoute   = menuRoute,
            };

            // Act
            Func <Task> action = async() => { await MenuBusinessLogic.AddAsync(menu).ConfigureAwait(false); };

            // Assert
            action.Should().ThrowExactly <MenuBusinessLogicAddAsyncOperationException>()
            .WithInnerException <ValidationException>();
        }
Beispiel #4
0
        public async Task Add_Menu()
        {
            // Arrange
            DomainModel.Entities.Module module = new DomainModel.Entities.Module
            {
                Name        = "asd",
                Description = "desc",
                IsActive    = 1,
                ModuleRoute = "asd",
            };
            DomainModel.Entities.Module moduleResult = await ModuleBusinessLogic.AddAsync(module).ConfigureAwait(false);

            DomainModel.Entities.Menu menu = new DomainModel.Entities.Menu
            {
                Name        = "name",
                Description = "desc",
                ModuleId    = moduleResult.Id,
                IsActive    = 1,
                MenuRoute   = "asd",
            };

            // Act
            DomainModel.Entities.Menu menuResult = await MenuBusinessLogic.AddAsync(menu).ConfigureAwait(false);

            // Assert
            menuResult.Id.Should().BeGreaterThan(0);
            menuResult.Description.Should().Be(menu.Description);
            menuResult.Name.Should().Be(menu.Name);
            menuResult.IsActive.Should().Be(menu.IsActive);
            menuResult.ModuleId.Should().Be(menu.ModuleId);
            menuResult.MenuRoute.Should().Be(menu.MenuRoute);
        }
Beispiel #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            bool flag = false;

            if (deleteMenuIDList.Count == 0)
            {
                MessageBox.Show("请选择要删除的菜品!");
            }
            else
            {
                foreach (string MenuID in deleteMenuIDList)
                {
                    flag = menuBusinessLogic.DeleteMenuByMenuID(MenuID);
                }
                if (!flag)
                {
                    MessageBox.Show("删除失败!");
                }
                else
                {
                    MessageBox.Show("删除成功!");
                }
            }
            deleteMenuIDList.Clear();
            loadMenu();
        }
Beispiel #6
0
        private void listBox1_Click(object sender, EventArgs e)
        {
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            int index = listBox1.SelectedIndex;

            if (listBox1.SelectedIndex != -1)
            {
                string     menuname = listBox1.SelectedItem.ToString();
                Model.Menu menu     = menuBusinessLogic.GetMenuByName(menuname);
                dgvOrderCheck.Rows[cellRowIndex].Cells[3].Value = menuname;
                dgvOrderCheck.Rows[cellRowIndex].Cells[4].Value = menu.Unit;
                dgvOrderCheck.Rows[cellRowIndex].Cells[5].Value = menu.MenuQuote;
                dgvOrderCheck.Rows[cellRowIndex].Cells[6].Value = menu.MenuRate;
                dgvOrderCheck.Rows[cellRowIndex].Cells[7].Value = menu.MenuPrice;
            }
            if (dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value != null && dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value.ToString() != "")
            {
                string a = dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value.ToString();
                Console.Write(dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value);
                double count = Convert.ToDouble(dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value);
                double price = Convert.ToDouble(dgvOrderCheck.Rows[cellRowIndex].Cells[7].Value);
                double money = count * price;
                dgvOrderCheck.Rows[cellRowIndex].Cells[9].Value = money;
                computertotalMoney();
            }
            this.listBox1.DataSource = null;
            listBox1.Visible         = false;
        }
Beispiel #7
0
        private void dgvOrderCheck_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            cellRowIndex = e.RowIndex;
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            List <string>     menus             = new List <string>();

            if (e.ColumnIndex == 3 && e.RowIndex != -1)
            {
                if (dgvOrderCheck.Rows[e.RowIndex].Cells[3].Value != null)
                {
                    string menuname = dgvOrderCheck.Rows[e.RowIndex].Cells[3].Value.ToString();
                    menus = menuBusinessLogic.GetMenusByMenuName(menuname);
                    this.listBox1.DataSource = menus;
                    listBox1.Visible         = true;
                }
                else
                {
                    return;
                }
            }
            //输入菜品数量后自动求出金额
            if (e.ColumnIndex == 8 && e.RowIndex != -1)
            {
                double count = Convert.ToDouble(dgvOrderCheck.Rows[cellRowIndex].Cells[8].Value);
                double price = Convert.ToDouble(dgvOrderCheck.Rows[cellRowIndex].Cells[7].Value);
                double money = count * price;
                dgvOrderCheck.Rows[cellRowIndex].Cells[9].Value = money;
                computertotalMoney();
            }
        }
Beispiel #8
0
        private void loadMenu()
        {
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            List <Model.Menu> menuList          = new List <Model.Menu>();

            menuList           = menuBusinessLogic.GetAllMenu();
            dgvPlan.DataSource = menuList;
        }
 public UpdataMenuForm(string MenuID)
 {
     InitializeComponent();
     menuBusinessLogic = new MenuBusinessLogic();
     menu              = menuBusinessLogic.GetMenuByID(MenuID);
     txbMenuName.Text  = menu.MenuName;
     txbUint.Text      = menu.Unit;
     txbQuote.Text     = menu.MenuQuote.ToString();
     txbRate.Text      = menu.MenuRate.ToString();
     txbInputDate.Text = menu.InputDate.ToString();
 }
Beispiel #10
0
        public void Throw_NullInputException_WhenInputIsNull()
        {
            // Arrange

            // Act
            Func <Task> action = async() => { await MenuBusinessLogic.AddAsync(null).ConfigureAwait(false); };

            // Assert
            action.Should().ThrowExactly <MenuBusinessLogicAddAsyncOperationException>()
            .WithInnerException <MenuNullInputException>();
        }
 public OrderCheckForm(string orderID, Users user)
 {
     this.orderBusinessLogic     = new OrderBusinessLogic();
     this.mORBusinessLogic       = new MORBusinessLogic();
     this.menuBusinessLogic      = new MenuBusinessLogic();
     this.view_MenuBusinessLogic = new View_MenuBusinessLogic();
     InitializeComponent();
     this.user               = user;
     order                   = this.orderBusinessLogic.GetOrderByID(orderID);
     txbGroup.Text           = order.Department;
     txbCreator.Text         = order.Creator;
     txbStatus.Text          = order.Status;
     dtpOrderTime.Text       = order.InputDate.ToString();
     txbRemark.Text          = order.Remark;
     view_MenuList           = this.view_MenuBusinessLogic.GetView_MenuByOrderID(orderID);
     menu_Order_RList        = this.mORBusinessLogic.GetMORByOrderID(orderID);
     dgvOrderEdit.DataSource = view_MenuList;
     setColumn();
 }
        //单元格编辑完成事件,用于输入菜品后同时将菜品各种属性一起填写
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            cellRowIndex = e.RowIndex;
            MenuBusinessLogic menuBusinessLogic = new MenuBusinessLogic();
            List <string>     menus             = new List <string>();

            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                if (dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
                {
                    string menuname = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    menus = menuBusinessLogic.GetMenusByMenuName(menuname);
                    this.listBox1.DataSource = menus;
                    listBox1.Visible         = true;
                }
                else
                {
                    return;
                }
            }
            //输入菜品数量后自动求出金额
            if (e.ColumnIndex == 3 && e.RowIndex != -1)
            {
                double totalMoney = 0;
                double count      = Convert.ToDouble(dataGridView1.Rows[cellRowIndex].Cells[3].Value);
                double price      = Convert.ToDouble(dataGridView1.Rows[cellRowIndex].Cells[6].Value);
                double money      = count * price;
                dataGridView1.Rows[cellRowIndex].Cells[7].Value = money;
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[7].Value != null)
                    {
                        money       = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value);
                        totalMoney += money;
                    }
                }
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[7].Value = totalMoney.ToString();
            }
        }
Beispiel #13
0
        public async Task Delete_AnItem()
        {
            // Arrange
            DomainModel.Entities.Module module = new DomainModel.Entities.Module
            {
                Name = "asd", Description = "desc", IsActive = 1, ModuleRoute = "asd",
            };
            DomainModel.Entities.Module moduleResult = await ModuleBusinessLogic.AddAsync(module).ConfigureAwait(false);

            DomainModel.Entities.Menu menuActive = new DomainModel.Entities.Menu
            {
                Name        = "name",
                Description = "desc",
                IsActive    = 1,
                ModuleId    = 1,
                MenuRoute   = "asd",
            };
            DomainModel.Entities.Menu menuActiveResult =
                await MenuBusinessLogic.AddAsync(menuActive).ConfigureAwait(false);

            DomainModel.Entities.Menu menuInactive = new DomainModel.Entities.Menu
            {
                Name        = "name",
                Description = "desc",
                IsActive    = 0,
                ModuleId    = 1,
                MenuRoute   = "asd",
            };
            DomainModel.Entities.Menu menuInactiveResult =
                await MenuBusinessLogic.AddAsync(menuInactive).ConfigureAwait(false);

            // Act
            await MenuBusinessLogic.DeleteAsync(menuInactiveResult).ConfigureAwait(false);

            List <DomainModel.Entities.Menu> result = await MenuBusinessLogic.GetAllAsync().ConfigureAwait(false);

            // Assert
            result.Count.Should().Be(1);
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            MenuBusinessLogic  menuBusinessLogic  = new MenuBusinessLogic();
            OrderBusinessLogic orderBusinessLogic = new OrderBusinessLogic();
            MORBusinessLogic   mORBusinessLogic   = new MORBusinessLogic();
            Order order = new Order();
            bool  flag  = orderBusinessLogic.IscontainOrder(txbOrderNumber.Text.Trim());

            if (flag)
            {
                MessageBox.Show("订单已存在!", "提示");
                return;
            }
            if (dataGridView1.Rows[0].Cells[0].Value == null)
            {
                MessageBox.Show("订单不能为空!", "提示");
                return;
            }
            if (dataGridView1.Rows[cellRowIndex].Cells[0].Value != null && dataGridView1.Rows[cellRowIndex].Cells[3].Value == null)
            {
                MessageBox.Show("数量不能为空!", "提示");
                return;
            }
            if (dataGridView1.Rows[cellRowIndex].Cells[0].Value == null && dataGridView1.Rows[cellRowIndex].Cells[3].Value != null)
            {
                MessageBox.Show("请填写菜品!", "提示");
                return;
            }
            order.OrderID     = Guid.NewGuid().ToString();
            order.OrderNumber = txbOrderNumber.Text.Trim();
            order.Department  = txbDepartment.Text.Trim();
            order.Creator     = txbCreater.Text.Trim();
            order.InputDate   = Convert.ToDateTime(txbOrderDate.Text.Trim());
            order.TotalMoney  = Convert.ToDouble(this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[7].Value);
            order.Status      = "未发送";
            orderBusinessLogic.AddOrder(order);
            int count = dataGridView1.Rows.Count;

            for (int i = 0; i < count - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null && dataGridView1.Rows[i].Cells[3].Value != null)
                {
                    string      menuName = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    Model.Menu  menu     = menuBusinessLogic.GetMenuByName(menuName);
                    MenuOrder_R MOR      = new MenuOrder_R();
                    MOR.MenuOrderID = Guid.NewGuid().ToString();
                    MOR.OrderID     = order.OrderID;
                    MOR.MenuName    = menu.MenuName;
                    MOR.Unit        = menu.Unit;
                    MOR.InputDate   = Convert.ToDateTime(txbOrderDate.Text.Trim());
                    MOR.Money       = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value);
                    MOR.Quote       = menu.MenuQuote;
                    MOR.Rate        = menu.MenuRate;
                    MOR.Price       = menu.MenuPrice;
                    MOR.Count       = Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value);
                    //MOR.Remark = null;
                    mORBusinessLogic.AddMOR(MOR);
                }
            }
            MessageBox.Show("提交成功!", "提示");
        }
Beispiel #15
0
        private void btnSaveMenu_Click(object sender, EventArgs e)
        {
            MenuBusinessLogic  menuBusinessLogic  = new MenuBusinessLogic();
            PriceBusinessLogic priceBusinessLogic = new PriceBusinessLogic();

            Model.Menu menu = new Model.Menu();
            menu.MenuID = Guid.NewGuid().ToString();
            if (txbMenuName.Text.Trim() != "")
            {
                menu.MenuName = txbMenuName.Text.Trim();
                if (menuBusinessLogic.GetMenuByName(menu.MenuName) != null)
                {
                    MessageBox.Show("该菜品已存在,不能重复添加!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("菜品名称不能为空!");
                return;
            }

            if (txbUint.Text.Trim() == "")
            {
                MessageBox.Show("菜品单价不能为空!");
                return;
            }
            else
            {
                menu.Unit = txbUint.Text.Trim();
            }
            double Quote = 0;

            if (!double.TryParse(txbQuote.Text.Trim(), out Quote))
            {
                MessageBox.Show("报价处请输入数字!");
                return;
            }
            menu.MenuQuote = Quote;
            double Rate = 1.0;

            if (!double.TryParse(txbRate.Text.Trim(), out Rate))
            {
                MessageBox.Show("请输入优惠率!");
                return;
            }
            menu.MenuRate  = Rate;
            menu.MenuPrice = Quote * Rate;
            menu.InputDate = DateTime.Now;

            Price price = new Price();

            price.PriceID   = Guid.NewGuid().ToString();
            price.MenuID    = menu.MenuID;
            price.Quote     = Quote;
            price.Rate      = Rate;
            price.Price1    = Quote * Rate;
            price.InputDate = Convert.ToDateTime(menu.InputDate);
            if (menuBusinessLogic.AddMenu(menu) && priceBusinessLogic.AddPrice(price))
            {
                MessageBox.Show("添加成功!");
                txbMenuName.Clear();
                txbUint.Clear();
                txbQuote.Clear();
                txbRate.Clear();
                loadMenu();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }