Example #1
0
        /*
         * 删除选中
         * 判断选中=》删除
         * */
        private void DeleteDishButton_Click(object sender, RoutedEventArgs e)
        {
            if (DishList.SelectedIndex == -1)
            {
                MessageBox.Show("未选中任何菜品");
                return;
            }


            int DeleteDishResult = DishInfoConnector.DeleteDish(ModifyDishName.Text, ModifyDishTypeCombo.SelectedIndex + 1);

            if (DeleteDishResult == 1)
            {
                MessageBox.Show("删除成功");
                DishList.SelectedIndex            = -1;
                ModifyDishName.Text               = "";
                ModifyDishPrice.Text              = "";
                ModifyDishTypeCombo.IsEnabled     = true;
                ModifyDishTypeCombo.SelectedIndex = 0;
                ModifyDishTypeCombo.IsEnabled     = false;
                LoadAllDishes();
            }
            else
            {
                MessageBox.Show("删除失败");
                return;
            }
        }
Example #2
0
        /**
         * 删除选中
         * 未分类菜系不能删除
         * 不必查存在,直接删除
         * */
        private void DeleteTypeButton_Click(object sender, RoutedEventArgs e)
        {
            if (DishTypeList.SelectedIndex == -1)
            {
                MessageBox.Show("未选择任何项");
                return;
            }
            if (DishTypeList.SelectedIndex == 0)
            {
                MessageBox.Show("未分类菜系不能删除");
                return;
            }
            ListBoxItem listBoxItem  = (ListBoxItem)DishTypeList.SelectedItem;
            String      DTitle       = (String)listBoxItem.Content;
            int         DeleteResult = DishInfoConnector.DeleteDishType(DTitle);

            if (DeleteResult == 1)
            {
                MessageBox.Show("删除成功");
                LoadAllDishType();
            }
            else
            {
                MessageBox.Show("删除失败");
            }
        }
Example #3
0
        private void ModifyButton_Click(object sender, RoutedEventArgs e)
        {
            if (ModifyDishPrice.Text == "")
            {
                MessageBox.Show("价格不能为空");
                return;
            }
            if (!double.TryParse(ModifyDishPrice.Text, out double DPrice))
            {
                MessageBox.Show("价格格式不正确");
                return;
            }

            int ModifyResult =
                DishInfoConnector.ModifyDishPrice(ModifyDishName.Text,
                                                  ModifyDishTypeCombo.SelectedIndex + 1,
                                                  double.Parse(ModifyDishPrice.Text));

            if (ModifyResult == 1)
            {
                MessageBox.Show("修改成功");
                DishList.SelectedIndex            = -1;
                ModifyDishName.Text               = "";
                ModifyDishPrice.Text              = "";
                ModifyDishTypeCombo.IsEnabled     = true;
                ModifyDishTypeCombo.SelectedIndex = 0;
                ModifyDishTypeCombo.IsEnabled     = false;
                LoadAllDishes();
            }
            else
            {
                MessageBox.Show("修改失败");
                return;
            }
        }
        /*
         * 将订单加入已点列表的方法
         * */
        private void AddOrder(String DTitle, int number)
        {
            int index = 0;

            foreach (AddOrderTmp orderTmp in addOrders)
            {
                if (DTitle == orderTmp.DTitle)
                {
                    //列表中已经存在的项目,把数量加一下然后退出
                    addOrders[index].DNumber = (int.Parse(addOrders[index].DNumber) + number).ToString();
                    OrderContainer container = new OrderContainer(addOrders[index]);
                    //ListBox方法里面没有替换,只能是先删除然后插入
                    OrderList.Items.RemoveAt(index);
                    ListBoxItem boxItem = new ListBoxItem();
                    boxItem.Content = container;
                    OrderList.Items.Insert(index, boxItem);
                    CountPriceSummary();
                    return;
                }
                index++;
            }
            Dish           dish           = DishInfoConnector.GetDish(DTitle.Trim());
            AddOrderTmp    addOrder       = new AddOrderTmp(DTitle, dish.DPrice.ToString(), number.ToString());
            OrderContainer orderContainer = new OrderContainer(addOrder);

            orderContainer.CancelButton.Click += DeleteThisOrderItem;
            ListBoxItem item = new ListBoxItem();

            item.Content = orderContainer;
            OrderList.Items.Add(item);
            addOrders.Add(addOrder);    //用addOrders存储已点的菜品
            CountPriceSummary();
        }
Example #5
0
        /**
         * 加载所有菜系
         * */
        private void LoadAllDishTypes()
        {
            List <DishTypeData> dishTypeDatas = DishInfoConnector.GetDishTypeDatas();

            foreach (DishTypeData typeData in dishTypeDatas)
            {
                AddDishType.Items.Add(typeData.DtTitle);
            }
            AddDishType.SelectedIndex = 0;
        }
Example #6
0
        /**
         * 加载所有的菜系信息
         * */
        private void LoadAllDishType()
        {
            List <DishTypeData> dishTypeDatas = DishInfoConnector.GetDishTypeDatas();

            ModifyDishTypeCombo.IsEnabled = true;
            foreach (DishTypeData typeData in dishTypeDatas)
            {
                SearchDishTypeCombo.Items.Add(typeData.DtTitle);
                ModifyDishTypeCombo.Items.Add(typeData.DtTitle);
            }
            ModifyDishTypeCombo.IsEnabled = false;
        }
Example #7
0
        /**
         * 选中菜品的时候把菜品信息显示在右侧
         * */
        private void DishList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DishList.SelectedIndex == -1)
            {
                return;
            }
            ModifyDishName.Text  = ((InformationTable3)DishList.SelectedItem).Left_TB.Text;
            ModifyDishPrice.Text = ((InformationTable3)DishList.SelectedItem).Right_TB.Text;

            String DTitle = ((InformationTable3)DishList.SelectedItem).Mid_TB.Text;
            int    DtId   = DishInfoConnector.GetDish(((InformationTable3)DishList.SelectedItem).Left_TB.Text).DTypeId;

            ModifyDishTypeCombo.IsEnabled     = true;
            ModifyDishTypeCombo.SelectedIndex = DtId;
            ModifyDishTypeCombo.IsEnabled     = false;
        }
        /*
         * 动态加载菜系的方法
         * */
        private void AddDishTypeList()
        {
            List <ListBoxItem> listBoxItems = new List <ListBoxItem>();

            dishTypeDatas = DishInfoConnector.GetDishTypeDatas();
            foreach (DishTypeData dishType in dishTypeDatas)
            {
                ListBoxItem item = new ListBoxItem
                {
                    Content  = dishType.DtTitle.Trim(),
                    MaxWidth = 45,
                    FontSize = 10
                };
                listBoxItems.Add(item);
            }

            DishTypeList.ItemsSource = listBoxItems;
        }
Example #9
0
        /*
         * 添加菜单的事件
         * 1. 判断输入框是否为空
         * 2. 判断图片是否选择
         * 3. 判断价格的输入是否正确
         * 4. 判断是否数据已存在(后台)
         * */
        private void AddDishButton_Click(object sender, RoutedEventArgs e)
        {
            if (AddDishName.Text == "" || AddDishPrice.Text == "")
            {
                MessageBox.Show("信息填写不完整");
                return;
            }
            if (openFileDialog == null)
            {
                MessageBox.Show("图片未选择");
                return;
            }

            if (!double.TryParse(AddDishPrice.Text, out double DPrice))
            {
                MessageBox.Show("价格格式不正确");
                return;
            }

            byte[] bytesOfPic = File.ReadAllBytes(openFileDialog.FileName);
            int    AddResult  = DishInfoConnector.InsertDish(AddDishName.Text, AddDishType.SelectedIndex, DPrice, ref bytesOfPic);

            if (AddResult == -1)
            {
                MessageBox.Show("已存在的菜品");
                return;
            }
            if (AddResult == 1)
            {
                MessageBox.Show("添加成功");
                AddDishName.Text          = "";
                AddDishPrice.Text         = "";
                openFileDialog            = null;
                DishImage.Source          = null;
                ImagePathLabel.Content    = null;
                AddDishType.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("添加失败");
                return;
            }
        }
Example #10
0
        /**
         * 加载所有菜品信息
         * */
        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;
        }
Example #11
0
        /*
         * 加载所有菜系
         * */
        private void LoadAllDishType()
        {
            int count = DishTypeList.Items.Count;

            for (int i = 0; i < count; i++)
            {
                DishTypeList.Items.RemoveAt(0);
            }
            dishTypeDatas = DishInfoConnector.GetDishTypeDatas();
            foreach (DishTypeData typeData in dishTypeDatas)
            {
                ListBoxItem listBoxItem = new ListBoxItem()
                {
                    Content    = typeData.DtTitle,
                    FontSize   = 14,
                    Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255))
                };
                DishTypeList.Items.Add(listBoxItem);
            }
        }
        //加载菜品
        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++;
            }
        }
Example #13
0
        /**
         * 添加菜系
         * 查空,查重,插入
         * */
        private void AddTypeButton_Click(object sender, RoutedEventArgs e)
        {
            if (AddTypeName.Text == "")
            {
                MessageBox.Show("菜系名为空");
                return;
            }

            int InsertResult = DishInfoConnector.InsertDishType(AddTypeName.Text);

            if (InsertResult == 1)
            {
                MessageBox.Show("插入成功");
                AddTypeName.Text = "";
                LoadAllDishType();
            }
            else
            {
                MessageBox.Show("插入失败");
                return;
            }
        }