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 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); } }