Ejemplo n.º 1
0
        private async Task OnDoPrint()
        {
            if (CollectionView != null && CollectionView.SourceCollection != null && CollectionView.TotalItemCount > 0 && CollectionView.SourceCollection is IEnumerable <Customer> customers)
            {
                var file = await dialogManager.SaveFileDialog(
                    "Guardar clientes",
                    directory : Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    initialFileName : "Clientes.csv",
                    ".csv");

                if (string.IsNullOrWhiteSpace(file) == false)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    StringBuilder moradas       = new StringBuilder();
                    foreach (var c in customers)
                    {
                        moradas.Clear();
                        if (c.BillingAddress != null)
                        {
                            moradas.Append(
                                c.BillingAddress.AddressDetail ??
                                c.BillingAddress.StreetName + " " + c.BillingAddress.BuildingNumber + " " + c.BillingAddress.PostalCode);
                        }

                        stringBuilder.AppendLine($"{c.CustomerTaxID};{c.CompanyName};{c.CustomerID};{moradas};{c.Telephone};;{c.Fax};{c.Email}");
                    }

                    File.WriteAllText(file, stringBuilder.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        private async Task OnDoPrint()
        {
            if (CollectionView != null && CollectionView.SourceCollection != null && CollectionView.TotalItemCount > 0 && CollectionView.SourceCollection is IEnumerable <Stock> products)
            {
                var file = await dialogManager.SaveFileDialog(
                    "Guardar produtos",
                    directory : Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    initialFileName : "Produtos.csv",
                    ".csv");

                if (string.IsNullOrWhiteSpace(file) == false)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (var c in products)
                    {
                        stringBuilder.AppendLine($"{c.ProductCode};{c.ProductDescription};{c.ProductNumberCode};{c.ProductCategory};{c.UnitOfMeasure};{c.ClosingStockQuantity}");
                    }

                    File.WriteAllText(file, stringBuilder.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        private async Task OnDoPrint()
        {
            if (CollectionView != null && CollectionView.SourceCollection != null && CollectionView.TotalItemCount > 0 && CollectionView.SourceCollection is IEnumerable <TaxTableEntry> taxes)
            {
                var file = await dialogManager.SaveFileDialog(
                    "Guardar Impostos",
                    directory : Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    initialFileName : "Impostos.csv",
                    ".csv");

                if (string.IsNullOrWhiteSpace(file) == false)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (var c in taxes)
                    {
                        stringBuilder.AppendLine($"{c.TaxType};{c.Description};{c.TaxCode};{c.TaxCountryRegion};{c.TaxAmount};{c.TaxPercentage};{c.TaxExpirationDate}");
                    }

                    File.WriteAllText(file, stringBuilder.ToString());
                }
            }
        }