/** * 加载所有菜品信息 * */ private void LoadAllDishes() { int count = DishList.Items.Count; for (int i = 0; i < count; i++) { DishList.Items.RemoveAt(0); } dishes = DishInfoConnector.GetDishes(); foreach (Dish dish in dishes) { InformationTable3 information = new InformationTable3(); information.Left_TB.Text = dish.DTitle; information.Mid_TB.Text = DishInfoConnector.GetTypeData(dish.DTypeId).DtTitle; information.Right_TB.Text = dish.DPrice.ToString(); DishList.Items.Add(information); } SearchDishTypeCombo.SelectedIndex = 0; }
//加载菜品 private void LoadDishList(int DTypeId) { while (listDishGrid.Children.Count > 0) { listDishGrid.Children.RemoveRange(0, 3); foreach (orderGrid order in listDishGrid.Children) { Grid.SetRow(order, (Grid.GetRow(order) - 1)); } } List <Dish> dishes = DishInfoConnector.GetDishes(DTypeId); int i = dishes.Count; int rows; if (i / 2 == 0) { rows = i / 2; } else { rows = i / 2 + 1; } RowDefinition[] row = new RowDefinition[i]; for (int tk = 0; tk < i; tk++) { row[tk] = new RowDefinition(); listDishGrid.RowDefinitions.Add(row[tk]); } int k = 0; foreach (Dish dish in dishes) { orderGrid order = new orderGrid(dish); order.button1.Click += Button1_Click; listDishGrid.Children.Add(order); Grid.SetRow(order, k / 2); Grid.SetColumn(order, k % 2 == 0 ? 0 : 1); k++; } }