public void getFromServerAndReloadUI(Action cb = null)
        {
            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    reloadListViewBill(true);
                }
                cb?.Invoke();
                RequestManager.getInstance().hideLoading();
            };

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

            ImportBillManager.getInstance().getAllImportBillFromServerAndUpdate(
                cbSuccessSent,
                cbError
                );
        }
Beispiel #2
0
        private void BtnRemoveTable_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            int oldTableId = ((TableInfo)LVTable.SelectedItem).TableData.TableId;

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

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

            TableManager.getInstance().deleteTableromServerAndUpdate(
                oldTableId,
                cbSuccessSent,
                cbError
                );
        }
        public void reloadOrderUI(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
                    {
                        reloadOrderUI(false, cbAfterReload);
                    }
                };

                Action <string> cbError =
                    delegate(string err) {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                    RequestManager.getInstance().hideLoading();
                };
                OrderManager.getInstance().getAllOrderFromServerAndUpdate(
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                cbAfterReload?.Invoke();
            }
        }
Beispiel #4
0
        private void BtnRemoveOrder_Click(object sender, RoutedEventArgs e)
        {
            if (LVOrderInfo.SelectedIndex < 0)
            {
                return;
            }
            var orderInfoWillCancel = ((OrderInfo)LVOrderInfo.SelectedItem);
            var orderIdWillCancel   = orderInfoWillCancel.OrderId;

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                RequestManager.getInstance().hideLoading();
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    LVOrderInfo.Items.Remove(orderInfoWillCancel);
                }
            };

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

            OrderManager.getInstance().cacelOrderFromServerAndUpdate(
                orderIdWillCancel,
                cbSuccessSent,
                cbError
                );
        }
Beispiel #5
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            float quantity = 0;

            if (!float.TryParse(TextBoxQuantity.Text, out quantity) ||
                ComboBoxIngredient.SelectedIndex < 0)
            {
                WindownsManager.getInstance().showMessageBoxCheckInfoAgain();
                return;
            }
            var id       = ((ComboData)ComboBoxIngredient.SelectedItem).Id;
            var name     = IngredientManager.getInstance().IngredientList[id].Name;
            var unitName = UnitManager.getInstance().UnitList[IngredientManager.getInstance().IngredientList[id].UnitId].Name;

            foreach (IngredientWithFoodTable ingredientWithFoodTable in DataGridIngredient.Items)
            {
                if (ingredientWithFoodTable.Id == id)
                {
                    WindownsManager.getInstance().showMessageBoxCheckInfoAgain();
                    return;
                }
            }

            _ingredientsWithFood.Add(new IngredientWithFoodTable()
            {
                Id       = id,
                Name     = name,
                UnitName = unitName,
                Quantity = quantity
            });
        }
        private void ComboBoxState_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_prepareFood == null ||
                _isReloading == true)
            {
                return;
            }
            var prepareFoodState = (PrepareFoodState)ComboBoxState.SelectedIndex;

            RequestManager.getInstance().showLoading();
            PrepareFoodManager.getInstance().setStatePrepareFoodAndUpdate(
                _prepareFood.PrepareFoodId,
                prepareFoodState,
                delegate(NetworkResponse rs) {
                if (rs.Successful)
                {
                    _prepareFood = PrepareFoodManager.getInstance().PrepareFoodList[_prepareFood.PrepareFoodId];
                    resetUI();
                }
                else
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                RequestManager.getInstance().hideLoading();
            },
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                RequestManager.getInstance().hideLoading();
            }
                );
        }
 private void BtnConfirm_Click(object sender, RoutedEventArgs e)
 {
     RestaurantInfoManager.getInstance().setName(TextBoxName.Text, false);
     RestaurantInfoManager.getInstance().setPhone(TextBoxPhone.Text, false);
     RestaurantInfoManager.getInstance().setAddess(TextBoxAddress.Text);
     WindownsManager.getInstance().showMessageBoxConfirm("Đổi thông tin thành công", "Chúc mừng");
 }
Beispiel #8
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (ComboBoxIngredient.SelectedIndex < 0 ||
                TextBoxTotal.Text == "0" ||
                string.IsNullOrEmpty(TextBoxTotal.Text))
            {
                WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                return;
            }
            decimal quantity = 0;

            decimal.TryParse(TextBoxQuantity.Text, out quantity);

            decimal price = 0;

            decimal.TryParse(TextBoxPrice.Text, out price);

            var ingredientId = (int)((ComboBoxItem)ComboBoxIngredient.SelectedItem).Tag;

            var importIngredientWithBill = new IngredientWithImportBill();

            importIngredientWithBill.IngredientId       = ingredientId;
            importIngredientWithBill.Ingredient         = IngredientManager.getInstance().IngredientList[ingredientId];
            importIngredientWithBill.Quantities         = (float)quantity;
            importIngredientWithBill.SinglePricePerUnit = price;

            LVIngredient.Items.Add(new ImportIngredientCell(importIngredientWithBill, this));
            reloadTotalBill();
        }
        private void BtnRemoveBill_Click(object sender, RoutedEventArgs e)
        {
            if (LVBill.SelectedIndex < 0)
            {
                return;
            }
            var selectedItem   = ((ImportHistoryCell)LVBill.SelectedItem);
            var billIdSelected = selectedItem.importBill.ImportBillId;

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    LVBill.Items.Remove(selectedItem);
                }
                RequestManager.getInstance().hideLoading();
            };

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

            ImportBillManager.getInstance().deleteImportBillFromServerAndUpdate(
                billIdSelected,
                cbSuccessSent,
                cbError
                );
        }
        private void onPayOneOrder(OrderInfo orderInfo, Action cb)
        {
            var orderInfoWillPay = orderInfo;
            var orderIdWillPay   = orderInfo.OrderId;
            var moneyWillPay     = (double)OrderManager.getInstance().OrderList[orderIdWillPay].BillMoney;

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                RequestManager.getInstance().hideLoading();
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    LVOrderInfo.Items.Remove(orderInfoWillPay);
                    onChangeMoney();
                }
                cb();
            };

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

            OrderManager.getInstance().payOrderFromServerAndUpdate(
                orderIdWillPay,
                (double)OrderManager.getInstance().OrderList[orderIdWillPay].BillMoney,
                cbSuccessSent,
                cbError
                );
        }
        private void BtnPay_Click(object sender, RoutedEventArgs e)
        {
            var orderList = new List <Order>();

            foreach (OrderInfo orderInfo in LVOrderInfo.Items.OfType <OrderInfo>())
            {
                orderList.Add(OrderManager.getInstance().OrderList[orderInfo.OrderId]);
                if (orderInfo.BtnAccept.IsVisible)
                {
                    WindownsManager.getInstance().showMessageBoxConfirm("Vui lòng xác nhận mọi thay đổi trước khi thanh toán.");
                    return;
                }
            }

            var exportWindow = new ExportBillWindow(orderList, delegate() {
                Action pay = null;
                pay        = delegate() {
                    if (LVOrderInfo.Items.Count > 0)
                    {
                        onPayOneOrder((OrderInfo)LVOrderInfo.Items[LVOrderInfo.Items.Count - 1], pay);
                    }
                };
                pay();
            });

            exportWindow.ShowDialog();
        }
Beispiel #12
0
        public void reloadFoodTableUI(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
                    {
                        reloadFoodTableUI(false, cbAfterReload);
                    }
                };

                Action <string> cbError =
                    delegate(string err) {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                    RequestManager.getInstance().hideLoading();
                };
                FoodManager.getInstance().getAllFoodFromServerAndUpdate(
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                LVFood.Items.Clear();
                foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList)
                {
                    if (entry.Value != null)
                    {
                        var foodCell = new FoodCell(entry.Value, this);
                        LVFood.Items.Add(foodCell);

                        var imageId = entry.Value.ImageId ?? default(int);
                        if (entry.Value.ImageId != null &&
                            imageId >= 0)
                        {
                            if (ImageManager.getInstance().checkImageExistLocal(imageId))
                            {
                                ImageManager.getInstance().loadImage(imageId, delegate(byte[] imageData) {
                                    foodCell.setImageFood(UtilFuction.ByteToImage(imageData));
                                });
                            }
                            else
                            {
                                ImageManager.getInstance().loadImage(imageId, delegate(byte[] imageData) {
                                    checkAndSetImageForFoodCell(entry.Value.FoodId, imageId, UtilFuction.ByteToImage(imageData));
                                });
                            }
                        }
                    }
                }
                cbAfterReload?.Invoke();
            }
        }
        private void BtnAddOrder_Click(object sender, RoutedEventArgs e)
        {
            RequestManager.getInstance().showLoading();
            Action <NetworkResponse, int> cbSuccessSent =
                delegate(NetworkResponse networkResponse, int newOrderId) {
                RequestManager.getInstance().hideLoading();
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    LVOrderInfo.Items.Add(new OrderInfo(newOrderId, this));
                }
            };

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

            OrderManager.getInstance().createOrderFromServerAndUpdate(
                TableData.TableId,
                new List <FoodWithOrder>(),
                cbSuccessSent,
                cbError
                );
        }
Beispiel #14
0
        private void updateOrCreateFood()
        {
            loadingAnim.Visibility = Visibility.Visible;
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    if (_foodTab != null)
                    {
                        _foodTab.reloadFoodTableUI();
                    }
                    Close();
                }
                loadingAnim.Visibility = Visibility.Hidden;
            };

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

            var     ingredientsWithFood = getIngredientWithFoodListFromTable();
            decimal price = 0;

            Decimal.TryParse(TextBoxPrice.Text, out price);
            try {
                if (_foodDetailId != Constant.ID_CREATE_NEW)
                {
                    FoodManager.getInstance().updateFoodFromServerAndUpdate(
                        _foodDetailId,
                        TextBoxName.Text,
                        ingredientsWithFood,
                        price,
                        Convert.ToInt64(((ComboData)ComboBoxCategory.SelectedItem).Id),
                        _currentImageId,
                        cbSuccessSent,
                        cbError
                        );
                }
                else
                {
                    FoodManager.getInstance().createFoodFromServerAndUpdate(
                        TextBoxName.Text,
                        ingredientsWithFood,
                        price,
                        Convert.ToInt64(((ComboData)ComboBoxCategory.SelectedItem).Id),
                        _currentImageId,
                        cbSuccessSent,
                        cbError
                        );
                }
            } catch (Exception ex) {
            }
        }
Beispiel #15
0
 private void BtnEditCategory_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridCategory.SelectedItem != null)
     {
         CategoryTable categoryTable = DataGridCategory.SelectedItem as CategoryTable;
         WindownsManager.getInstance().showDetailFoodWithCategorizeWindow(this, categoryTable.Id);
     }
 }
Beispiel #16
0
 private void DataGridCategory_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (DataGridCategory.SelectedItem != null)
     {
         CategoryTable categoryTable = DataGridCategory.SelectedItem as CategoryTable;
         WindownsManager.getInstance().showDetailFoodWithCategorizeWindow(this, categoryTable.Id);
     }
 }
 private void BtnEditUnit_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridUnit.SelectedItem != null)
     {
         UnitTable unitTable = DataGridUnit.SelectedItem as UnitTable;
         WindownsManager.getInstance().showDetailUnitWindow(this, unitTable.Id);
     }
 }
 private void BtnEditIngredient_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridIngredient.SelectedItem != null)
     {
         IngredientTable ingredientTable = DataGridIngredient.SelectedItem as IngredientTable;
         WindownsManager.getInstance().showDetailIngredientWindow(this, ingredientTable.Id);
     }
 }
 private void DataGridUnit_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (DataGridUnit.SelectedItem != null)
     {
         UnitTable unitTable = DataGridUnit.SelectedItem as UnitTable;
         WindownsManager.getInstance().showDetailUnitWindow(this, unitTable.Id);
     }
 }
 private void DataGridIngredient_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (DataGridIngredient.SelectedItem != null)
     {
         IngredientTable ingredientTable = DataGridIngredient.SelectedItem as IngredientTable;
         WindownsManager.getInstance().showDetailIngredientWindow(this, ingredientTable.Id);
     }
 }
        private void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (((ComboData)ComboBoxUnit.SelectedItem) == null ||
                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 (_ingredientTab != null)
                    {
                        _ingredientTab.reloadIngredientTableUI();
                    }
                    this.Close();
                }
                loadingAnim.Visibility = Visibility.Hidden;
            };

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

            if (_ingredientDetailId != Constant.ID_CREATE_NEW)
            {
                IngredientManager.getInstance().updateIngredientFromServerAndUpdate(
                    _ingredientDetailId,
                    TextBoxName.Text,
                    ((ComboData)ComboBoxUnit.SelectedItem).Id,
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                IngredientManager.getInstance().createIngredientFromServerAndUpdate(
                    TextBoxName.Text,
                    ((ComboData)ComboBoxUnit.SelectedItem).Id,
                    cbSuccessSent,
                    cbError
                    );
            }
        }
Beispiel #22
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (sender != null)
            {
                if (string.IsNullOrEmpty(TextBoxUserName.Text))
                {
                    WindownsManager.getInstance().showMessageBoxConfirm("Chưa nhập tài khoản", "Đăng nhập thất bại");
                    return;
                }
                else if (string.IsNullOrEmpty(PasswordBoxPassword.Password))
                {
                    WindownsManager.getInstance().showMessageBoxConfirm("Chưa nhập mật khẩu", "Đăng nhập thất bại");
                    return;
                }
            }
            loadingAnim.Visibility = Visibility.Visible;
            var           userInfoManager = UserInfoManager.getInstance();
            Action <User> cbSuccess       =
                delegate(User result)
            {
                userInfoManager.setIsKeepSignedIn(CheckBoxKeepLogin.IsChecked, false);
                userInfoManager.setIsRememberPass(CheckBoxRememberPass.IsChecked, false);
                userInfoManager.setPreviousPass(CheckBoxRememberPass.IsChecked == false ? "" : PasswordBoxPassword.Password, false);
                userInfoManager.setPreviousAcc(TextBoxUserName.Text);

                MainWindow mainWin = new MainWindow();
                mainWin.Show();

                Close();
            };
            Action <HttpStatusCode> cbFail = delegate(HttpStatusCode code)
            {
                if (code == HttpStatusCode.Unauthorized)
                {
                    WindownsManager.getInstance().showMessageBoxConfirm("Sai tài khoản hoặc mật khẩu", "Đăng nhập thất bại");
                }
                else
                {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                }
                loadingAnim.Visibility = Visibility.Hidden;
            };

            userInfoManager.getAccessTokenAsync(
                TextBoxUserName.Text,
                PasswordBoxPassword.Password,
                cbSuccess,
                cbFail
                );
            //MainWindow mainWin = new MainWindow();
            //mainWin.Show();
        }
        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
                    );
            }
        }
        public void reloadIngredientTableUI(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
                    {
                        reloadIngredientTableUI(false, cbAfterReload);
                    }
                };

                Action <string> cbError =
                    delegate(string err) {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                    RequestManager.getInstance().hideLoading();
                };
                IngredientManager.getInstance().getAllIngredientFromServerAndUpdate(
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                ingredientListTable.Clear();
                foreach (KeyValuePair <int, Ingredient> entry in IngredientManager.getInstance().IngredientList)
                {
                    if (entry.Value != null)
                    {
                        ingredientListTable.Add(new IngredientTable()
                        {
                            Id       = entry.Value.IngredientId,
                            Name     = entry.Value.Name,
                            UnitName = UnitManager.getInstance().UnitList[entry.Value.UnitId].Name
                        });
                    }
                }
                cbAfterReload?.Invoke();
            }
        }
Beispiel #25
0
        private void BtnChangeTableId_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            int newTableId = 0;

            if (!int.TryParse(TextBoxCurrentTableId.Text, out newTableId))
            {
                return;
            }
            int oldTableId = ((TableInfo)LVTable.SelectedItem).TableData.TableId;

            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    foreach (KeyValuePair <int, Order> entry in OrderManager.getInstance().OrderList)
                    {
                        var table = ((List <TableWithOrder>)entry.Value.TableWithOrders).Find(t => t.TableId == oldTableId);
                        if (entry.Value != null &&
                            table != null)
                        {
                            table.TableId = newTableId;
                        }
                    }
                    reloadLVTable();
                }
                RequestManager.getInstance().hideLoading();
            };

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

            TableManager.getInstance().updateTableFromServerAndUpdate(
                oldTableId,
                newTableId,
                cbSuccessSent,
                cbError
                );
        }
Beispiel #26
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();
            }
        }
Beispiel #27
0
        private void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(PasswordBoxNewPassword.Password))
            {
                WindownsManager.getInstance().showMessageBoxConfirm("Chưa nhập mật khẩu mới", "Đổi mật khẩu thất bại");
                return;
            }
            else if (string.IsNullOrEmpty(PasswordBoxConfirmPassword.Password))
            {
                WindownsManager.getInstance().showMessageBoxConfirm("Chưa nhập mật khẩu xác nhận", "Đổi mật khẩu thất bại");
                return;
            }
            else if (!PasswordBoxConfirmPassword.Password.Equals(PasswordBoxNewPassword.Password))
            {
                WindownsManager.getInstance().showMessageBoxConfirm("Mật khẩu xác nhận không khớp", "Đổi mật khẩu thất bại");
                return;
            }
            loadingAnim.Visibility = Visibility.Visible;
            var userInfoManager = UserInfoManager.getInstance();
            Action <NetworkResponse> cbSuccess =
                delegate(NetworkResponse result) {
                if (result.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxConfirm("Mật khẩu của tài khoản " + _userName + " đã được cập nhật", "Thành công");
                }
                else
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                loadingAnim.Visibility = Visibility.Hidden;
            };
            Action <string> cbFail = delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                loadingAnim.Visibility = Visibility.Hidden;
            };

            UserManager.getInstance().changePasswordFromServerAndUpdate(
                _userName,
                PasswordBoxNewPassword.Password,
                cbSuccess,
                cbFail
                );
        }
        public void reloadFoodTableUI(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
                    {
                        reloadFoodTableUI(false, cbAfterReload);
                    }
                };

                Action <string> cbError =
                    delegate(string err) {
                    WindownsManager.getInstance().showMessageBoxErrorNetwork();
                    RequestManager.getInstance().hideLoading();
                };
                FoodManager.getInstance().getAllFoodFromServerAndUpdate(
                    cbSuccessSent,
                    cbError
                    );
            }
            else
            {
                LVFood.Items.Clear();
                foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList)
                {
                    if (entry.Value != null)
                    {
                        var foodCell = new FoodCell(entry.Value, this);
                        LVFood.Items.Add(foodCell);
                    }
                }
                cbAfterReload?.Invoke();
            }
        }
Beispiel #29
0
        private void updateFoodWithOrderAndReloadUI()
        {
            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    reloadAllUI();
                }
                RequestManager.getInstance().hideLoading();
            };

            Action <string> cbError =
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                RequestManager.getInstance().hideLoading();
            };
            var listFoodWithOrders = new List <FoodWithOrder>();

            foreach (OrderWithFood orderWithFood in listViewOrderWithFood.Items.OfType <OrderWithFood>())
            {
                var newQuantity = orderWithFood._foodWithOrder.Quantities;
                int.TryParse(orderWithFood.TextBoxQuantity.Text, out newQuantity);
                listFoodWithOrders.Add(new FoodWithOrder()
                {
                    FoodId     = orderWithFood._foodWithOrder.FoodId,
                    OrderId    = orderWithFood._foodWithOrder.OrderId,
                    Quantities = newQuantity
                });
            }
            OrderManager.getInstance().updateOrderWithFoodsFromServerAndUpdate(
                OrderId,
                listFoodWithOrders,
                cbSuccessSent,
                cbError
                );
        }
Beispiel #30
0
        private void BtnImport_Click(object sender, RoutedEventArgs e)
        {
            RequestManager.getInstance().showLoading();
            Action <NetworkResponse> cbSuccessSent =
                delegate(NetworkResponse networkResponse) {
                if (!networkResponse.Successful)
                {
                    WindownsManager.getInstance().showMessageBoxSomeThingWrong();
                }
                else
                {
                    LVIngredient.Items.Clear();
                    reloadTotalBill();
                }
                RequestManager.getInstance().hideLoading();
            };

            Action <string> cbError =
                delegate(string err) {
                WindownsManager.getInstance().showMessageBoxErrorNetwork();
                RequestManager.getInstance().hideLoading();
            };
            var ingredientWithImportBillList = new List <IngredientWithImportBill>();

            foreach (ImportIngredientCell importIngredientCell in LVIngredient.Items.OfType <ImportIngredientCell>())
            {
                ingredientWithImportBillList.Add(new IngredientWithImportBill()
                {
                    IngredientId       = importIngredientCell._ingredientWithImportBill.Ingredient.IngredientId,
                    SinglePricePerUnit = importIngredientCell._ingredientWithImportBill.SinglePricePerUnit,
                    Quantities         = importIngredientCell._ingredientWithImportBill.Quantities
                });
            }
            ImportBillManager.getInstance().createImportBillFromServerAndUpdate(
                ingredientWithImportBillList,
                cbSuccessSent,
                cbError
                );
        }