/// <summary>
        /// Loads user preferences and displays them
        /// </summary>
        private void LoadPreferences()
        {
            DescuentoValue        = UserPreferences.GetDescuento();
            DescuentoInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", DescuentoValue);

            NumeroReciboValue        = UserPreferences.GetNumeroRecibo();
            NumeroReciboInitialValue = NumeroReciboValue;

            UbicacionValue        = UserPreferences.GetPreferredLocation();
            UbicacionInitialValue = UbicacionValue;

            RecibosValue        = UserPreferences.GetRecibosLocation();
            RecibosInitialValue = RecibosValue;

            FacturasValue        = UserPreferences.GetFacturasLocation();
            FacturasInitialValue = FacturasValue;

            ReconexionValue        = UserPreferences.GetReconexionValue();
            ReconexionInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ReconexionValue);

            AfiliacionValue        = UserPreferences.GetAfiliacionValue();
            AfiliacionInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", AfiliacionValue);

            DerivacionValue        = UserPreferences.GetDerivacionValue();
            DerivacionInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", DerivacionValue);

            TrasladoValue        = UserPreferences.GetTrasladoValue();
            TrasladoInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", TrasladoValue);

            TVvalue        = UserPreferences.GetTVValue();
            TVInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", TVvalue);

            Megas3Value        = UserPreferences.Get3MegasValue();
            Megas3InitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", Megas3Value);

            Megas5Value        = UserPreferences.Get5MegasValue();
            Megas5InitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", Megas5Value);

            Megas7Value        = UserPreferences.Get7MegasValue();
            Megas7InitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", Megas7Value);

            Megas10Value        = UserPreferences.Get10MegasValue();
            Megas10InitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", Megas10Value);

            (ComboTV3Value, ComboInternet3Value) = UserPreferences.GetCombo3();
            Combo3TVInitialValue       = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboTV3Value);
            Combo3InternetInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboInternet3Value);

            (ComboTV5Value, ComboInternet5Value) = UserPreferences.GetCombo5();
            Combo5TVInitialValue       = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboTV5Value);
            Combo5InternetInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboInternet5Value);

            (ComboTV7Value, ComboInternet7Value) = UserPreferences.GetCombo7();
            Combo7TVInitialValue       = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboTV7Value);
            Combo7InternetInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboInternet7Value);

            (ComboTV10Value, ComboInternet10Value) = UserPreferences.GetCombo10();
            Combo10TVInitialValue       = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboTV10Value);
            Combo10InternetInitialValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C}", ComboInternet10Value);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a traslado to a customer
        /// </summary>
        private void AddTraslado()
        {
            Customer     customer = this.ListViewCustomers.SelectedItem as Customer;
            List <Cargo> cargos   = new List <Cargo>();

            SystemSounds.Beep.Play();
            var r = MessageBox.Show("¿Esta seguro de que desea generar un traslado para el cliente con cedula " + customer.Cedula + " ?", "Informacion", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if ((r == MessageBoxResult.Yes))
            {
                string numeroFactura  = new StringBuilder(customer.Cedula).Append("-").Append(TypeOfRecibos.TRASLADO).Append("-").Append(DateManager.GetDateInSpanish()).ToString();
                int    traslado_value = UserPreferences.GetTrasladoValue();
                Cargo  cargo          = new Cargo(traslado_value, traslado_value, Concepto.Traslado);
                cargos.Add(cargo);
                Factura factura = new Factura(numeroFactura, DateManager.GetToday(), null, null, cargos, customer.Cedula);

                RecibosManager                    recibosManager = new RecibosManager();
                Tuple <Factura, Customer>         pair           = new Tuple <Factura, Customer>(factura, customer);
                List <Tuple <Factura, Customer> > info           = new List <Tuple <Factura, Customer> >();
                info.Add(pair);


                try
                {
                    recibosManager.Valor = cargo.Valor;
                    LoadingWindow loadingWindow = new LoadingWindow();
                    loadingWindow.Show();
                    loadingWindow.StartWorking((object sender, DoWorkEventArgs e) =>
                    {
                        recibosManager.GenerateFiles(info, TypeOfRecibos.TRASLADO, sender, loadingWindow.Status);

                        try
                        {
                            if (BDManager.AddChargeSimple(factura))
                            {
                                this.Dispatcher.Invoke(delegate
                                {
                                    loadingWindow.Hide();
                                    SystemSounds.Beep.Play();
                                    MessageBox.Show("Traslado generado exitosamente!", Messages.Titles.Success, MessageBoxButton.OK, MessageBoxImage.Information);
                                });
                            }
                        }
                        catch (MySqlException ex)
                        {
                            this.Dispatcher.Invoke(delegate {
                                loadingWindow.Hide();
                                SystemSounds.Beep.Play();
                                MessageBox.Show(Messages.Errors.setErrorCodeMessage(ex.Number.ToString()), Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error);
                            });
                        }
                        catch (Exception ex)
                        {
                            this.Dispatcher.Invoke(delegate {
                                loadingWindow.Hide();
                                SystemSounds.Beep.Play();
                                MessageBox.Show(ex.Message, Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error);
                            });
                        }
                    }
                                               );
                }
                catch (Exception)
                {
                    this.Dispatcher.Invoke(delegate
                    {
                        SystemSounds.Beep.Play();
                        MessageBox.Show(Messages.Errors.CouldntReadFile, Messages.Titles.Warninig, MessageBoxButton.OK, MessageBoxImage.Warning);
                    });
                }
            }
        }