private void weightBtn_Click(object sender, RoutedEventArgs e)
 {
     var pgd = new WeightDetail();
     bool? res = ZeroMessageBox.Show(pgd, Properties.Resources.NewMeasurementUnit);
     if (res.HasValue && res.Value)
     {
         BusinessContext.Instance.Model.Weights.AddObject(pgd.CurrentWeigth);
         BusinessContext.Instance.Model.SaveChanges(SaveOptions.AcceptAllChangesAfterSave, true);
         weightBox.Items.Add(pgd.CurrentWeigth);
         ProductDetailViewModel.Product.Price1.Weight = pgd.CurrentWeigth;
     }
 }
 private void weightBoxItemButton_Click(object sender, RoutedEventArgs e)
 {
     var t = (int)((Button)sender).DataContext;
     var algo =
     BusinessContext.Instance.Model.Weights.First(w => w.Code == t);
     var pgd = new WeightDetail(algo);
     bool? res = ZeroMessageBox.Show(pgd, Properties.Resources.EditMeasurementUnit);
     if (res.HasValue && res.Value)
     {
         BusinessContext.Instance.Model.SaveChanges(SaveOptions.AcceptAllChangesAfterSave, true);
     }
     else
     {
         BusinessContext.Instance.Model.Refresh(RefreshMode.StoreWins, algo);
     }
 }