private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            SetSKU setSKU = new SetSKU(products);

            setSKU.ShowDialog();
            var pr = products[products.Count - 1];

            DataTable.ScrollIntoView(pr);
            DataTable.SelectedItem = pr;
        }
        private void DataTable_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            TextBox t      = e.EditingElement as TextBox;
            String  value  = t.Text.ToString();
            String  header = e.Column.Header.ToString();
            var     sku    = (e.Row.DataContext as Product).sku;

            /// additionally additionally0
            ///
            if (sku != null)
            {
                using (var db = new ProductDBEntitie())
                {
                    var product = (from c in db.Product where c.sku == sku select c).FirstOrDefault();
                    if (product != null)
                    {
                        var additionally  = (from c in db.Additionally where c.id == product.id_additionally select c).FirstOrDefault();
                        var additionally0 = (from c in db.Additionally0 where c.id == product.id_additionally0 select c).FirstOrDefault();

                        if (additionally == null)
                        {
                            additionally = new Additionally();
                            db.Additionally.Add(additionally);
                            db.SaveChanges();
                            product.id_additionally = additionally.id;
                            db.SaveChanges();
                        }
                        Resource res = (from c in db.Resource where c.id == additionally.id_resource select c).FirstOrDefault();

                        if (header.Equals("IMG_1"))
                        {
                            res.img1 = value;
                        }
                        if (header.Equals("IMG_2"))
                        {
                            res.img2 = value;
                        }
                        if (header.Equals("IMG_3"))
                        {
                            res.img3 = value;
                        }
                        if (header.Equals("IMG_4"))
                        {
                            res.img4 = value;
                        }
                        if (header.Equals("PDF_1"))
                        {
                            res.pdf = value;
                        }
                        if (header.Equals("Icon"))
                        {
                            res.pdf = value;
                        }

                        db.Resource.Add(res);
                        db.SaveChanges();
                        additionally.Resource    = res;
                        additionally.id_resource = res.id;
                        db.SaveChanges();


                        if (additionally0 == null)
                        {
                            additionally0 = new Additionally0();
                            db.Additionally0.Add(additionally0);
                            db.SaveChanges();
                            product.id_additionally0 = additionally0.id;
                            db.SaveChanges();
                        }
                        var forName = (from c in db.ForName where c.id == additionally0.id_forname select c).FirstOrDefault();
                        if (header == "FORNAME1")
                        {
                            forName.forname1 = value;
                            try
                            {
                                db.ForName.Add(forName);
                                db.SaveChanges();
                            }
                            catch
                            {
                                string str = value;
                                forName = (from c in db.ForName where c.forname2.Equals(str) select c).FirstOrDefault();
                            }
                            additionally0.id_forname = forName.id;
                            additionally0.ForName    = (ForName)forName;
                            db.SaveChanges();
                            return;
                        }
                        if (header == "FORNAME2")
                        {
                            forName.forname2 = value;
                            try
                            {
                                db.ForName.Add(forName);
                                db.SaveChanges();
                            }
                            catch
                            {
                                string str = value;
                                forName = (from c in db.ForName where c.forname2.Equals(str) select c).FirstOrDefault();
                            }
                            additionally0.id_forname = forName.id;
                            additionally0.ForName    = (ForName)forName;
                            db.SaveChanges();
                            return;
                        }

                        try
                        {
                            if (!product.init_product(header, t.Text.ToString(), ref additionally0))
                            {
                                product.init_product(header, value, ref additionally);
                            }
                        }
                        catch (Exception ee) { MessageBox.Show(ee.Message); }
                        BrandName b = product.BrandName;
                        product.BrandName = null;
                        db.SaveChanges();
                        product.BrandName = b;
                    }
                }
            }
            else
            {
                SetSKU setSKU = new SetSKU(products);
                setSKU.ShowDialog();
            }
        }