Esempio n. 1
0
        public void LoadData()
        {
            lstOrigenListas = dbUser.VerListaPrecio();
            var adapter = new ListasPrecioViewAdapter(this, lstOrigenListas);

            lstDatosListas.Adapter = adapter;
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                if (VariablesGlobales.Idvendedor == 0)
                {
                    Intent i = new Intent(this.ApplicationContext, typeof(MainActivity));
                    i.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                    StartActivity(i);
                    this.Finish();
                }
                SetContentView(Resource.Layout.PaginaConfiguracion);

                var btnVaciarProductos = FindViewById <Button>(Resource.Id.btnVaciarProductos);
                //var btnVaciarCategoriasProductos = FindViewById<Button>(Resource.Id.btnVaciarCategorias);
                var btnVaciarListasPrecio = FindViewById <Button>(Resource.Id.btnVaciarListasPrecio);
                var btnVaciarClientes     = FindViewById <Button>(Resource.Id.btnVaciarClientes);
                var btnVaciarPedidos      = FindViewById <Button>(Resource.Id.btnVaciarPedidos);
                //var btnVaciarPedidosDetalle = FindViewById<Button>(Resource.Id.btnVariarDetallePed);
                var btnGuardarCotizacionMoneda = FindViewById <Button>(Resource.Id.btnCotizacionDolar);
                var btnVolver              = FindViewById <Button>(Resource.Id.btnConfVolverInicio);
                var txtCotizacion          = FindViewById <EditText>(Resource.Id.txtCotizacionDolar);
                var txtMetodoCalculo       = FindViewById <EditText>(Resource.Id.txtMetodoCalculo);
                var txtDireccionWebService = FindViewById <EditText>(Resource.Id.txtDireccionWebService);
                var txtNomWebService       = FindViewById <EditText>(Resource.Id.txtNombWebService);
                SeleccListaPrecios = (Spinner)FindViewById(Resource.Id.spnListaPrecios);
                //dbUser = new ConsultasTablas();

                ListasPrecio  = db.VerListaPrecio();
                ListaVendedor = db.VerListaPreciosVendedor(VariablesGlobales.Idvendedor);
                adapter       = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, ListasPrecio);
                SeleccListaPrecios.Adapter = adapter;

                int posicion = 0;
                for (int i = 0; i < SeleccListaPrecios.Count; i++)
                {
                    if (SeleccListaPrecios.GetItemAtPosition(i).ToString() == ListaVendedor[0].nombre)
                    {
                        posicion = i;
                    }
                }
                //Toast.MakeText(this, "posicion " + posicion, ToastLength.Long).Show();
                SeleccListaPrecios.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(ListasPrecios_ItemSelected);
                MonedaYConfig = db.VerListaConfiguraciones();

                txtCotizacion.Text          = MonedaYConfig[1].valor;
                txtMetodoCalculo.Text       = MonedaYConfig[2].valor;
                txtDireccionWebService.Text = MonedaYConfig[4].valor;
                txtNomWebService.Text       = MonedaYConfig[5].valor;

                SeleccListaPrecios.SetSelection(posicion);
                if (int.Parse(MonedaYConfig[3].valor) != 0)
                {
                    ListasPrecio = new List <ListasPrecio>();
                    ListasPrecio = db.VerListaPrecioId(int.Parse(MonedaYConfig[3].valor));
                    int itemSel = adapter.GetPosition(ListasPrecio[0].nombre);
                }

                btnVaciarProductos.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de productos?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaProductos())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de PRODUCTOS", ToastLength.Long).Show();
                        }
                        if (db.VaciarTablaCategoriasProd())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de categorias", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarListasPrecio.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de productos?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaListasPrecio())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de LISTAS DE PRECIO", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarClientes.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de CLIENTES?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaClientes())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Clientes", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarPedidos.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de PEDIDOS?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaPedidosMaster())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Pedidos", ToastLength.Long).Show();
                        }
                        if (db.VaciarTablaDetallePedidos())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Detalle de pedidos", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnGuardarCotizacionMoneda.Click += delegate
                {
                    if (listaOK == true)
                    {
                        string ItemLIstaPrecios = SeleccListaPrecios.SelectedItem.ToString();
                        ListasPrecio = new List <ListasPrecio>();
                        ListasPrecio = db.ObtenerIDListaPrecios(ItemLIstaPrecios);
                    }
                    double tempCotiza = 0;
                    if (txtCotizacion.Text != "" & double.TryParse(txtCotizacion.Text, out tempCotiza))

                    {
                        string valLista = "0";
                        if (listaOK == true)
                        {
                            valLista = ListasPrecio[0].id.ToString();
                        }
                        else
                        {
                            valLista = "0";
                        }

                        ConfiguracionesVarias moneda = new ConfiguracionesVarias()
                        {
                            id    = 2,
                            valor = txtCotizacion.Text
                        };
                        ConfiguracionesVarias FormulaCalculo = new ConfiguracionesVarias
                        {
                            id    = 3,
                            valor = txtMetodoCalculo.Text
                        };

                        ConfiguracionesVarias listaDefecto = new ConfiguracionesVarias
                        {
                            id    = 4,
                            valor = valLista
                        };
                        db.ActualizarConfiguracion(moneda);
                        db.ActualizarConfiguracion(FormulaCalculo);
                        db.ActualizarConfiguracion(listaDefecto);

                        VariablesGlobales.CotizacionDolar    = double.Parse(txtCotizacion.Text);
                        VariablesGlobales.MetodoCalculo      = int.Parse(txtMetodoCalculo.Text);
                        VariablesGlobales.ListaPrecioCliente = int.Parse(valLista); // ListasPrecio[0].id;

                        Toast.MakeText(this, "Se actualizo configuraciones varias", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "NO SE PUEDEN GUARDAR LAS CONFIGURACIONES VARIAS", ToastLength.Long).Show();
                    }
                    if (txtDireccionWebService.Text != "" & txtDireccionWebService.Text.Contains("http://") == true & txtNomWebService.Text != "" & txtNomWebService.Text.Contains("/") == false)
                    {
                        ConfiguracionesVarias DireccWebService = new ConfiguracionesVarias
                        {
                            id     = 5,
                            nombre = "DireccWebService",
                            valor  = txtDireccionWebService.Text
                        };
                        ConfiguracionesVarias NombWebService = new ConfiguracionesVarias
                        {
                            id     = 6,
                            nombre = "NombWebService",
                            valor  = txtNomWebService.Text
                        };

                        db.ActualizarConfiguracion(DireccWebService);
                        db.ActualizarConfiguracion(NombWebService);

                        VariablesGlobales.DireccWebService = txtDireccionWebService.Text;
                        VariablesGlobales.NombWebService   = txtNomWebService.Text;

                        Toast.MakeText(this, "Se actualizo la configuracion de web service", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "NO SE PUEDEN GUARDAR LAS CONFIGURACIONES DE WEB SERVICE", ToastLength.Long).Show();
                    }
                };
                btnVolver.Click += delegate
                {
                    StartActivity(typeof(PaginaPrincipal));
                };
            }
            catch (Exception ex)
            {
                Toast.MakeText(Application.Context, ex.Message, ToastLength.Short).Show();
            }
        }
Esempio n. 3
0
        public string CalcularPrecioLista(string precio, string utilidad, string utilidad1, string utilidad2, string utilidad3, string utilidad4, string utilidad5, string iva, int idLista, int moneda)
        {
            List <ListasPrecio> listasPrecios = new List <ListasPrecio>();
            ConsultasTablas     dbuser        = new ConsultasTablas();
            double cotizacion = 0;

            if (moneda == 1)
            {
                cotizacion = 1;
            }
            else if (moneda == 2)
            {
                cotizacion = VariablesGlobales.CotizacionDolar;
            }
            string Precios = "";

            if (iva == "")
            {
                iva = "0";
            }
            if (precio == "")
            {
                precio = "0";
            }
            if (utilidad == "")
            {
                utilidad = "0";
            }
            if (utilidad1 == "")
            {
                utilidad1 = "0";
            }
            if (utilidad2 == "")
            {
                utilidad2 = "0";
            }
            if (utilidad3 == "")
            {
                utilidad3 = "0";
            }
            if (utilidad4 == "")
            {
                utilidad4 = "0";
            }
            if (utilidad5 == "")
            {
                utilidad5 = "0";
            }

            precio    = CambiarPuntoDecimalEU(precio);
            iva       = CambiarPuntoDecimalEU(iva);
            utilidad  = CambiarPuntoDecimalEU(utilidad);
            utilidad1 = CambiarPuntoDecimalEU(utilidad1);
            utilidad2 = CambiarPuntoDecimalEU(utilidad2);
            utilidad3 = CambiarPuntoDecimalEU(utilidad3);
            utilidad4 = CambiarPuntoDecimalEU(utilidad4);
            utilidad5 = CambiarPuntoDecimalEU(utilidad5);

            double LISTA       = 0;
            double precioFinal = 0;

            double IVA       = Convert.ToDouble(iva);
            double PRECIO    = Convert.ToDouble(precio);
            double GANANCIA  = Convert.ToDouble(utilidad);
            double GANANCIA1 = Convert.ToDouble(utilidad1);
            double GANANCIA2 = Convert.ToDouble(utilidad2);
            double GANANCIA3 = Convert.ToDouble(utilidad3);
            double GANANCIA4 = Convert.ToDouble(utilidad4);
            double GANANCIA5 = Convert.ToDouble(utilidad5);
            double utilSum   = GANANCIA2;

            IVA       = (IVA + 100) / 100;
            GANANCIA  = (GANANCIA + 100) / 100;
            GANANCIA1 = (GANANCIA1 + 100) / 100;
            GANANCIA2 = (GANANCIA2 + 100) / 100;
            GANANCIA3 = (GANANCIA3 + 100) / 100;
            GANANCIA4 = (GANANCIA4 + 100) / 100;
            GANANCIA5 = (GANANCIA5 + 100) / 100;


            if (idLista == 0)
            {
                listasPrecios = dbuser.VerListaPrecio();

                for (int i = 0; i <= listasPrecios.Count() - 1; i++)
                {
                    string modo   = listasPrecios[i].utilidad;
                    int    auxcol = listasPrecios[i].auxcol;
                    if (modo.Contains("%"))
                    {
                        LISTA = Convert.ToDouble(listasPrecios[i].utilidad.Replace(",", ".").Replace("%", ""));
                        //utilSum = (utilSum + LISTA + 100) / 100;
                        LISTA = (LISTA + 100) / 100;

                        precioFinal = Math.Round(PRECIO * IVA * LISTA * cotizacion, 2);
                        Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                    }
                    else
                    {
                        LISTA   = Convert.ToDouble(listasPrecios[i].utilidad.Replace(",", "."));
                        utilSum = (utilSum + LISTA + 100) / 100;
                        LISTA   = (LISTA + 100) / 100;
                        if (VariablesGlobales.MetodoCalculo == 1)
                        {
                            switch (auxcol)
                            {
                            case 0:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 1:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA1 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 2:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA2 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 3:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA3 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 4:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA4 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 5:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA5 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;
                            }
                        }
                        else if (VariablesGlobales.MetodoCalculo == 0)
                        {
                            switch (auxcol)
                            {
                            case 0:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 1:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA1 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 2:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA2 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 3:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA3 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 4:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA4 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 5:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA5 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;
                            }
                        }
                    }
                }
                Precios = "Seleccione un cliente para poder ver los precios";
                return(Precios);
            }
            else
            {
                listasPrecios = dbuser.VerListaPrecioId(idLista);
                string modo   = listasPrecios[0].utilidad;
                int    auxcol = listasPrecios[0].auxcol;
                if (modo.Contains("%"))
                {
                    LISTA = Convert.ToDouble(listasPrecios[0].utilidad.Replace(",", ".").Replace("%", ""));
                    LISTA = (LISTA + 100) / 100;

                    precioFinal = Math.Round(PRECIO * IVA * LISTA * cotizacion, 2);
                    Precios     = precioFinal.ToString();
                    return(Precios);
                }
                else
                {
                    LISTA = Convert.ToDouble(listasPrecios[0].utilidad.Replace(",", "."));
                    LISTA = (LISTA + 100) / 100;

                    if (VariablesGlobales.MetodoCalculo == 1)
                    {
                        switch (auxcol)
                        {
                        case 0:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 1:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA1 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 2:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA2 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 3:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA3 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 4:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA4 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 5:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA5 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;
                        }
                    }
                    else if (VariablesGlobales.MetodoCalculo == 0)
                    {
                        switch (auxcol)
                        {
                        case 0:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 1:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA1 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 2:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA2 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 3:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA3 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 4:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA4 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 5:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA5 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;
                        }
                    }
                    return(Precios);
                }
            }
        }