Exemple #1
0
        private void generatePriaReport_Click(object sender, EventArgs e)
        {
            using (var generator = new PriaReport())
            {
                foreach (var invoice in invoices.OrderBy(invoice => invoice.GetDate()))
                {
                    foreach (var product in invoice.GetProducts())
                    {
                        if (product.Definition is null)
                        {
                            var dialogResult = new DefinitionsForm(product).ShowDialog();
                            if (dialogResult == DialogResult.Abort)
                            {
                                break;
                            }

                            if (dialogResult == DialogResult.Ignore)
                            {
                                Console.WriteLine($"[SKIPPED]: {product.Name} | Kogus arvel: {product.Amount}");
                                continue;
                            }
                        }
                        if (product.Definition.AncIngredient.Name.Contains("Piim 3"))
                        {
                            generator.AddRow("Piim", invoice, product);
                        }
                        if (product.Definition.AncIngredient.Name.Contains("Keefir"))
                        {
                            generator.AddRow("Keefir", invoice, product);
                        }
                        if (product.Definition.AncIngredient.Name == "Õun")
                        {
                            generator.AddRow("Õun", invoice, product);
                        }
                        if (product.Definition.AncIngredient.Name == "Pirn")
                        {
                            generator.AddRow("Pirn", invoice, product);
                        }
                        if (product.Definition.AncIngredient.Name == "Nuikapsas")
                        {
                            generator.AddRow("Nuikapsas", invoice, product);
                        }
                        if (product.Definition.AncIngredient.Name == "Marjad (külmutatud)")
                        {
                            generator.AddRow("Marjad", invoice, product);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void uploadInvoices_Click(object sender, EventArgs e)
        {
            _ancHandler.AncIngredientsLoader.RunWorkerAsync();
            List <String> allInvalidProducts = new List <String>();

            foreach (DataGridViewRow row in invoiceDataGrid.Rows)
            {
                if ((bool)row.Cells[0].Value)
                {
                    Invoice        invoice         = invoices.Where(i => i.GetInvoiceNumber() == row.Cells[2].Value.ToString()).First();
                    List <Product> invalidProducts = invoice.ParseProducts();
                    if (invalidProducts.Count > 0)
                    {
                        foreach (Product invalidProduct in invalidProducts)
                        {
                            if (!allInvalidProducts.Contains(invalidProduct.Name))
                            {
                                allInvalidProducts.Add(invalidProduct.Name);
                            }
                        }
                    }
                }
            }
            foreach (string invalidProduct in allInvalidProducts)
            {
                Console.WriteLine(invalidProduct);
            }
            MessageBox.Show("Tundmatuid tooteid: " + allInvalidProducts.Count);


            DialogResult   dialogResult         = DialogResult.OK;
            int            totalInvalidProducts = 0;
            List <Invoice> toBeUploadedInvoices = new List <Invoice>();

            foreach (DataGridViewRow row in invoiceDataGrid.Rows)
            {
                if ((bool)row.Cells[0].Value)
                {
                    Invoice        invoice         = invoices.Where(i => i.GetInvoiceNumber() == row.Cells[2].Value.ToString()).First();
                    List <Product> invalidProducts = invoice.ParseProducts();
                    if (invalidProducts.Count > 0)
                    {
                        totalInvalidProducts += invalidProducts.Count;
                        foreach (Product invalidProduct in invalidProducts)
                        {
                            dialogResult = new DefinitionsForm(invalidProduct).ShowDialog();
                            if (dialogResult == DialogResult.Abort)
                            {
                                break;
                            }

                            if (dialogResult == DialogResult.Ignore)
                            {
                                Console.WriteLine($"[SKIPPED]: {invalidProduct.Name} | Kogus arvel: {invalidProduct.Amount}");
                            }
                        }
                    }
                    else
                    {
                        toBeUploadedInvoices.Add(invoice);
                    }
                }
                if (dialogResult == DialogResult.Abort)
                {
                    break;
                }
            }
            populateGrid();
            if (totalInvalidProducts == 0)
            {
                ancStopwatch.Start();
                _ancHandler.AncUploaderWorker.RunWorkerAsync(toBeUploadedInvoices);
            }
        }