コード例 #1
0
        private void PFDelete_Click(object sender, RoutedEventArgs e)
        {
            if (dgProducts.SelectedIndex != -1)
            {
                Product p = dgProducts.SelectedItem as Product;
                //delete product images in the server
                foreach (Picture pic in p.Pictures)
                {
                    try {
                        WebRequest req = WebRequest.Create(
                            Configs.Data.Global["imgSrvUrl"] + "product/picture?name=" +
                            pic.PictureName + "&token=" +
                            Configs.Data.Global["accessToken"]
                            );
                        req.GetResponse();
                    } catch { }
                }

                Data.Products.Remove(p);
                DbProduct.DeleteProduct(p);
                dgProducts.Items.Refresh();
            }
            resetProductForm();
        }