private void lbAddCategory_Click(object sender, EventArgs e) { string categoryName = tbCategoryName.Text.Trim(); if (categoryName == "") { MessageBox.Show("分类名称不能为空!"); } else { FoodCategory category = new FoodCategory(); category.categoryName = categoryName; category.categoryBelong = cbCategoryBelong.Text.Trim(); FoodCategoryService service = new FoodCategoryService(); service.AddCategory(category); this.DialogResult = System.Windows.Forms.DialogResult.OK; } }
private void InitCategory() { FoodCategoryService service = new FoodCategoryService(); List<FoodCategory> categorys = service.GetAllCategory(); foreach (FoodCategory c in categorys) { cbCategory.Items.Add(c.categoryName); } cbCategory.SelectedIndex = 0; }
private void 删除分类ToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = tvFoodCate.SelectedNode; string category = node.Text; if (category.Equals("厨房") || category.Equals("酒吧")) { MessageBox.Show("非法操作!"); } else { FoodCategoryService service = new FoodCategoryService(); service.DelCategory(category); InitTvFoodCate(); } }
private void tvFoodCate_AfterSelect(object sender, TreeViewEventArgs e) { string category = e.Node.Text; if (category.Equals("厨房") || category.Equals("酒吧")) { FoodCategoryService service = new FoodCategoryService(); List<FoodCategory> categorys = service.GetAllCategoryByBelong(category); TreeNode node = tvFoodCate.SelectedNode; node.Nodes.Clear(); foreach (FoodCategory cate in categorys) { node.Nodes.Add(new TreeNode(cate.categoryName)); } node.Expand(); } else { SearchFood(category); } }
private void InitTvFoodCate() { tvFoodCate.Nodes.Clear(); TreeNode node0 = new TreeNode("厨房"); tvFoodCate.Nodes.Add(node0); FoodCategoryService service = new FoodCategoryService(); List<FoodCategory> categorys = service.GetAllCategoryByBelong("厨房"); foreach (FoodCategory cate in categorys) { node0.Nodes.Add(new TreeNode(cate.categoryName)); } node0.Expand(); categorys = service.GetAllCategoryByBelong("酒吧"); TreeNode node1 = new TreeNode("酒吧"); tvFoodCate.Nodes.Add(node1); foreach (FoodCategory cate in categorys) { node1.Nodes.Add(new TreeNode(cate.categoryName)); } node1.Expand(); }
private void FormOrder_Load(object sender, EventArgs e) { JudgeRights(); lbTabInfo.Text = ("餐桌号--" + tabName); // 查询是否有账单信息 加载账单信息 InitBillInfo(); CalcBillMoney(); FoodCategoryService service = new FoodCategoryService(); List<FoodCategory> categorys = service.GetAllCategory(); FoodService foodService = new FoodService(); foreach (FoodCategory c in categorys) { TabPage page = new TabPage(); page.Text = c.categoryName; List<Food> foods = foodService.GetAllFoodByCategory(c.categoryName); int width = tabCategory.Width; int height = tabCategory.Height; int lbWidth = width / 9; int lbHeight = height / 12; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { int cco = i * 8 + j; if (cco < foods.Count) { Label lb = new Label(); lb.Text = foods[cco].cnName; lb.Tag = foods[cco].foodid; lb.ForeColor = Color.White; lb.BackColor = Color.LightGreen; lb.TextAlign = ContentAlignment.MiddleCenter; lb.BorderStyle = BorderStyle.FixedSingle; //lb.AutoSize = false; lb.Size = new Size(lbWidth, lbHeight); lb.Location = new Point(10 + j * (int)(width / 8.2), 15 + i * height / 9); lb.Click += lb_Click; page.Controls.Add(lb); } } } tabCategory.TabPages.Add(page); } }