예제 #1
0
        private void btnCreateSale_Click(object sender, EventArgs e)
        {
            try
            {
                ProductSaleContainer prodSaleCont = new ProductSaleContainer();
                for (int i = 0; i < lvProductSrecOffer.Rows.Count; i++)
                {
                    if ((bool)lvProductSrecOffer.Rows[i].Cells[0].Value)
                    {
                        prodSaleCont.productsId.Add(lProductSrecOffer[i].id_product);
                    }
                }

                prodSaleCont.sale = nudSale.Value;

                if (File.Exists("ProductSale.xml"))
                {
                    File.Delete("ProductSale.xml");
                }

                Serializer.SerializeClass(typeof(ProductSaleContainer), prodSaleCont, "ProductSale.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void LoadProductView()
        {
            try
            {
                if (client.sex == 1)
                {
                    mannequinImg = Image.FromFile(@"res\images\Man.png");
                }
                else
                {
                    mannequinImg = Image.FromFile(@"res\images\Woman.png");
                }

                listProduct.Clear();
                if (tanyaM.ShoppersList()
                    .Where(x => x.id_client == client.id_client)
                    .ToList().Count != 0)
                {
                    ProductSaleContainer prodSaleC = Serializer.DeserializeClass(typeof(ProductSaleContainer), "ProductSale.xml") as
                                                     ProductSaleContainer;
                    if (prodSaleC != null)
                    {
                        saleSize    = prodSaleC.sale;
                        listProduct = orderControl.AllProducts();

                        for (int i = 0; i < listProduct.Count; i++)
                        {
                            if (prodSaleC.productsId.Contains(listProduct[i].id_product))
                            {
                                listProduct[i].price = DecrementPercentages(listProduct[i].price, saleSize);
                            }
                        }

                        lblSaleInfo.Text = "Вам предоставлена специальная скидка на товары в размере " + saleSize + "%";
                    }
                    else
                    {
                        listProduct      = orderControl.AllProducts();
                        lblSaleInfo.Text = "";
                    }
                }
                else
                {
                    listProduct      = orderControl.AllProducts();
                    lblSaleInfo.Text = "";
                }

                //рисуем изначальный манекен
                DrawClothesOnMannequin(clothes);

                // извлекаются все изображения и добавляются в imagelist
                imageList.Images.Clear();

                foreach (var product in listProduct)
                {
                    imageList.Images.Add(ImgConverter.ImageFromString(product.photo));
                }

                //все продукты добавляются в listView
                UpdateListViewProducts();

                clothes.Clear();             //очищаем список добавленных на манекен вещей
                listSelectedProduct.Clear(); //очищаем список выбранных нами вещей
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }