Example #1
0
 private void SearchFood()
 {
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(tbSearch.Text.Trim());
     {
         pnFood.Controls.Clear();
         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 > 64)
                     return;
                 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), 5 + i * height / 9);
                     lb.Click += lb_Click;
                     pnFood.Controls.Add(lb);
                 }
             }
         }
     }
 }
Example #2
0
 private void SearchFoodByName()
 {
     dvAllFood.Rows.Clear();
     string searchStr = tbFoodSearchStr.Text.Trim();
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(searchStr);
     foreach (Food food in foods)
     {
         dvAllFood.Rows.Add(food.foodid, food.cnName, food.enName, food.des, food.price, food.category, food.canDiscount, food.status, food.unit, food.isPlan, food.createTime, food.updateTime, food.imageUpdateTime, food.delTime, food.needKC, food.needMaterials);
     }
 }
Example #3
0
 private void tbSearchStr_TextChanged(object sender, EventArgs e)
 {
     dvFood.Rows.Clear();
     FoodService service = new FoodService();
     List<Food> foods = service.GetAllFoodByName(tbSearchStr.Text.Trim());
     foreach (Food food in foods)
     {
         dvFood.Rows.Add(food.foodid, food.cnName, food.enName, food.price, food.category, food.unit);
     }
 }