Exemplo n.º 1
0
        private async void btnDone_Click(object sender, RoutedEventArgs e)
        {
            var messageDialog = new MessageDialog("Save your change ???");

            messageDialog.Commands.Add(new UICommand("Yes")
            {
                Id = 0
            });
            messageDialog.Commands.Add(new UICommand("No")
            {
                Id = 1
            });
            messageDialog.DefaultCommandIndex = 0;
            messageDialog.CancelCommandIndex  = 1;

            var result = await messageDialog.ShowAsync();

            if ((int)result.Id == 0)
            {
                Product.Price    = Decimal.Parse(addGia.Text);
                Product.Quantity = int.Parse(addSoLuong.Text);
                QueryForSQLServer.UpdateProduct(Product);

                //delete then insert
                QueryForSQLServer.DeleteProduct_Image(Product.Id);
                int id = 1;
                foreach (var item in Product.Product_Images)
                {
                    item.id        = id;
                    item.ProductId = Product.Id;
                    QueryForSQLServer.InsertProduct_Image(item);
                    id++;
                }
                Handler?.Invoke(Product);
                //e.Handled = true;
                //SystemNavigationManager manager = SystemNavigationManager.GetForCurrentView();
                //manager.BackRequested -= DetailPage_BackRequested;
                //manager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                this.Visibility = Visibility.Collapsed;
            }
            else
            {
                //this.Visibility = Visibility.Collapsed;
            }
        }