Exemplo n.º 1
0
        /// <summary>Sets up the PrintService dialog.</summary>
        /// <param name="ServiceRow">The service row.</param>
        /// <param name="ProductsTable">The products table.</param>
        private async void SetupPrintServiceDialog(DataRowView ServiceRow, DataTable ProductTable)
        {
            //ServiceRow Array form:
            //"ID = 0"
            //"Kunde ID = 1"
            //"Dato = 2"
            //"Antal Gange = 3"
            //"Betaling = 5"
            //"Nummer = 6"

            try
            {
                var giro   = ServiceRow.Row["Nummer"].ToString().Replace(" ", "").Split('.')[0];
                var number = "";

                switch (ServiceRow.Row["Nummer"].ToString().Replace(" ", "").Split('.')[1] != null)
                {
                case true:
                {
                    number = ServiceRow.Row["Nummer"].ToString().Replace(" ", "").Split('.')[1];
                    break;
                }
                }

                ServiceID.Text  = ServiceRow.Row["ID"].ToString();
                CustomerID.Text = ServiceRow.Row["Kunde ID"].ToString();
                Times.Text      = ServiceRow.Row["Antal Gange"].ToString();
                DateSelect.Text = ServiceRow.Row["Dato"].ToString();
                InvoiceNum.Text = number;

                var date = DateTime.Now.Date;
                date = date.AddMonths(1);
                PayDateSelect.Text = date.ToString("dd-MMM-yy");

                InvoiceMethod.Items.Add(giro);
                InvoiceMethod.SelectedIndex = InvoiceMethod.Items.Count - 1;

                switch (!string.IsNullOrWhiteSpace(ServiceRow.Row["Betaling"].ToString()))
                {
                case true:
                {
                    PaymentMethodText.Items.Add(ServiceRow.Row["Betaling"].ToString());
                    PaymentMethodText.SelectedIndex = PaymentMethodText.Items.Count - 1;
                    break;
                }
                }

                ProductList.Items.Clear();

                switch (ProductTable != null)
                {
                case true:
                {
                    foreach (DataRow row in ProductTable.Rows)
                    {
                        ProductList.Items.Add(new ServiceProduct
                            {
                                ID          = row["Produkt ID"].ToString(),
                                Name        = row["Produkt Navn"].ToString(),
                                Price       = row["Pris"].ToString(),
                                Description = row["Beskrivelse"].ToString()
                            });
                    }
                    break;
                }
                }

                PrintHelper.CalculatePrice(ProductList, PriceTextBox);
                await Task.FromResult(true);
            }
            catch (Exception ex)
            {
                await Task.FromResult(true);

                Log.Error(ex, "An error occured while setting up the PrintService Dialog");
            }
        }