Пример #1
0
        private void DelOrder_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            try
            {
                if (long.TryParse(btn.Uid, out var tmp))
                {
                    long ordId  = long.Parse(btn.Uid);
                    long ordNum = (long)btn.Tag;
                    using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                    {
                        var order = db.Orders.Single(s => s.OrderID == ordId && s.OrderNumber == ordNum);
                        int quant = order.ProductQuant;
                        db.Orders.Remove(order);
                        var prodQuant = db.productquantities.Single(s => s.ProductId == order.ProductId && s.StorehouseId == order.StorehouseId);
                        prodQuant.InOrder -= quant;
                        db.Entry(prodQuant).Property(p => p.InOrder).IsModified = true;
                        var prodsQ = db.productquantities.Where(w => w.ProductId == order.ProductId).ToList();
                        foreach (var innerItem in prodsQ)
                        {
                            quant -= (int)innerItem.Quantity;
                        }
                        var product = db.products.Single(s => s.ProductId == order.ProductId);
                        if (quant > 0)
                        {
                            product.ProdStatus = true;
                        }
                        else
                        {
                            product.ProdStatus = false;
                        }
                        db.Entry(product).Property(p => p.ProdStatus).IsModified = true;
                        db.SaveChanges();
                        MessageBox.Show("Бронь успешно удалена!", "Информация", MessageBoxButton.OK);
                        using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                        {
                            var prod = db.products.Single(s => s.ProductId == order.ProductId);
                            var id   = uint.Parse(prod.ProdNumber);
                            if (db2.shop_product.Any(a => a.product_id == id))
                            {
                                var siteProd = db2.shop_product.Single(a => a.product_id == id);
                                siteProd.quantity += quant;
                                db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                                if (siteProd.quantity >= 0)
                                {
                                    db2.SaveChanges();
                                }
                                if (siteProd.quantity >= 0 && siteProd.stock_status_id == 8)
                                {
                                    siteProd.stock_status_id = 7;
                                    db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                                    db2.SaveChangesAsync();
                                }
                            }
                        }
                        LoadOrderList();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " \n" + ex.StackTrace);
                MessageBox.Show("Кажется, что-то пошло не так...", "Информация", MessageBoxButton.OK);
            }
        }
Пример #2
0
        private void AddOrder_Click(object sender, RoutedEventArgs e)
        {
            bool flag = false;

            try
            {
                if (Products.SelectedValue != null)
                {
                    flag = true;
                    int    quant = 0, storeId = 0;
                    string customerName  = Customer.Text;
                    string customerPhone = Phone.Text;
                    int    prodId        = (int)Products.SelectedValue;
                    if (int.TryParse(OrderQuant.Text, out var tmp))
                    {
                        quant = int.Parse(OrderQuant.Text);
                    }
                    else
                    {
                        flag = false;
                    }
                    if (Storehouse.SelectedValue != null)
                    {
                        storeId = (int)Storehouse.SelectedValue;
                    }
                    else
                    {
                        flag = false;
                    }
                    if (flag == true)
                    {
                        using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                        {
                            var prodQuant = db.productquantities.Single(s => s.ProductId == prodId && s.StorehouseId == storeId);
                            var diff      = prodQuant.Quantity - quant;
                            if (diff >= 0)
                            {
                                var  sNum   = db.Orders.ToList();
                                long number = 0;
                                if (sNum.Count == 0)
                                {
                                    number = 1;
                                }
                                else
                                {
                                    number = (long)sNum[sNum.Count - 1].OrderNumber + 1;
                                }
                                Order newOrd = new Order()
                                {
                                    OrderNumber   = number,
                                    OrderCustomer = customerName,
                                    PhoneCustomer = customerPhone,
                                    ProductId     = prodId,
                                    ProductQuant  = quant,
                                    StorehouseId  = storeId,
                                    MengerId      = _user.UserId
                                };
                                db.Orders.Add(newOrd);
                                if (prodQuant.InOrder != null)
                                {
                                    prodQuant.InOrder += quant;
                                }
                                else
                                {
                                    prodQuant.InOrder = quant;
                                }
                                db.Entry(prodQuant).Property(p => p.InOrder).IsModified = true;
                                var prodsQ = db.productquantities.Where(w => w.ProductId == prodId).ToList();
                                foreach (var innerItem in prodsQ)
                                {
                                    quant += (int)innerItem.Quantity;
                                }
                                var product = db.products.Single(s => s.ProductId == prodId);
                                if (quant > 0)
                                {
                                    product.ProdStatus = true;
                                }
                                else
                                {
                                    product.ProdStatus = false;
                                }
                                db.Entry(product).Property(p => p.ProdStatus).IsModified = true;
                                db.SaveChanges();
                                using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                                {
                                    var prod = db.products.Single(s => s.ProductId == prodId);
                                    var id   = uint.Parse(prod.ProdNumber);
                                    if (db2.shop_product.Any(a => a.product_id == id))
                                    {
                                        var siteProd = db2.shop_product.Single(a => a.product_id == id);
                                        siteProd.quantity -= quant;
                                        db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                                        if (siteProd.quantity >= 0)
                                        {
                                            db2.SaveChanges();
                                        }
                                        else
                                        {
                                            log.Error(siteProd.model + siteProd.quantity + siteProd.product_id + " количество не может быть отрицательным");
                                        }
                                        if (siteProd.quantity == 0 && siteProd.stock_status_id == 7)
                                        {
                                            siteProd.stock_status_id = 8;
                                            db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                                            db2.SaveChangesAsync();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("На выбранном складе недостаточное количество товара для осуществления брони!", "Информация", MessageBoxButton.OK);
                            }
                        }
                        LoadOrderList();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " \n" + ex.StackTrace);
                MessageBox.Show("Кажется, что-то пошло не так...", "Информация", MessageBoxButton.OK);
            }
        }
        private void DelSale_Click(object sender, RoutedEventArgs e)
        {
            var btn             = sender as Button;
            DelSaleButtonTag dt = btn.Tag as DelSaleButtonTag;

            try
            {
                DGSaleItems sale  = new DGSaleItems();
                var         sales = lst.Where(w => w.SaleNumber == dt.SaleNumber).ToList();
                foreach (var item in sales)
                {
                    var prod = new product();
                    if (dt.ProdId != null)
                    {
                        sale = lst.First(s => s.ProductId == dt.ProdId && s.SaleNumber == dt.SaleNumber);
                    }
                    if (dt.ServId != null)
                    {
                        sale = lst.First(s => s.ServiceId == dt.ServId && s.SaleNumber == dt.SaleNumber);
                    }
                    lst.Remove(sale);
                    using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                    {
                        prod = db.products.Single(s => s.ProductId == item.ProductId);
                        var oper = db.operations.First(s => (s.ProductId == dt.ProdId && s.SaleNumber == dt.SaleNumber) || (s.ServiceId == dt.ServId && s.SaleNumber == dt.SaleNumber));
                        var res  = MessageBox.Show("Вы действительно хотите полностью удалить данную операцию? Действие необратимо.", "Информация", MessageBoxButton.OKCancel);
                        if (res == MessageBoxResult.OK)
                        {
                            if (oper.ProductId != null && oper.ProductId != 0)
                            {
                                int store = db.storehouses.First(s => s.StorehouseName == oper.Storehouse).StorehouseId;
                                int quant = oper.Count;
                                var pq    = db.productquantities.First(s => s.StorehouseId == store && s.ProductId == oper.ProductId);
                                pq.Quantity += quant;
                                db.Entry(pq).Property(x => x.Quantity).IsModified = true;
                                var prodsQ = db.productquantities.Where(w => w.ProductId == item.ProductId).ToList();
                                foreach (var innerItem in prodsQ)
                                {
                                    quant += (int)innerItem.Quantity;
                                }
                                var product = db.products.Single(s => s.ProductId == item.ProductId);
                                if (quant > 0)
                                {
                                    product.ProdStatus = true;
                                }
                                else
                                {
                                    product.ProdStatus = false;
                                }
                                db.Entry(product).Property(p => p.ProdStatus).IsModified = true;
                                using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                                {
                                    //var prod = db.products.Single(s => s.ProductId == prodId);
                                    var id = int.Parse(prod.ProdNumber);
                                    if (db2.shop_product.Any(a => a.product_id == id))
                                    {
                                        var siteProd = db2.shop_product.Single(a => a.product_id == id);
                                        siteProd.quantity += quant;
                                        db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                                        if (siteProd.quantity >= 0)
                                        {
                                            db2.SaveChanges();
                                        }
                                        if (siteProd.quantity >= 0 && siteProd.stock_status_id == 8)
                                        {
                                            siteProd.stock_status_id = 7;
                                            db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                                            db2.SaveChangesAsync();
                                        }
                                    }
                                }
                            }

                            db.operations.Remove(oper);
                            db.SaveChanges();
                        }
                    }
                }
                Report.Items.Refresh();
            }
            catch (Exception ex) {
                int point = 0;
            }
        }
        private void OffBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int     prodId = (int)ModelsOff.SelectedValue;
                product prod   = new product();
                if (int.TryParse(ProductOffQuantity.Text, out var tmp))
                {
                    int         quant    = int.Parse(ProductOffQuantity.Text);
                    int         store    = (int)StorehouseOffFrom.SelectedValue;
                    CultureInfo provider = CultureInfo.InvariantCulture;
                    using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                    {
                        var  storeHouse = db.productquantities.Single(w => w.ProductId == prodId && w.StorehouseId == store);
                        var  sNum       = db.operations.ToList();
                        long number     = 0;
                        if (sNum.Count == 0)
                        {
                            number = 1;
                        }
                        else
                        {
                            number = (long)sNum[sNum.Count - 1].SaleNumber + 1;
                        }
                        prod = db.products.Single(s => s.ProductId == prodId);
                        var date = DateTime.Now.ToString("dd-MM-yyyy");
                        var time = DateTime.Now.ToString("hh:mm:ss");
                        var diff = storeHouse.Quantity - quant;
                        if (diff >= 0)
                        {
                            operation oper = new operation()
                            {
                                OperationDate = DateTime.ParseExact(date, "dd-MM-yyyy", provider),
                                OperationTime = DateTime.ParseExact(time, "hh:mm:ss", provider),
                                Price         = decimal.Parse(ProductOffPrice.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture) * (decimal)quant,
                                Count         = quant,
                                ProductId     = prodId,
                                //ServiceId = item.ServiceId,
                                SaleNumber    = number,
                                Comment       = OffComment.Text == string.Empty ? "" : OffComment.Text,
                                OperationType = "Списание товара",
                                PayType       = "Списание товара",
                                Storehouse    = db.storehouses.Where(w => w.StorehouseId == store).Select(s => s.StorehouseName).First(),
                                CardPay       = "Нет"

                                                /*
                                                 * PayType = item.PayType,
                                                 * OperationType = item.OperationType,
                                                 * Comment = item.Comment,
                                                 * Storehouse = storehouseName,
                                                 * CardPay = item.CardPayed
                                                 */
                            };
                            db.operations.Add(oper);
                            storeHouse.Quantity -= quant;
                            db.Entry(storeHouse).Property(p => p.Quantity).IsModified = true;
                            if (storeHouse.Quantity > 0)
                            {
                                prod.ProdStatus = true;
                            }
                            else
                            {
                                prod.ProdStatus = false;
                            }
                            db.Entry(prod).Property(p => p.ProdStatus).IsModified = true;
                            db.SaveChanges();
                            MessageBox.Show("Товар успешно списан!", "Информация", MessageBoxButton.OK);
                        }
                        else
                        {
                            MessageBox.Show("На выбранном складе недостаточное количество товара для осуществления операции списания!", "Информация", MessageBoxButton.OK);
                        }
                    }
                    using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                    {
                        var id = int.Parse(prod.ProdNumber);
                        if (db2.shop_product.Any(a => a.product_id == id))
                        {
                            var siteProd = db2.shop_product.Single(a => a.product_id == id);
                            siteProd.quantity -= quant;
                            db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                            if (siteProd.quantity >= 0)
                            {
                                db2.SaveChanges();
                            }
                            else
                            {
                                log.Error(siteProd.model + siteProd.quantity + siteProd.product_id + " количество не может быть отрицательным");
                            }
                            if (siteProd.quantity == 0 && siteProd.stock_status_id == 7)
                            {
                                siteProd.stock_status_id = 8;
                                db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                                db2.SaveChangesAsync();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " \n" + ex.StackTrace);
                MessageBox.Show("Кажется, что-то пошло не так...", "Информация", MessageBoxButton.OK);
            }
        }
        private void InProduct(int category, int ManId, int modelId, string rad, int width, float height, int store, int quant)
        {
            try
            {
                string model = "", manufacturer = "";
                using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                {
                    var product = GetProduct(category, ManId, modelId, rad, width, height);
                    model        = db.models.Single(s => s.ModelId == modelId).ModelName;
                    manufacturer = db.manufacturers.Single(s => s.ManufacturerId == ManId).ManufacturerName;
                    if (db.productquantities.Any(s => s.StorehouseId == store && s.ProductId == product.ProductId))
                    {
                        var storehouse = db.productquantities.Single(s => s.StorehouseId == store && s.ProductId == product.ProductId);
                        storehouse.Quantity += quant;
                        db.Entry(storehouse).Property(p => p.Quantity).IsModified = true;
                        if (storehouse.Quantity > 0)
                        {
                            product.ProdStatus = true;
                        }
                        else
                        {
                            product.ProdStatus = false;
                        }
                        if (db.products.Any(a => a.ProductId == product.ProductId))
                        {
                            var prod = db.products.Single(s => s.ProductId == product.ProductId);
                            prod.ProdStatus = product.ProdStatus;
                            db.Entry(prod).Property(p => p.ProdStatus).IsModified = true;
                        }

                        db.SaveChanges();
                        //GridItemSource(category, product.ProductId);
                        MessageBox.Show("Товар успешно оприходован!", "Информация", MessageBoxButton.OK);
                    }
                    else
                    {
                        productquantity pq = new productquantity()
                        {
                            StorehouseId = store,
                            ProductId    = product.ProductId,
                            Quantity     = quant
                        };
                        db.productquantities.Add(pq);
                        db.SaveChanges();
                        //GridItemSource(category, product.ProductId);
                        MessageBox.Show("Товар успешно добавлен на указанный склад!", "Информация", MessageBoxButton.OK);
                    }
                }
                using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                {
                    var product = GetProduct(category, ManId, modelId, rad, width, height);
                    var id      = uint.Parse(product.ProdNumber);
                    if (db2.shop_product.Any(a => a.product_id == id))
                    {
                        var siteProd = db2.shop_product.Single(a => a.product_id == id);
                        siteProd.quantity += quant;
                        db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                        if (siteProd.quantity >= 0)
                        {
                            db2.SaveChanges();
                        }
                        if (siteProd.quantity >= 0 && siteProd.stock_status_id == 8)
                        {
                            siteProd.stock_status_id = 7;
                            db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                            db2.SaveChangesAsync();
                        }
                    }
                    else
                    {
                        int shopStat = 0;
                        if (quant > 0)//больше нуля - продаем
                        {
                            shopStat = 7;
                        }
                        else//в любом другом случае предзаказ
                        {
                            shopStat = 8;
                        }
                        shop_product sp = new shop_product()
                        {
                            product_id      = id,                                                                        //айдишник продукта в сайтовой базе
                            model           = model,                                                                     //наименование модели
                            quantity        = quant,                                                                     //количество в наличии
                            stock_status_id = shopStat,                                                                  //статус
                            manufacturer_id = db2.shop_manufacturer.Single(s => s.name == manufacturer).manufacturer_id, //получение и присвоение айдишника производителя
                            price           = (decimal)product.Price,                                                    //цена
                            status          = true,
                            //subtract = true,
                        };
                        List <shop_product_attribute> lst = new List <shop_product_attribute>()//список атрибутов
                        {
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 12, text = width.ToString()
                            },                                                                                                                 //ширина
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 13, text = height.ToString()
                            },                                                                                                                  //высота
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 14, text = product.Radius
                            },                                                                                                               //радиус
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 15, text = product.Season
                            },                                                                                                               //сезон, у меня - зима или лето
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 16, text = product.InCol
                            },                                                                                                              //ИН
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 17, text = product.IsCol
                            },                                                                                                              //ИС
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 18, text = product.RFT
                            },                                                                                                            //РанФлэт
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 19, text = product.Gruz
                            },                                                                                                             //Грузовой
                            new shop_product_attribute()
                            {
                                product_id = int.Parse(product.Articul), attribute_id = 20, text = product.Spikes
                            },                                                                                                               //Шипы
                        };
                        shop_product_to_category sptc = new shop_product_to_category()
                        {
                            category_id = 1,
                            product_id  = id
                        };
                        shop_product_to_layout sptl = new shop_product_to_layout()
                        {
                            layout_id  = 0,
                            store_id   = 0,
                            product_id = id
                        };
                        shop_product_to_store spts = new shop_product_to_store()
                        {
                            product_id = id,
                            store_id   = 0
                        };
                        string seasonToMetaTitle = "";
                        switch (product.Season)
                        {
                        case "Лето":
                            seasonToMetaTitle = "Летние";
                            break;

                        case "Зима":
                            seasonToMetaTitle = "Зимние";
                            break;
                        }
                        string productName           = manufacturer + " " + model + " " + width + "/" + height + product.Radius + " " + product.InCol + product.IsCol + " " + product.RFT + product.Spikes;
                        shop_product_description spd = new shop_product_description()
                        {
                            product_id       = id,
                            language_id      = 1,
                            name             = productName,
                            description      = "",
                            tag              = width + "," + height + "," + product.Radius,
                            meta_title       = seasonToMetaTitle + " шины " + productName + ". Магазин автошин TireShop",
                            meta_description = seasonToMetaTitle + " шины " + productName + " по " + product.Price * 4 + " руб/шт. Доставка по СПб и в другие регионы",
                            meta_keyword     = ""
                        };
                        shop_url_alias sua = new shop_url_alias()
                        {
                            query   = "product_id=" + id,
                            keyword = manufacturer + "_" + id
                        };
                        db2.shop_product.Add(sp); //добавили сам продукт
                        foreach (var item in lst)
                        {                         //добавляем все атрибуты шин
                            db2.shop_product_attribute.Add(item);
                        }
                        db2.shop_product_to_category.Add(sptc);
                        db2.shop_product_to_layout.Add(sptl);
                        db2.shop_product_to_store.Add(spts);
                        db2.shop_product_description.Add(spd);
                        db2.shop_url_alias.Add(sua);
                        db2.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " \n" + ex.StackTrace);
                MessageBox.Show("Кажется, что-то пошло не так...", "Информация", MessageBoxButton.OK);
            }
        }
Пример #6
0
        private void SaveSale()
        {
            CultureInfo provider = CultureInfo.InvariantCulture;

            try
            {
                using (u0324292_tyreshopEntities db = new u0324292_tyreshopEntities())
                {
                    var  sNum   = db.operations.ToList();
                    long number = 0;
                    if (sNum.Count == 0)
                    {
                        number = 1;
                    }
                    else
                    {
                        number = (long)sNum[sNum.Count - 1].SaleNumber + 1;
                    }
                    //int storeId = (int)StorehouseFrom.SelectedValue;
                    int quant = 0;
                    foreach (var item in salesToCheck)
                    {
                        string storehouseName = "";
                        if (item.StoreId != null)
                        {
                            var store = db.storehouses.Single(s => s.StorehouseId == item.StoreId);
                            storehouseName = store.StorehouseName;
                        }
                        operation oper = new operation()
                        {
                            OperationDate  = DateTime.ParseExact(item.Date, "dd-MM-yyyy", provider),
                            OperationTime  = DateTime.ParseExact(item.Time, "hh:mm:ss", provider),
                            Price          = item.Price,
                            Count          = item.Quantity,
                            ProductId      = item.ProductId,
                            ServiceId      = item.ServiceId,
                            SaleNumber     = number,
                            PayType        = item.PayType,
                            OperationType  = item.OperationType,
                            Comment        = item.Comment,
                            Storehouse     = storehouseName,
                            CardPay        = item.CardPayed,
                            CardToTotalSum = item.CardToTotalSum,
                            UserId         = item.UserId
                        };
                        db.operations.Add(oper);
                        if (item.StoreId != null)
                        {
                            var store = db.productquantities.Single(s => s.ProductId == item.ProductId && s.StorehouseId == item.StoreId);
                            store.Quantity -= item.Quantity;
                            db.Entry(store).Property(p => p.Quantity).IsModified = true;
                        }
                        if (item.ProductId != null && item.ProductId != 0)
                        {
                            using (u0324292_mainEntities db2 = new u0324292_mainEntities())
                            {
                                var prod = db.products.Single(s => s.ProductId == item.ProductId);
                                var id   = int.Parse(prod.ProdNumber);
                                if (db2.shop_product.Any(a => a.product_id == id))
                                {
                                    var siteProd = db2.shop_product.Single(a => a.product_id == id);
                                    siteProd.quantity -= item.Quantity;
                                    db2.Entry(siteProd).Property(p => p.quantity).IsModified = true;
                                    if (siteProd.quantity >= 0)
                                    {
                                        db2.SaveChanges();
                                    }
                                    else
                                    {
                                        log.Error(siteProd.model + siteProd.quantity + siteProd.product_id + " количество не может быть отрицательным");
                                    }
                                    if (siteProd.quantity == 0 && siteProd.stock_status_id == 7)
                                    {
                                        siteProd.stock_status_id = 8;
                                        db2.Entry(siteProd).Property(p => p.stock_status_id).IsModified = true;
                                        db2.SaveChangesAsync();
                                    }
                                }
                            }
                            var prodsQ = db.productquantities.Where(w => w.ProductId == item.ProductId).ToList();
                            foreach (var innerItem in prodsQ)
                            {
                                quant += (int)innerItem.Quantity;
                            }
                            var product = db.products.Single(s => s.ProductId == item.ProductId);
                            if (quant > 0)
                            {
                                product.ProdStatus = true;
                            }
                            else
                            {
                                product.ProdStatus = false;
                            }
                            db.Entry(product).Property(p => p.ProdStatus).IsModified = true;
                        }
                    }
                    db.SaveChanges();
                    sales.Clear();
                    salesToCheck.Clear();
                    DGSaleFix.Items.Refresh();
                    SaleSave.IsEnabled  = false;
                    PrintSale.IsEnabled = false;
                    Savedoperation      = true;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + " \n" + ex.StackTrace);
                MessageBox.Show("Кажется, что-то пошло не так...", "Информация", MessageBoxButton.OK);
            }
        }