private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                db.Dictionary.Remove(Dictionary);
                db.SaveChanges();
            }

            deleteDictionary?.Invoke();
            this.Close();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                db.Provider.Remove(Provider);
                db.SaveChanges();
            }

            deleteProvider?.Invoke();
            this.Close();
        }
Example #3
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                var oldDictionary = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == Item);
                oldDictionary.NameDictionary = nameDictioanary.Text;
                db.SaveChanges();
            }

            this.Close();
        }
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new groceryContext())
     {
         db.Dictionary.Add(new DictionaryDomain
         {
             NameDictionary = nameDictioanary.Text
         });
         db.SaveChanges();
     }
     addDictionary?.Invoke();
     this.Close();
 }
        private void Denomintation_LostFocus(object sender, RoutedEventArgs e)
        {
            var textBox  = (TextBox)sender;
            var selected = (ProviderModel)database.SelectedItem;

            using (var db = new groceryContext())
            {
                var provider = db.Provider.FirstOrDefault(domain => selected.IdProvider == domain.IdProvider);
                switch (textBox.Name)
                {
                case "denomintation":
                    provider.DenomintaionProvider = textBox.Text;
                    break;

                case "name":
                    provider.NameProvider = textBox.Text;
                    break;

                case "surname":
                    provider.SurnameProvider = textBox.Text;
                    break;

                case "patronymic":
                    provider.PatronymicProvider = textBox.Text;
                    break;

                case "phone":
                    provider.PhoneProvider = textBox.Text;
                    break;

                case "fax":
                    provider.FaxProvider = textBox.Text;
                    break;

                case "city":
                    provider.CityProvider = textBox.Text;
                    break;
                }

                db.SaveChanges();
            }
        }
Example #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                db.Provider.Add(new ProviderDomain
                {
                    PatronymicProvider   = patronymic.Text,
                    DenomintaionProvider = denomintation.Text,
                    CityProvider         = city.Text,
                    FaxProvider          = fax.Text,
                    NameProvider         = name.Text,
                    PhoneProvider        = phone.Text,
                    SurnameProvider      = surname.Text
                });
                db.SaveChanges();
            }

            addProvider?.Invoke();
            this.Close();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                var product = (from DictionaryModel productsSelectedItem in products.SelectedItems
                               select new ProductDomain
                {
                    IdDictionary = productsSelectedItem.IdDictionary,
                    RestProduct = int.Parse(count.Text),
                    CountProduct = int.Parse(count.Text),
                    ShelfLifeProduct = DateTime.Parse(date.Text),
                    IdDictionaryNavigation = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == productsSelectedItem.IdDictionary),
                    Price = decimal.Parse(price.Text)
                }).ToList();

                db.Product.AddRange(product);

                var waybill = new WaybillDomain
                {
                    IdData               = DateTime.Now,
                    IdProvider           = int.Parse(providers.SelectedValue.ToString()),
                    IdProviderNavigation = db.Provider.FirstOrDefault(domain => domain.IdProvider == int.Parse(providers.SelectedValue.ToString())),
                    Product              = product
                };

                db.Waybill.Add(waybill);

                foreach (var productDomain in product)
                {
                    productDomain.IdWaybillNavigation = waybill;
                }

                db.SaveChanges();

                addWaybill?.Invoke();
                this.Close();
            }
        }
Example #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new groceryContext())
            {
                var sell = new SaleDomain
                {
                    IdProductNavigation = db.Product.FirstOrDefault(domain => domain.IdProduct == int.Parse(products.SelectedValue.ToString())),
                    IdProduct           = int.Parse(products.SelectedValue.ToString()),
                    DataSale            = DateTime.Now,
                    CountSale           = int.Parse(count.Text)
                };
                var product = db.Product.FirstOrDefault(domain =>
                                                        domain.IdProduct == int.Parse(products.SelectedValue.ToString()));

                product.RestProduct -= int.Parse(count.Text);

                db.Sale.Add(sell);

                db.SaveChanges();

                sellProduct?.Invoke();
                this.Close();
            }
        }