コード例 #1
0
 private void setupUI()
 {
     if (FoodData == null)
     {
         return;
     }
     TextBlockName.Text     = FoodData.FoodId + " - " + FoodData.Name;
     TextBlockPrice.Text    = UtilFuction.formatMoney(FoodData.Price) + " vnđ";
     TextBlockCategory.Text = FoodCategorizeManager.getInstance().FoodCategorizeList[FoodData.FoodCategorizeId].Name;
 }
コード例 #2
0
        private void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(TextBoxName.Text))
            {
                WindownsManager.getInstance().showMessageBoxCheckInfoAgain();
                return;
            }
            loadingAnim.Visibility = Visibility.Visible;
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    if (_foodTab != null)
                    {
                        _foodTab.reloadCategoryTableUI();
                        _foodTab.reloadFoodTableUI(true);
                    }
                    this.Close();
                }
                loadingAnim.Visibility = Visibility.Hidden;
            };

            Action <string> cbError =
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                loadingAnim.Visibility = Visibility.Hidden;
            };

            if (_foodWithCategorizeDetailId != Constant.ID_CREATE_NEW)
            {
                FoodCategorizeManager.getInstance().updateFoodCategorizeFromServerAndUpdate(
                    _foodWithCategorizeDetailId,
                    TextBoxName.Text,
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                FoodCategorizeManager.getInstance().createFoodCategorizeFromServerAndUpdate(
                    TextBoxName.Text,
                    cbSuccessSent,
                    cbError
                    );
            }
        }
コード例 #3
0
        private void setupUI()
        {
            var foodWithCategorizeId = _foodWithCategorizeDetailId;

            if (foodWithCategorizeId != Constant.ID_CREATE_NEW)
            {
                var foodWithCategorizeData = FoodCategorizeManager.getInstance().FoodCategorizeList[foodWithCategorizeId];
                TextBoxId.Text   = foodWithCategorizeData.FoodCategoryId.ToString();
                TextBoxName.Text = foodWithCategorizeData.Name;

                this.Title = "Chi tiết loại món";
                //TextBlockNameWindow.Text = "Chi tiết loại món";
                BtnConfirm.Content = "Sửa";
            }
        }
コード例 #4
0
        public void reloadCategoryTableUI(bool isReloadFromServer = false, Action cbAfterReload = null)
        {
            if (isReloadFromServer)
            {
                RequestManager.getInstance().showLoading();
                Action <NetworkResponse> cbSuccessSent =
                    delegate(NetworkResponse networkResponse) {
                    RequestManager.getInstance().hideLoading();
                    if (!networkResponse.Successful)
                    {
                        WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                    }
                    else
                    {
                        reloadCategoryTableUI(false, cbAfterReload);
                    }
                };

                Action <string> cbError =
                    delegate(string err) {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                    RequestManager.getInstance().hideLoading();
                };
                FoodCategorizeManager.getInstance().getAllFoodCategorizeFromServerAndUpdate(
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                categoryListTable.Clear();
                foreach (KeyValuePair <int, FoodCategorize> entry in FoodCategorizeManager.getInstance().FoodCategorizeList)
                {
                    if (entry.Value != null)
                    {
                        categoryListTable.Add(new CategoryTable()
                        {
                            Id   = entry.Value.FoodCategorizeId,
                            Name = entry.Value.Name
                        });
                    }
                }
                cbAfterReload?.Invoke();
            }
        }
コード例 #5
0
        private void BtnRemoveCategory_Click(object sender, RoutedEventArgs e)
        {
            var mesResult = WindownsManager.getInstance().showMessageBoxConfirmDelete();

            if (mesResult == MessageBoxResult.No)
            {
                return;
            }

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                    RequestManager.getInstance().hideLoading();
                }
                else
                {
                    reloadCategoryTableUI();
                    reloadFoodTableUI(true);
                }
            };

            Action <string> cbError =
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                RequestManager.getInstance().hideLoading();
            };

            CategoryTable categoryTable = DataGridCategory.SelectedItem as CategoryTable;

            FoodCategorizeManager.getInstance().deleteFoodCategorizeFromServerAndUpdate(
                categoryTable.Id,
                cbSuccessSent,
                cbError
                );
        }
コード例 #6
0
        private void setupUI()
        {
            var foodId = _foodDetailId;

            var categorizeNames = new List <ComboData>();

            foreach (KeyValuePair <int, FoodCategorize> entry in FoodCategorizeManager.getInstance().FoodCategorizeList)
            {
                if (entry.Value != null)
                {
                    categorizeNames.Add(new ComboData()
                    {
                        Id = entry.Key, Value = entry.Value.Name
                    });
                }
            }
            ComboBoxCategory.ItemsSource       = categorizeNames;
            ComboBoxCategory.DisplayMemberPath = "Value";
            ComboBoxCategory.SelectedValuePath = "Id";

            var ingredientsName = new List <ComboData>();

            foreach (KeyValuePair <int, Ingredient> entry in IngredientManager.getInstance().IngredientList)
            {
                if (entry.Value != null)
                {
                    ingredientsName.Add(new ComboData()
                    {
                        Id = entry.Key, Value = entry.Value.Name
                    });
                }
            }
            ComboBoxIngredient.ItemsSource       = ingredientsName;
            ComboBoxIngredient.DisplayMemberPath = "Value";
            ComboBoxIngredient.SelectedValuePath = "Id";

            if (foodId != Constant.ID_CREATE_NEW)
            {
                var foodData = FoodManager.getInstance().FoodList[foodId];
                setupUIWithFoodData(foodData);

                BtnConfirm.Content = "Sửa";
                Title = "Sửa chi tiết món";
                TextBlockTile.Text = "Sửa chi tiết món";

                TextBlockId.Visibility      = Visibility.Visible;
                TextBoxId.Visibility        = Visibility.Visible;
                BtnCopy.Visibility          = Visibility.Collapsed;
                ComboBoxFoodCopy.Visibility = Visibility.Collapsed;
            }
            else
            {
                foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList)
                {
                    if (entry.Value != null)
                    {
                        string txt    = entry.Value.FoodId + " - " + entry.Value.Name;
                        var    imgSrc = (ImageSource)Application.Current.FindResource("ImageDefaultFood");
                        if (entry.Value.ImageId != null)
                        {
                            byte[] imgData = null;
                            ImageManager.getInstance().loadImageFromLocal(entry.Value.ImageId ?? default(int), out imgData);
                            if (imgData != null)
                            {
                                var img = UtilFuction.ByteToImage(imgData);
                                imgSrc = UtilFuction.imageToBitmapSource(img);
                            }
                        }
                        var item = ComboBoxFoodCopy.addItem(txt, imgSrc);
                        item.Tag = entry.Value.FoodId;
                    }
                }
            }
        }