예제 #1
0
        private void showClientInfoButton_Click(object sender, EventArgs e)
        {
            if (!(saleBindingSource.Current is Sale sale))
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("По заказу:");
            int index = 1;

            foreach (var variant in sale.Goods.Sells)
            {
                builder.AppendLine($"{index}){variant.Variant.Product.Name}");
                builder.AppendLine($"{variant.Variant.ProductCount} гр. - {variant.Variant.Cost} руб.");
                if (variant.Count > 1)
                {
                    builder.AppendLine($"Количество: {variant.Count}");
                }
                index++;
            }

            builder.AppendLine($"Доставка: {sale.Delivery.Name} ({sale.Delivery.Cost} руб.)");
            builder.AppendLine($"Итого: {sale.Cost} руб.");
            var detailForm = new ClientSaleDocument(builder.ToString());

            detailForm.ShowDialog();
        }
예제 #2
0
        private void newSellButton_Click(object sender, EventArgs e)
        {
            var form = new SaleForm(_dbContext.SellVariants,
                                    _dbContext.Deliveries,
                                    _dbContext.Clients,
                                    _dbContext.SaleStatuses);

            if (form.ShowDialog() == DialogResult.OK)
            {
                //_dbContext.SellCountCollections.Attach(form.Sale.Goods);
                _dbContext.Sales.Add(form.Sale);
                _dbContext.SaveChanges();
                foreach (var sell in form.Sale.Goods.Sells)
                {
                    sell.Variant.Pack.Count--;
                    sell.Variant.Product.Count -= sell.Count * sell.Variant.ProductCount;
                }

                _dbContext.SaveChanges();

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("По заказу:");
                int index = 1;
                foreach (var variant in form.Sale.Goods.Sells)
                {
                    builder.AppendLine($"{index}){variant.Variant.Product.Name}");
                    builder.AppendLine($"{variant.Variant.ProductCount} гр. - {variant.Variant.Cost} руб.");
                    if (variant.Count > 1)
                    {
                        builder.AppendLine($"Количество: {variant.Count}");
                    }
                    index++;
                }

                builder.AppendLine($"Доставка: {form.Sale.Delivery.Name} ({form.Sale.Delivery.Cost} руб.)");
                builder.AppendLine($"Итого: {form.Sale.Cost} руб.");
                var detailForm = new ClientSaleDocument(builder.ToString());
                detailForm.ShowDialog();
            }
            saleBindingSource.ResetBindings(false);
            CheckBalance();
        }