コード例 #1
0
        private async void menuitemProductDelete_Click(object sender, RoutedEventArgs e)
        {
            var model = gridProducts.SelectedItem as ProductModel;

            if (model == null)
            {
                return;
            }

            var mboxResult = MessageBox.Show(this, $"Do you want to delete the product \"{model.Product}\"?", "Delete Product", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (mboxResult != MessageBoxResult.OK)
            {
                return;
            }
            Cursor = Cursors.Wait;
            try
            {
                ModelManager modelManager = ModelManager.GetInstance();
                if (await modelManager.DeleteProduct(this.CurrentTenantModel, model))
                {
                    MessageBox.Show("Product delete is success",
                                    "OK", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show("Product delete is failure",
                                    "Error", MessageBoxButton.OK);
                }
            }
            finally
            {
                Cursor = null;
            }
            Cursor = null;
        }